Skip to main content
Glama
test-integration.jsโ€ข7.76 kB
#!/usr/bin/env node /** * Integration test to verify MCP server compatibility and tool availability */ const { spawn } = require('child_process'); class IntegrationTester { constructor() { this.serverProcess = null; } async startServer() { console.log('๐Ÿš€ Starting n8n MCP server for integration test...'); this.serverProcess = spawn('npx', ['.'], { cwd: '/Users/yasinboelhouwer/n8n-workflow-builder', env: { ...process.env, N8N_HOST: 'https://n8n.yasin.nu/api/v1', N8N_API_KEY: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIyMmE2NzM0NC05ZWI1LTQ0NmMtODczNi1lNWYyOGE4MjY4NTIiLCJpc3MiOiJuOG4iLCJhdWQiOiJwdWJsaWMtYXBpIiwiaWF0IjoxNzUzMzQzODU5fQ.PhpEIzzSGROy9Kok26SXmj9RRH1K3ArahexaVbQ2-Ho' }, stdio: ['pipe', 'pipe', 'pipe'] }); return new Promise((resolve, reject) => { let output = ''; this.serverProcess.stderr.on('data', (data) => { output += data.toString(); if (output.includes('N8N Workflow Builder MCP server running on stdio')) { console.log('โœ… Server started successfully'); resolve(); } }); this.serverProcess.on('error', (error) => { console.error('โŒ Failed to start server:', error); reject(error); }); setTimeout(() => { reject(new Error('Server startup timeout')); }, 10000); }); } async sendMCPRequest(method, params = {}) { return new Promise((resolve, reject) => { const request = { jsonrpc: '2.0', id: Date.now(), method: method, params: params }; let response = ''; let timeout; const onData = (data) => { response += data.toString(); try { const parsed = JSON.parse(response); clearTimeout(timeout); this.serverProcess.stdout.removeListener('data', onData); resolve(parsed); } catch (e) { // Continue collecting data } }; this.serverProcess.stdout.on('data', onData); timeout = setTimeout(() => { this.serverProcess.stdout.removeListener('data', onData); reject(new Error(`Timeout waiting for response to ${method}`)); }, 5000); this.serverProcess.stdin.write(JSON.stringify(request) + '\n'); }); } async testToolsAvailability() { console.log('๐Ÿ” Testing tools availability...'); try { const response = await this.sendMCPRequest('tools/list'); if (response.error) { console.log('โŒ Failed to list tools:', response.error.message); return false; } const tools = response.result.tools || []; const expectedTools = [ 'list_workflows', 'create_workflow', 'get_workflow', 'execute_workflow', 'update_workflow', 'activate_workflow', 'deactivate_workflow', 'delete_workflow', 'create_workflow_and_activate' ]; console.log(`๐Ÿ“‹ Found ${tools.length} tools:`); const availableToolNames = tools.map(tool => tool.name); const missingTools = expectedTools.filter(tool => !availableToolNames.includes(tool)); const extraTools = availableToolNames.filter(tool => !expectedTools.includes(tool)); expectedTools.forEach(toolName => { const isAvailable = availableToolNames.includes(toolName); console.log(` ${isAvailable ? 'โœ…' : 'โŒ'} ${toolName}`); }); if (extraTools.length > 0) { console.log('\n๐Ÿ“Ž Additional tools found:'); extraTools.forEach(tool => console.log(` โž• ${tool}`)); } if (missingTools.length === 0) { console.log('\n๐ŸŽ‰ All expected tools are available!'); return true; } else { console.log('\nโŒ Missing tools:', missingTools); return false; } } catch (error) { console.error('โŒ Error testing tools availability:', error.message); return false; } } async testMCPCompatibility() { console.log('\n๐Ÿ”ง Testing MCP protocol compatibility...'); try { // Test initialize const initResponse = await this.sendMCPRequest('initialize', { protocolVersion: '2024-11-05', capabilities: {}, clientInfo: { name: 'integration-test', version: '1.0.0' } }); if (initResponse.error) { console.log('โŒ MCP initialize failed:', initResponse.error.message); return false; } console.log('โœ… MCP initialize successful'); // Test ping (if supported) try { const pingResponse = await this.sendMCPRequest('ping'); if (!pingResponse.error) { console.log('โœ… MCP ping successful'); } } catch (e) { // Ping might not be supported, that's okay console.log('โ„น๏ธ MCP ping not supported (optional)'); } return true; } catch (error) { console.error('โŒ MCP compatibility test failed:', error.message); return false; } } async testBasicFunctionality() { try { // Test list_workflows const listResponse = await this.sendMCPRequest('tools/call', { name: 'list_workflows', arguments: {} }); if (listResponse.error) { console.log('โŒ Basic functionality test failed:', listResponse.error.message); return false; } console.log('โœ… Basic functionality test passed'); return true; } catch (error) { console.log('โŒ Basic functionality test error:', error.message); return false; } } async runIntegrationTests() { try { await this.startServer(); console.log('\n๐Ÿงช Running integration tests...\n'); // Test 1: Tools availability const toolsAvailable = await this.testToolsAvailability(); // Test 2: MCP compatibility const mcpCompatible = await this.testMCPCompatibility(); // Test 3: Quick functional test console.log('\nโšก Running quick functional test...'); const functionalTest = await this.testBasicFunctionality(); // Summary console.log('\n๐Ÿ“Š Integration Test Results:'); console.log('============================'); console.log(`Tools Availability: ${toolsAvailable ? 'โœ… PASS' : 'โŒ FAIL'}`); console.log(`MCP Compatibility: ${mcpCompatible ? 'โœ… PASS' : 'โŒ FAIL'}`); console.log(`Basic Functionality: ${functionalTest ? 'โœ… PASS' : 'โŒ FAIL'}`); const allPassed = toolsAvailable && mcpCompatible && functionalTest; if (allPassed) { console.log('\n๐ŸŽ‰ All integration tests passed!'); console.log('โœ… Enhanced MCP server is fully compatible and functional'); return true; } else { console.log('\nโŒ Some integration tests failed'); return false; } } catch (error) { console.error('โŒ Integration test execution failed:', error); return false; } finally { this.cleanup(); } } cleanup() { if (this.serverProcess) { console.log('\n๐Ÿงน Cleaning up server process...'); this.serverProcess.kill(); } } } // Run integration tests const tester = new IntegrationTester(); tester.runIntegrationTests().then(success => { if (success) { console.log('\n๐Ÿš€ Enhanced n8n-workflow-builder MCP server is ready for production!'); process.exit(0); } else { console.log('\nโš ๏ธ Integration tests failed. Please review the issues above.'); process.exit(1); } }).catch(console.error);

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/danilonovaisv/n8n-workflow-builder-GPT'

If you have feedback or need assistance with the MCP directory API, please join our Discord server