fix: pass req.body to handleRequest for proper MCP protocol handling
Some checks failed
CI/CD Pipeline / build (push) Has been cancelled
CI/CD Pipeline / publish-npm (push) Has been cancelled
CI/CD Pipeline / docker (push) Has been cancelled

The StreamableHTTPServerTransport.handleRequest() method requires the parsed
body as the third argument for POST requests. This was causing "Parse error:
Invalid JSON" responses for all MCP requests.
This commit is contained in:
Krishna Kumar
2025-12-31 13:43:31 -06:00
parent 3e0ed2d6c6
commit 15127c3cbd

View File

@@ -110,9 +110,9 @@ class OpenRouterMultimodalServer {
return; return;
} }
// Let the transport handle the SSE stream // Let the transport handle the SSE stream (no body for GET)
const transport = transports[sessionId]; const transport = transports[sessionId];
await transport.handleRequest(req, res); await transport.handleRequest(req, res, undefined);
return; return;
} }
@@ -174,9 +174,9 @@ class OpenRouterMultimodalServer {
transport = transports[sessionId]; transport = transports[sessionId];
} }
// Handle the request // Handle the request - pass body for POST, omit for GET/DELETE
try { try {
await transport.handleRequest(req, res); await transport.handleRequest(req, res, req.body);
} catch (error) { } catch (error) {
console.error('[MCP] Request handling error:', error); console.error('[MCP] Request handling error:', error);
if (!res.headersSent) { if (!res.headersSent) {