-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-client.js
More file actions
76 lines (65 loc) · 1.67 KB
/
test-client.js
File metadata and controls
76 lines (65 loc) · 1.67 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
// Quick test client for Common MCP Gateway
const { spawn } = require('child_process');
const client = spawn('C:\\Users\\mikuc\\AppData\\Roaming\\npm\\common-mcp.cmd', [], {
stdio: ['pipe', 'pipe', 'pipe'],
shell: true
});
let buffer = '';
client.stdout.on('data', (data) => {
buffer += data.toString();
console.log('[STDOUT]', data.toString());
// Try to parse JSON-RPC messages
try {
const lines = buffer.split('\n');
for (const line of lines) {
if (line.trim() && line.includes('{')) {
const msg = JSON.parse(line);
console.log('[PARSED]', JSON.stringify(msg, null, 2));
}
}
} catch (e) {
// Not yet complete JSON
}
});
client.stderr.on('data', (data) => {
console.log('[STDERR]', data.toString());
});
client.on('exit', (code) => {
console.log('[EXIT]', code);
process.exit(code);
});
// Send initialize request
setTimeout(() => {
const initRequest = {
jsonrpc: '2.0',
id: 1,
method: 'initialize',
params: {
protocolVersion: '2024-11-05',
capabilities: {},
clientInfo: {
name: 'test-client',
version: '1.0.0'
}
}
};
console.log('[SEND]', JSON.stringify(initRequest));
client.stdin.write(JSON.stringify(initRequest) + '\n');
}, 1000);
// Send tools/list after 3s
setTimeout(() => {
const listRequest = {
jsonrpc: '2.0',
id: 2,
method: 'tools/list',
params: {}
};
console.log('[SEND]', JSON.stringify(listRequest));
client.stdin.write(JSON.stringify(listRequest) + '\n');
}, 3000);
// Exit after 30s to allow all 11 MCPs to load
setTimeout(() => {
console.log('[TIMEOUT] Test completed');
client.kill();
process.exit(0);
}, 30000);