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;
|
||||
}
|
||||
|
||||
// Let the transport handle the SSE stream
|
||||
// Let the transport handle the SSE stream (no body for GET)
|
||||
const transport = transports[sessionId];
|
||||
await transport.handleRequest(req, res);
|
||||
await transport.handleRequest(req, res, undefined);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -174,9 +174,9 @@ class OpenRouterMultimodalServer {
|
||||
transport = transports[sessionId];
|
||||
}
|
||||
|
||||
// Handle the request
|
||||
// Handle the request - pass body for POST, omit for GET/DELETE
|
||||
try {
|
||||
await transport.handleRequest(req, res);
|
||||
await transport.handleRequest(req, res, req.body);
|
||||
} catch (error) {
|
||||
console.error('[MCP] Request handling error:', error);
|
||||
if (!res.headersSent) {
|
||||
|
||||
Reference in New Issue
Block a user