cheatengine 5.8.15 → 5.8.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ce_mcp_server.js +34 -28
- package/package.json +1 -1
package/ce_mcp_server.js
CHANGED
|
@@ -300,41 +300,47 @@ class CEMCPServer {
|
|
|
300
300
|
log.info('Cheat Engine MCP Bridge Started. Waiting for input...');
|
|
301
301
|
log.info(`Node.js version: ${process.version}`);
|
|
302
302
|
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
const response = this.handleRequest(request);
|
|
303
|
+
// Use raw stdin/stdout for MCP protocol - no readline to avoid buffering issues
|
|
304
|
+
process.stdin.setEncoding('utf8');
|
|
305
|
+
|
|
306
|
+
let buffer = '';
|
|
307
|
+
|
|
308
|
+
process.stdin.on('data', async (chunk) => {
|
|
309
|
+
buffer += chunk;
|
|
310
|
+
|
|
311
|
+
// Process complete lines
|
|
312
|
+
let lines = buffer.split('\n');
|
|
313
|
+
buffer = lines.pop(); // Keep incomplete line in buffer
|
|
314
|
+
|
|
315
|
+
for (const line of lines) {
|
|
316
|
+
if (!line.trim()) continue;
|
|
318
317
|
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
318
|
+
this.requestCount++;
|
|
319
|
+
|
|
320
|
+
try {
|
|
321
|
+
const request = JSON.parse(line);
|
|
322
|
+
const response = this.handleRequest(request);
|
|
323
|
+
|
|
324
|
+
if (response) {
|
|
325
|
+
// Handle async tool calls
|
|
326
|
+
if (response instanceof Promise) {
|
|
327
|
+
const result = await response;
|
|
328
|
+
process.stdout.write(JSON.stringify(result) + '\n');
|
|
329
|
+
} else {
|
|
330
|
+
process.stdout.write(JSON.stringify(response) + '\n');
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
} catch (err) {
|
|
334
|
+
if (err instanceof SyntaxError) {
|
|
335
|
+
log.error(`Failed to decode JSON: ${err.message}`);
|
|
324
336
|
} else {
|
|
325
|
-
|
|
337
|
+
log.error(`Critical Error (request #${this.requestCount}): ${err.stack}`);
|
|
326
338
|
}
|
|
327
339
|
}
|
|
328
|
-
} catch (err) {
|
|
329
|
-
if (err instanceof SyntaxError) {
|
|
330
|
-
log.error(`Failed to decode JSON: ${err.message}`);
|
|
331
|
-
} else {
|
|
332
|
-
log.error(`Critical Error (request #${this.requestCount}): ${err.stack}`);
|
|
333
|
-
}
|
|
334
340
|
}
|
|
335
341
|
});
|
|
336
342
|
|
|
337
|
-
|
|
343
|
+
process.stdin.on('end', () => {
|
|
338
344
|
log.info('Received end of input');
|
|
339
345
|
this.pipeClient.stop();
|
|
340
346
|
log.info(`Server Stopped (processed ${this.requestCount} requests)`);
|