-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-tool.js
More file actions
72 lines (61 loc) · 1.63 KB
/
test-tool.js
File metadata and controls
72 lines (61 loc) · 1.63 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
// Test calling domain_profile_list tool
import { spawn } from 'child_process';
const server = spawn('node', ['dist/index.js'], {
stdio: ['pipe', 'pipe', 'pipe']
});
let output = '';
let requestId = 0;
server.stdout.on('data', (data) => {
output += data.toString();
try {
const lines = output.split('\n').filter(l => l.trim());
for (const line of lines) {
const msg = JSON.parse(line);
// Response to tools/list
if (msg.id === 1 && msg.result) {
console.log('✅ Server initialized');
// Now call domain_profile_list
const toolRequest = JSON.stringify({
jsonrpc: '2.0',
id: 2,
method: 'tools/call',
params: {
name: 'domain_profile_list',
arguments: {}
}
});
server.stdin.write(toolRequest + '\n');
}
// Response to tool call
if (msg.id === 2 && msg.result) {
console.log('✅ Tool executed successfully');
console.log('Response:', JSON.stringify(msg.result, null, 2));
server.kill();
process.exit(0);
}
if (msg.error) {
console.error('❌ Error:', msg.error);
server.kill();
process.exit(1);
}
}
} catch (e) {
// Not complete JSON yet
}
});
server.stderr.on('data', (data) => {
console.error('Server stderr:', data.toString());
});
// Send initial tools/list
const listRequest = JSON.stringify({
jsonrpc: '2.0',
id: 1,
method: 'tools/list',
params: {}
});
server.stdin.write(listRequest + '\n');
setTimeout(() => {
console.error('❌ Timeout');
server.kill();
process.exit(1);
}, 5000);