-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathtest-gemini.js
More file actions
93 lines (79 loc) · 2.3 KB
/
test-gemini.js
File metadata and controls
93 lines (79 loc) · 2.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
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
#!/usr/bin/env node
import { spawn } from 'child_process';
import { readFileSync } from 'fs';
import { fileURLToPath } from 'url';
import { dirname, join } from 'path';
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
console.log('Testing Deep Code Reasoning MCP Server with Gemini...\n');
// Start the server
const server = spawn('node', ['dist/index.js'], {
stdio: ['pipe', 'pipe', 'pipe'],
cwd: __dirname
});
// Wait for server to start
await new Promise(resolve => setTimeout(resolve, 1000));
// Test 1: List tools
console.log('Test 1: Listing available tools...');
const listToolsRequest = {
jsonrpc: '2.0',
id: 1,
method: 'tools/list',
params: {}
};
server.stdin.write(JSON.stringify(listToolsRequest) + '\n');
// Test 2: Performance analysis
setTimeout(() => {
console.log('\nTest 2: Testing performance bottleneck analysis...');
// Create path to example file
const exampleFile = join(__dirname, 'examples', 'performance-issue.ts');
const performanceRequest = {
jsonrpc: '2.0',
id: 2,
method: 'tools/call',
params: {
name: 'performance_bottleneck',
arguments: {
code_path: {
entry_point: {
file: exampleFile,
line: 15,
function_name: 'getOrdersWithDetails'
},
suspected_issues: ['N+1 queries', 'memory leak']
},
profile_depth: 3
}
}
};
server.stdin.write(JSON.stringify(performanceRequest) + '\n');
}, 2000);
// Handle responses
let responseBuffer = '';
server.stdout.on('data', (data) => {
responseBuffer += data.toString();
// Try to parse complete JSON responses
const lines = responseBuffer.split('\n');
for (let i = 0; i < lines.length - 1; i++) {
const line = lines[i].trim();
if (line) {
try {
const response = JSON.parse(line);
console.log('\nResponse received:');
console.log(JSON.stringify(response, null, 2));
} catch (e) {
// Not complete JSON yet
}
}
}
responseBuffer = lines[lines.length - 1];
});
server.stderr.on('data', (data) => {
console.error('Server log:', data.toString());
});
// Clean exit after 10 seconds
setTimeout(() => {
console.log('\nTest completed. Shutting down server...');
server.kill();
process.exit(0);
}, 10000);