fix(server): improve JSON-RPC HTTP compatibility for strict clients#12
Merged
Merged
Conversation
Handle JSON-RPC notifications (requests without an id) by responding with 202 and an empty body instead of a spurious response object, preserve the request id in error responses (including id 0), and add a GET /mcp endpoint so clients that probe transport capabilities before POSTing (e.g. JetBrains Rider) get a 200 with service metadata.
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.
Summary
Fixes JSON-RPC over HTTP compatibility issues that prevented strict MCP clients (e.g. JetBrains Rider) from working with the server.
Closes #11
Changes
idare JSON-RPC notifications and must not receive a response body. The server now replies with202 Acceptedand an empty body instead of a spurious response/error object.idpreservation — error responses now always echo the requestid(including0), consistent with success responses.GET /mcp— added so clients that probe transport capabilities before issuing a POST get a200with service metadata rather than a 404.The POST handler was also refactored into a single
switchthat computes the result once and then chooses between a202ack (notifications) and a JSON-RPC response (requests), removing the duplicated response-shape logic.Testing
src/server/mcpServer.test.tscoveringGET /mcp,GET /health, id echoing oninitialize/tools/list/tools/call, id preservation on error paths, and202/empty-body behavior for notifications.npm run build✅npm run test✅ (212 tests pass)