debug-mcp-communication.mjsā¢2.29 kB
#!/usr/bin/env node
import { spawn } from 'child_process';
console.log('š === DEBUG MCP SERVER COMMUNICATION ===\n');
const testPayload = {
jsonrpc: "2.0",
id: 1,
method: "tools/call",
params: {
name: "visum_health_check",
arguments: {}
}
};
console.log('š Test payload:', JSON.stringify(testPayload, null, 2));
console.log('ā³ Starting server and monitoring all output...\n');
const serverProcess = spawn('node', ['build/index.js'], {
stdio: ['pipe', 'pipe', 'pipe']
});
let stdoutData = '';
let stderrData = '';
serverProcess.stdout.on('data', (data) => {
const chunk = data.toString();
stdoutData += chunk;
console.log('š¤ STDOUT:', chunk.trim());
});
serverProcess.stderr.on('data', (data) => {
const chunk = data.toString();
stderrData += chunk;
console.log('š¢ STDERR:', chunk.trim());
});
serverProcess.on('error', (error) => {
console.log('ā Process error:', error.message);
});
// Wait for server to start, then send request
setTimeout(() => {
console.log('\nšØ Sending request...');
const payload = JSON.stringify(testPayload) + '\n';
console.log('šØ Payload length:', payload.length);
serverProcess.stdin.write(payload);
// Wait for response
setTimeout(() => {
console.log('\nš === FINAL RESULTS ===');
console.log('š¤ Total STDOUT length:', stdoutData.length);
console.log('š¢ Total STDERR length:', stderrData.length);
if (stdoutData.trim()) {
console.log('š¤ STDOUT content:', stdoutData);
// Try to parse JSON response
try {
const lines = stdoutData.split('\n').filter(line => line.trim());
for (const line of lines) {
try {
const parsed = JSON.parse(line);
if (parsed.jsonrpc) {
console.log('ā
Found JSON-RPC response:', JSON.stringify(parsed, null, 2));
break;
}
} catch (e) {
// Not JSON, continue
}
}
} catch (error) {
console.log('ā No valid JSON-RPC found in STDOUT');
}
} else {
console.log('ā No STDOUT received');
}
serverProcess.kill();
}, 5000);
}, 2000);
serverProcess.on('exit', (code) => {
console.log('\nš Process exited with code:', code);
});