forked from TCMPP-Team/tcsas-devtools-mcp-server
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-server.js
More file actions
64 lines (55 loc) · 1.3 KB
/
test-server.js
File metadata and controls
64 lines (55 loc) · 1.3 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
const http = require('http');
// Test MCP server
const testData = {
jsonrpc: '2.0',
method: 'initialize',
params: {
protocolVersion: '2024-11-05',
capabilities: {
tools: {}
},
clientInfo: {
name: 'test-client',
version: '1.0.0'
}
},
id: 1
};
const postData = JSON.stringify(testData);
const options = {
hostname: 'localhost',
port: 3000,
path: '/mcp',
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Content-Length': Buffer.byteLength(postData)
}
};
console.log('Testing MCP server initialization...');
const req = http.request(options, (res) => {
console.log(`Status: ${res.statusCode}`);
console.log(`Headers: ${JSON.stringify(res.headers)}`);
let data = '';
res.on('data', (chunk) => {
data += chunk;
});
res.on('end', () => {
console.log('Response:', data);
try {
const response = JSON.parse(data);
if (response.result) {
console.log('✅ MCP Server initialized successfully!');
} else {
console.log('❌ MCP Server initialization failed:', response.error);
}
} catch (e) {
console.log('❌ Invalid JSON response:', e.message);
}
});
});
req.on('error', (e) => {
console.error(`❌ Request error: ${e.message}`);
});
req.write(postData);
req.end();