This repository was archived by the owner on Sep 23, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest-rust-server.js
More file actions
executable file
Β·140 lines (114 loc) Β· 3.75 KB
/
Copy pathtest-rust-server.js
File metadata and controls
executable file
Β·140 lines (114 loc) Β· 3.75 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
129
130
131
132
133
134
135
136
137
138
139
140
#!/usr/bin/env node
/**
* Simple test for Rust MCP server with VSCode extension
*
* Run this in a terminal where DIALECTIC_IPC_PATH is set by the IDE.
* It will start the MCP server and send a simple review to display.
*/
const { spawn } = require('child_process');
const path = require('path');
// Path to the Rust MCP server binary
const serverPath = path.join(__dirname, 'server-rs', 'target', 'release', 'dialectic-mcp-server');
console.log('π Testing Rust MCP Server...');
console.log('π IPC Path:', process.env.DIALECTIC_IPC_PATH || 'NOT SET');
console.log('');
// Simple review content
const reviewContent = `# π¦ Rust MCP Server Test
## Summary
Testing the Rust MCP server implementation! If you can see this review in VSCode, then our Rust server successfully:
- Connected to VSCode via IPC
- Processed the MCP tool call
- Sent the review data to the extension
## Code Tour
### Server Implementation [here](dialectic:server-rs/src/server.rs?regex=present_review)
The Rust server is now handling this request using the rmcp SDK with async/await.
### IPC Layer [check this](dialectic:server-rs/src/ipc.rs?regex=send_message_with_reply)
This review traveled through our custom IPC implementation with UUID correlation.
## π Success!
If you're reading this, the Rust migration worked perfectly!`;
// MCP messages - proper protocol flow
const initialize = {
jsonrpc: '2.0',
id: 1,
method: 'initialize',
params: {
protocolVersion: '2024-11-05',
capabilities: { tools: {} },
clientInfo: { name: 'rust-test', version: '1.0.0' }
}
};
const initialized = {
jsonrpc: '2.0',
method: 'notifications/initialized'
};
const presentReview = {
jsonrpc: '2.0',
id: 2,
method: 'tools/call',
params: {
name: 'present_review',
arguments: {
content: reviewContent,
mode: 'replace',
baseUri: '/Users/nikomat/dev/dialectic',
section: null
}
}
};
// Start the server
const server = spawn(serverPath, [], {
stdio: ['pipe', 'pipe', 'pipe'],
env: process.env // Use current environment (includes DIALECTIC_IPC_PATH)
});
let buffer = '';
let step = 0;
server.stdout.on('data', (data) => {
buffer += data.toString();
const lines = buffer.split('\n');
buffer = lines.pop() || '';
for (const line of lines) {
if (!line.trim()) continue;
try {
const msg = JSON.parse(line);
console.log('π¨ Response:', JSON.stringify(msg, null, 2));
if (msg.id === 1 && step === 0) {
console.log('\nβ
Initialize response received! Sending initialized notification...\n');
server.stdin.write(JSON.stringify(initialized) + '\n');
step = 1;
// Wait a moment then send the review
setTimeout(() => {
console.log('π€ Sending review...\n');
server.stdin.write(JSON.stringify(presentReview) + '\n');
step = 2;
}, 100);
} else if (msg.id === 2 && step === 2) {
console.log('\nπ Review sent!');
if (msg.result && !msg.result.isError) {
console.log('β
Success! Check VSCode review panel.');
} else {
console.log('β Error:', msg.error || msg.result);
}
server.kill();
}
} catch (e) {
console.log('π Output:', line);
}
}
});
server.stderr.on('data', (data) => {
console.log('π Log:', data.toString().trim());
});
server.on('close', (code) => {
console.log(`\nπ Done (exit ${code})`);
});
server.on('error', (err) => {
console.error('β Error:', err.message);
});
// Start the flow
console.log('π€ Starting server and sending initialize...\n');
server.stdin.write(JSON.stringify(initialize) + '\n');
// Safety timeout
setTimeout(() => {
console.log('\nβ° Timeout - killing server');
server.kill();
}, 15000);