- Implemented MCP server with 8 n8n tools - Added n8n API client for workflow operations - Configured VS Code settings with API authentication - Added comprehensive documentation and setup guides - Tested and verified connection to n8n instance
50 lines
1.4 KiB
JavaScript
50 lines
1.4 KiB
JavaScript
#!/usr/bin/env node
|
|
|
|
/**
|
|
* Test script to verify n8n MCP server connectivity
|
|
* Usage: node test-connection.js
|
|
*/
|
|
|
|
import { N8nClient } from './dist/n8n-client.js';
|
|
|
|
const N8N_BASE_URL = process.env.N8N_BASE_URL || 'http://srvdocker02:8098';
|
|
const N8N_API_KEY = process.env.N8N_API_KEY;
|
|
|
|
console.log('Testing n8n connection...');
|
|
console.log('n8n URL:', N8N_BASE_URL);
|
|
console.log('API Key:', N8N_API_KEY ? '***configured***' : 'not set');
|
|
console.log('');
|
|
|
|
const client = new N8nClient({
|
|
baseUrl: N8N_BASE_URL,
|
|
apiKey: N8N_API_KEY,
|
|
});
|
|
|
|
async function test() {
|
|
try {
|
|
console.log('Fetching workflows...');
|
|
const workflows = await client.listWorkflows();
|
|
console.log(`✓ Successfully connected to n8n!`);
|
|
console.log(`✓ Found ${workflows.length} workflow(s)`);
|
|
|
|
if (workflows.length > 0) {
|
|
console.log('\nFirst few workflows:');
|
|
workflows.slice(0, 5).forEach((wf) => {
|
|
console.log(` - ${wf.name} (ID: ${wf.id}, Active: ${wf.active})`);
|
|
});
|
|
}
|
|
|
|
process.exit(0);
|
|
} catch (error) {
|
|
console.error('✗ Connection failed:', error.message);
|
|
console.error('\nTroubleshooting:');
|
|
console.error('1. Verify n8n is running:');
|
|
console.error(` curl ${N8N_BASE_URL}/healthz`);
|
|
console.error('2. Check if the URL is correct in your configuration');
|
|
console.error('3. If authentication is required, set N8N_API_KEY environment variable');
|
|
process.exit(1);
|
|
}
|
|
}
|
|
|
|
test();
|