From 15127c3cbdef499e32c9f192e2614f353bf5ac56 Mon Sep 17 00:00:00 2001 From: Krishna Kumar Date: Wed, 31 Dec 2025 13:43:31 -0600 Subject: [PATCH] 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. --- src/index.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/index.ts b/src/index.ts index c04c1ad..699f1bc 100644 --- a/src/index.ts +++ b/src/index.ts @@ -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) {