UNPKG

task-engine-ai-core

Version:

Revolutionary AI-driven task management system with complete transformation trilogy: Frontend v0.1.0, Backend v0.2.0, CLI v0.3.0 - Enterprise-grade performance with 95% improvements

192 lines (152 loc) โ€ข 6.53 kB
#!/usr/bin/env node /** * Test MCP from IDE Perspective * Simulates how an IDE would start the MCP servers */ import { spawn } from 'child_process'; import fs from 'fs/promises'; import path from 'path'; class MCPIDEPerspectiveTest { constructor() { this.projectRoot = process.cwd(); } /** * Test MCP servers from IDE perspective */ async testFromIDEPerspective() { console.log('๐Ÿ” Testing MCP from IDE Perspective...\n'); try { // Test Cursor configuration await this.testCursorMCP(); // Test VS Code configuration await this.testVSCodeMCP(); console.log('\nโœ… All MCP servers work from IDE perspective!'); } catch (error) { console.error('\nโŒ MCP IDE perspective test failed:', error.message); process.exit(1); } } /** * Test Cursor MCP configuration */ async testCursorMCP() { console.log('๐Ÿ“ฑ Testing Cursor MCP Configuration...'); const configPath = path.join(this.projectRoot, '.cursor/mcp.json'); try { const config = JSON.parse(await fs.readFile(configPath, 'utf8')); const servers = config.mcpServers; // Test taskmaster-ai server await this.testMCPServer('Cursor', 'taskmaster-ai', servers['taskmaster-ai']); // Test taskmaster-ide-bridge server await this.testMCPServer('Cursor', 'taskmaster-ide-bridge', servers['taskmaster-ide-bridge']); console.log(' โœ… Cursor MCP configuration works!\n'); } catch (error) { if (error.code === 'ENOENT') { console.log(' โš ๏ธ Cursor MCP config not found (skipping)\n'); } else { throw error; } } } /** * Test VS Code MCP configuration */ async testVSCodeMCP() { console.log('๐Ÿ’ป Testing VS Code MCP Configuration...'); const configPath = path.join(this.projectRoot, '.vscode/mcp.json'); try { const config = JSON.parse(await fs.readFile(configPath, 'utf8')); const servers = config.servers; // Test taskmaster-ai server await this.testMCPServer('VS Code', 'taskmaster-ai', servers['taskmaster-ai']); // Test taskmaster-ide-bridge server await this.testMCPServer('VS Code', 'taskmaster-ide-bridge', servers['taskmaster-ide-bridge']); console.log(' โœ… VS Code MCP configuration works!\n'); } catch (error) { if (error.code === 'ENOENT') { console.log(' โš ๏ธ VS Code MCP config not found (skipping)\n'); } else { throw error; } } } /** * Test individual MCP server */ async testMCPServer(ide, serverName, serverConfig) { console.log(` ๐Ÿงช Testing ${serverName} server...`); return new Promise((resolve, reject) => { const { command, args, env } = serverConfig; // Simulate IDE environment const ideEnv = { ...process.env, ...env, // Simulate IDE working directory (different from project root) PWD: '/home/augment-agent' }; console.log(` Command: ${command} ${args.join(' ')}`); console.log(` Working Directory: ${ideEnv.PWD}`); const server = spawn(command, args, { stdio: ['pipe', 'pipe', 'pipe'], env: ideEnv, cwd: ideEnv.PWD }); let output = ''; let errorOutput = ''; let serverStarted = false; // For MCP servers, we need to send a ping first to test if they're working setTimeout(() => { // Send initial ping to test MCP protocol server.stdin.write('{"method":"ping","jsonrpc":"2.0","id":1}\n'); }, 500); server.stdout.on('data', (data) => { output += data.toString(); // Check for successful startup indicators if (output.includes('MCP Bridge Server started') || output.includes('Task Master AI MCP Server') || output.includes('FastMCP server started') || output.includes('{"method":"ping"') || output.includes('{"jsonrpc":"2.0"')) { if (!serverStarted) { serverStarted = true; console.log(` โœ… ${serverName} started and responding to MCP protocol`); // Give it a moment, then kill setTimeout(() => { server.kill('SIGTERM'); }, 1000); } } }); server.stderr.on('data', (data) => { errorOutput += data.toString(); }); server.on('close', (code) => { if (serverStarted) { console.log(` โœ… ${serverName} stopped gracefully`); resolve(); } else { console.log(` โŒ ${serverName} failed to start`); console.log(` Output: ${output}`); console.log(` Errors: ${errorOutput}`); reject(new Error(`${ide} ${serverName} server failed to start (exit code: ${code})`)); } }); server.on('error', (error) => { reject(new Error(`Failed to start ${ide} ${serverName} server: ${error.message}`)); }); // Timeout after 10 seconds setTimeout(() => { if (!serverStarted) { server.kill('SIGKILL'); reject(new Error(`${ide} ${serverName} server startup timed out`)); } }, 10000); }); } } // Run test if called directly if (import.meta.url === `file://${process.argv[1]}`) { const tester = new MCPIDEPerspectiveTest(); tester.testFromIDEPerspective().catch(console.error); } export default MCPIDEPerspectiveTest;