-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-full.js
More file actions
128 lines (112 loc) · 3.39 KB
/
Copy pathtest-full.js
File metadata and controls
128 lines (112 loc) · 3.39 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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#!/usr/bin/env node
// Full test of MCP server functionality
import { spawn } from 'child_process';
import readline from 'readline';
const mcp = spawn('node', ['dist/index.js'], {
stdio: ['pipe', 'pipe', 'pipe']
});
let messageId = 1;
mcp.stderr.on('data', (data) => {
const msg = data.toString();
if (!msg.includes('MCP server running')) {
console.error('Server:', msg);
}
});
function sendRequest(method, params) {
const request = JSON.stringify({
jsonrpc: '2.0',
method,
params,
id: messageId++
}) + '\n';
mcp.stdin.write(request);
}
const rl = readline.createInterface({
input: mcp.stdout
});
let testStep = 'init';
// Start the test
console.log('1. Initializing MCP server...');
sendRequest('initialize', {
protocolVersion: '2024-11-05',
clientInfo: { name: 'test-client', version: '1.0.0' },
capabilities: {}
});
rl.on('line', (line) => {
console.log('Response:', line.substring(0, 100));
try {
const response = JSON.parse(line);
if (response.error) {
if (!response.error.message.includes('Required')) {
console.error('Error:', response.error);
}
}
switch (testStep) {
case 'init':
console.log('2. Indexing conversations...');
sendRequest('tools/call', {
name: 'index_conversations',
arguments: { path: `${process.env.HOME}/.claude/projects` }
});
testStep = 'index';
break;
case 'index':
if (response.result?.content?.[0]?.text) {
console.log(' Result:', response.result.content[0].text.split('\n')[0]);
}
console.log('3. Listing projects...');
sendRequest('tools/call', {
name: 'list_projects',
arguments: {}
});
testStep = 'list';
break;
case 'list':
if (response.result?.content?.[0]?.text) {
console.log(' Projects found!');
}
console.log('4. Searching for "gpu"...');
sendRequest('tools/call', {
name: 'search_history',
arguments: { query: 'gpu', limit: 3 }
});
testStep = 'search1';
break;
case 'search1':
if (response.result?.content?.[0]?.text) {
const text = response.result.content[0].text;
const matches = text.match(/Found (\d+) results/);
if (matches) {
console.log(' Found', matches[1], 'results for "gpu"');
}
}
console.log('5. Searching for "multi-gpu" (hyphenated)...');
sendRequest('tools/call', {
name: 'search_history',
arguments: { query: 'multi-gpu', limit: 3 }
});
testStep = 'search2';
break;
case 'search2':
if (response.result?.content?.[0]?.text) {
const text = response.result.content[0].text;
const matches = text.match(/Found (\d+) results/);
if (matches) {
console.log(' Found', matches[1], 'results for "multi-gpu"');
} else if (text.includes('No results')) {
console.log(' No results (but no SQL error!)');
}
}
console.log('\n✅ All tests completed successfully!');
console.log('The MCP server is working correctly.');
process.exit(0);
break;
}
} catch (e) {
// Ignore parse errors
}
});
setTimeout(() => {
console.error('\n❌ Timeout - tests did not complete');
process.exit(1);
}, 30000);