-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathdebug-tools-response.js
More file actions
100 lines (81 loc) · 3.05 KB
/
debug-tools-response.js
File metadata and controls
100 lines (81 loc) · 3.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#!/usr/bin/env node
/**
* Debug the tools list response to see what's happening
*/
import { spawn } from 'child_process';
async function debugToolsResponse() {
console.log('🔍 Debugging Tools List Response\n');
return new Promise((resolve) => {
const serverProcess = spawn('node', ['./dist/index.js', '--api-key=QGUYbd7rkBqswN0otgk8KvzCVRZ+h7Tiz0onFETzF6M='], {
stdio: ['pipe', 'pipe', 'pipe']
});
let output = '';
serverProcess.stdout.on('data', (data) => {
const text = data.toString();
output += text;
console.log('📤 Raw output:', text);
});
serverProcess.stderr.on('data', (data) => {
const text = data.toString();
if (text.includes('HeyReach MCP Server started successfully')) {
console.log('✅ Server started\n');
// Initialize
const initMessage = JSON.stringify({
jsonrpc: '2.0',
id: 1,
method: 'initialize',
params: {
protocolVersion: '2024-11-05',
capabilities: { tools: {} },
clientInfo: { name: 'debug-client', version: '1.0.0' }
}
}) + '\n';
console.log('📤 Sending init:', initMessage.trim());
serverProcess.stdin.write(initMessage);
setTimeout(() => {
// List tools
const listToolsMessage = JSON.stringify({
jsonrpc: '2.0',
id: 2,
method: 'tools/list',
params: {}
}) + '\n';
console.log('📤 Sending tools/list:', listToolsMessage.trim());
serverProcess.stdin.write(listToolsMessage);
setTimeout(() => {
console.log('\n📋 Analyzing complete output...');
// Split by lines and analyze each JSON response
const lines = output.split('\n');
let toolsFound = 0;
lines.forEach((line, index) => {
if (line.trim().startsWith('{')) {
try {
const parsed = JSON.parse(line.trim());
console.log(`\nLine ${index + 1}:`, JSON.stringify(parsed, null, 2));
if (parsed.result && parsed.result.tools) {
toolsFound = parsed.result.tools.length;
console.log(`\n🎯 Found tools array with ${toolsFound} tools:`);
parsed.result.tools.forEach((tool, i) => {
console.log(`${i + 1}. ${tool.name}`);
});
}
} catch (e) {
console.log(`Line ${index + 1} (not JSON):`, line.trim());
}
}
});
console.log(`\n📊 Total tools found: ${toolsFound}`);
serverProcess.kill('SIGTERM');
resolve();
}, 3000);
}, 2000);
}
});
setTimeout(() => {
console.log('⏰ Timeout');
serverProcess.kill('SIGTERM');
resolve();
}, 15000);
});
}
debugToolsResponse().catch(console.error);