-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest.js
More file actions
82 lines (69 loc) · 2 KB
/
test.js
File metadata and controls
82 lines (69 loc) · 2 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
#!/usr/bin/env node
import { spawn } from 'child_process';
console.log('Testing Nativelink MCP Server...\n');
// Start the server in stdio mode
const server = spawn('node', ['dist/index.js'], {
stdio: ['pipe', 'pipe', 'pipe']
});
// Send a tools/list request
const listRequest = JSON.stringify({
jsonrpc: '2.0',
method: 'tools/list',
id: 1
}) + '\n';
console.log('Sending tools/list request...');
server.stdin.write(listRequest);
// Collect output
let output = '';
server.stdout.on('data', (data) => {
output += data.toString();
// Try to parse each line as JSON
const lines = output.split('\n');
for (const line of lines) {
if (line.trim()) {
try {
const response = JSON.parse(line);
console.log('Response received:', JSON.stringify(response, null, 2));
// If we got a successful tools list, test calling a tool
if (response.result && response.result.tools) {
console.log('\nTesting get-bazel-config tool...');
const callRequest = JSON.stringify({
jsonrpc: '2.0',
method: 'tools/call',
params: {
name: 'get-bazel-config',
arguments: {
projectType: 'rust',
features: ['remote_cache', 'remote_execution']
}
},
id: 2
}) + '\n';
setTimeout(() => {
server.stdin.write(callRequest);
}, 100);
}
// If we got the tool response, exit
if (response.id === 2) {
console.log('\nTest completed successfully!');
server.kill();
process.exit(0);
}
} catch (e) {
// Not valid JSON yet, continue collecting
}
}
}
});
server.stderr.on('data', (data) => {
console.error('Error:', data.toString());
});
server.on('close', (code) => {
console.log(`Server exited with code ${code}`);
});
// Timeout after 5 seconds
setTimeout(() => {
console.log('Test timed out');
server.kill();
process.exit(1);
}, 5000);