fix: pass req.body to handleRequest for proper MCP protocol handling
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:
@@ -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) {
|
||||||
|
|||||||
Reference in New Issue
Block a user