| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Per JSON-RPC 2.0, a message that is valid JSON but not a valid request object must be answered with an Invalid Request (-32600) error that echoes the original request id when it is detectable, so clients can correlate the failure. Previously: - Streamable HTTP replied 400 with id null and code -32602 (Invalid params), breaking client-side request/response correlation. - stdio sent no response at all; the validation exception was forwarded into the read stream and silently dropped by the dispatcher. Both transports now extract the id from the raw payload (via the new mcp.types.jsonrpc.extract_request_id helper) and reply with a correlated -32600 error. On stdio, lines without a detectable id (parse errors, malformed notifications, ids of an invalid type) keep the previous behavior of forwarding the exception without a response. Fixes modelcontextprotocol#2848 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…/correlate-invalid-envelope-request-id # Conflicts: # docs/migration.md # tests/interaction/transports/test_hosting_http.py # tests/shared/test_streamable_http.py
|
You've opened a duplicated pull request, please search opened PRs before creating new ones. Duplicated from #2852. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Summary
Fixes #2848.
A JSON-RPC message that is valid JSON but not a valid request object (wrong jsonrpc version, missing jsonrpc, non-string method, etc.) was not answered with an error that a client could correlate back to its request. Per JSON-RPC 2.0, the server should reply with an Invalid Request (-32600) error that echoes the original request id when it is detectable (and null otherwise).
Previously the behavior was inconsistent and uncorrelatable:
Changes
Testing
Migration / breaking change
The error code returned for an invalid JSON-RPC envelope over both transports changes from -32602 (Invalid params) to -32600 (Invalid Request), and the response id is now populated when detectable. This is a behavioral change to error responses; documented here for reviewers since it may affect clients that string-matched on the prior code.
🤖 Generated with Claude Code