-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-server.js
More file actions
executable file
·72 lines (60 loc) · 1.56 KB
/
test-server.js
File metadata and controls
executable file
·72 lines (60 loc) · 1.56 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
#!/usr/bin/env node
// Simple test script to verify the MCP server
import { spawn } from 'child_process';
import readline from 'readline';
console.log('Starting GitHub Projects MCP Server test...\n');
// Start the server
const server = spawn('node', ['dist/index.js'], {
stdio: ['pipe', 'pipe', 'pipe'],
env: { ...process.env }
});
// Create readline interface for sending commands
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
// Handle server output
server.stdout.on('data', (data) => {
console.log('Server:', data.toString());
});
server.stderr.on('data', (data) => {
console.log('Server Error:', data.toString());
});
// Send initialize request
const initializeRequest = {
jsonrpc: '2.0',
method: 'initialize',
params: {
protocolVersion: '0.1.0',
capabilities: {},
clientInfo: {
name: 'test-client',
version: '1.0.0'
}
},
id: 1
};
console.log('Sending initialize request...');
server.stdin.write(JSON.stringify(initializeRequest) + '\n');
// Send list tools request after a delay
setTimeout(() => {
const listToolsRequest = {
jsonrpc: '2.0',
method: 'tools/list',
params: {},
id: 2
};
console.log('\nSending list tools request...');
server.stdin.write(JSON.stringify(listToolsRequest) + '\n');
}, 1000);
// Exit after 3 seconds
setTimeout(() => {
console.log('\nTest complete. Shutting down...');
server.kill();
process.exit(0);
}, 3000);
// Handle errors
server.on('error', (err) => {
console.error('Failed to start server:', err);
process.exit(1);
});