#!/usr/bin/env node
import { spawn } from 'child_process';
class SimpleMCPTest {
constructor() {
this.requestId = 1;
}
async testMCPServer() {
console.log('π Testing MCP Server Communication...');
// Start the MCP server process
const mcpProcess = spawn('node', ['build/index.js'], {
stdio: ['pipe', 'pipe', 'pipe'],
cwd: process.cwd()
});
mcpProcess.stderr.on('data', (data) => {
console.log('π Server:', data.toString().trim());
});
// Wait for server to start
await new Promise(resolve => setTimeout(resolve, 2000));
// Test basic communication
const request = {
jsonrpc: '2.0',
id: this.requestId++,
method: 'tools/list',
params: {}
};
console.log('π€ Sending tools/list request...');
mcpProcess.stdin.write(JSON.stringify(request) + '\n');
// Listen for response
let responseReceived = false;
mcpProcess.stdout.on('data', (data) => {
const responseText = data.toString();
console.log('π₯ Raw response:', responseText);
try {
const response = JSON.parse(responseText);
if (response.result && response.result.tools) {
console.log(`β
Found ${response.result.tools.length} tools:`);
response.result.tools.forEach(tool => {
console.log(` - ${tool.name}: ${tool.description}`);
});
responseReceived = true;
}
} catch (e) {
console.log('β οΈ Could not parse response as JSON');
}
});
// Wait for response
await new Promise(resolve => setTimeout(resolve, 3000));
if (!responseReceived) {
console.log('β No valid response received');
}
// Clean up
mcpProcess.kill();
console.log('π Test completed');
}
}
// Run the test
const test = new SimpleMCPTest();
test.testMCPServer().catch(console.error);