-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathtest_mcp.js
More file actions
41 lines (33 loc) · 932 Bytes
/
test_mcp.js
File metadata and controls
41 lines (33 loc) · 932 Bytes
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
const WebSocket = require('ws');
const ws = new WebSocket('ws://127.0.0.1:8000/mcp', {
headers: {
'Authorization': `Bearer ${process.env.BEARER_TOKEN}` // Replace with your actual token
}
});
ws.on('open', function open() {
console.log('Connected to MCP server');
// Send tools/list request
const request = {
jsonrpc: '2.0',
id: 1,
method: 'tools/list',
params: {}
};
console.log('Sending request:', JSON.stringify(request));
ws.send(JSON.stringify(request));
// Close after 5 seconds
setTimeout(() => {
ws.close();
process.exit(0);
}, 5000);
});
ws.on('message', function message(data) {
console.log('Received:', data.toString());
});
ws.on('error', function error(err) {
console.error('Error:', err);
process.exit(1);
});
ws.on('close', function close() {
console.log('Connection closed');
});