Repository navigation
Conversation
express.json() consumes the request stream before the /mcp handler runs, so transport.handleRequest(req, res) found an empty body and rejected every POST, including valid initialize requests, with HTTP 400 / JSON-RPC -32700 "Parse error: Invalid JSON". Pass req.body as the parsedBody argument. Extract the Express app into an exported createHttpApp() so the transport can be exercised in tests, and add a regression test that initializes a session, sends a follow-up notification and deletes it. Add a multi-stage Dockerfile (non-root node user, /health healthcheck) and .dockerignore for the HTTP transport. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fix(http): pass parsed Express body to MCP transport
Summary
Fixes HTTP 400 responses from the Streamable HTTP MCP endpoint when clients send valid JSON-RPC initialization requests.
Root cause
Express JSON middleware parses the incoming request body before the MCP transport receives it.
The POST handler previously called:
Because the request stream had already been consumed, the transport attempted to parse it again, resulting in JSON-RPC error
-32700(Parse error: Invalid JSON).Fix
Pass the already-parsed body to the MCP transport:
The changes also introduce a testable HTTP application factory and a regression test for MCP initialization and session handling.
Validation
Additional changes
Includes a Dockerfile and
.dockerignoreto support reproducible container deployments.Known limitation
The lint command could not run because ESLint was absent from the existing development dependencies.
Testing environment
Node.js tests and Docker image validation were performed in resource-limited containers.