forked from kunwarVivek/mcp-github-project-manager
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebug-simple.js
More file actions
90 lines (74 loc) · 2.25 KB
/
Copy pathdebug-simple.js
File metadata and controls
90 lines (74 loc) · 2.25 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
const { spawn } = require('child_process');
const path = require('path');
// Simpler test with better error handling
async function testServerBasic() {
console.log('Testing basic MCP server communication...');
const serverPath = path.join(__dirname, 'build/index.js');
const serverProcess = spawn('node', [serverPath], {
env: {
...process.env,
GITHUB_TOKEN: 'test-token',
GITHUB_OWNER: 'test-owner',
GITHUB_REPO: 'test-repo'
},
stdio: ['pipe', 'pipe', 'pipe']
});
let hasResponded = false;
let responseData = '';
serverProcess.stdout.on('data', (data) => {
const chunk = data.toString();
responseData += chunk;
console.log('Got stdout:', JSON.stringify(chunk));
hasResponded = true;
});
serverProcess.stderr.on('data', (data) => {
console.log('Got stderr:', data.toString().substring(0, 200) + '...');
});
serverProcess.on('error', (error) => {
process.stderr.write('Process error:', error);
});
serverProcess.on('exit', (code, signal) => {
console.log('Process exited:', code, signal);
});
// Wait for server to be ready
console.log('Waiting for server startup...');
await new Promise(resolve => setTimeout(resolve, 5000));
// Send MCP request
console.log('Sending MCP request...');
const request = JSON.stringify({
jsonrpc: "2.0",
id: 1,
method: "initialize",
params: {
protocolVersion: "2024-11-05",
capabilities: {},
clientInfo: {
name: "test-client",
version: "1.0.0"
}
}
}) + '\n';
console.log('Request:', request);
serverProcess.stdin.write(request);
// Wait for response
console.log('Waiting for response...');
for (let i = 0; i < 20; i++) { // Wait up to 10 seconds
if (hasResponded) break;
await new Promise(resolve => setTimeout(resolve, 500));
console.log(`Waiting... ${i + 1}/20`);
}
console.log('Has responded:', hasResponded);
console.log('Response data:', responseData);
// Cleanup
serverProcess.kill();
return hasResponded;
}
testServerBasic()
.then(result => {
console.log('Test result:', result ? 'SUCCESS' : 'FAILED');
process.exit(result ? 0 : 1);
})
.catch(error => {
process.stderr.write('Test error:', error);
process.exit(1);
});