Title: Invalid JSON-RPC envelope errors are not correlated with the original request id · Issue #2848 · modelcontextprotocol/python-sdk · GitHub
Open Graph Title: Invalid JSON-RPC envelope errors are not correlated with the original request id · Issue #2848 · modelcontextprotocol/python-sdk
X Title: Invalid JSON-RPC envelope errors are not correlated with the original request id · Issue #2848 · modelcontextprotocol/python-sdk
Description: Initial Checks I confirm that I'm using the latest version of MCP Python SDK I confirm that I searched for my issue in https://github.com/modelcontextprotocol/python-sdk/issues before opening this issue Description After a normal initial...
Open Graph Description: Initial Checks I confirm that I'm using the latest version of MCP Python SDK I confirm that I searched for my issue in https://github.com/modelcontextprotocol/python-sdk/issues before opening this ...
X Description: Initial Checks I confirm that I'm using the latest version of MCP Python SDK I confirm that I searched for my issue in https://github.com/modelcontextprotocol/python-sdk/issues before opening t...
Opengraph URL: https://github.com/modelcontextprotocol/python-sdk/issues/2848
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Invalid JSON-RPC envelope errors are not correlated with the original request id","articleBody":"### Initial Checks\n\n- [x] I confirm that I'm using the latest version of MCP Python SDK\n- [x] I confirm that I searched for my issue in https://github.com/modelcontextprotocol/python-sdk/issues before opening this issue\n\n### Description\n\nAfter a normal initialization flow, several id-bearing JSON-RPC messages that are syntactically valid JSON but invalid JSON-RPC request envelopes are not correlated back to the original request id.\n\nThis is not meant to require implementations to recover an id after every low-level parse/deserialization failure. The narrower concern is that these payloads are parsed far enough to produce request-specific validation errors, while the original top-level id is still present in the payload. Preserving that id where feasible would make the error response easier for clients to correlate.\n\n\nThe tested inputs were:\n\n| Case | Request | Validation detail |\n| ----------------------- | ------------------------------------------------------ | ------------------------------------------------------- |\n| wrong `jsonrpc` version | `{\"jsonrpc\":\"1.0\",\"id\":3,\"method\":\"ping\",\"params\":{}}` | `JSONRPCRequest.jsonrpc`: value should be `\"2.0\"` |\n| missing `jsonrpc` field | `{\"id\":4,\"method\":\"ping\",\"params\":{}}` | `JSONRPCRequest.jsonrpc`: field required |\n| `method` as number | `{\"jsonrpc\":\"2.0\",\"id\":8,\"method\":12345,\"params\":{}}` | `JSONRPCRequest.method`: input should be a valid string |\n\nFor all three envelope-invalid inputs, I would expect `-32600 Invalid Request` or `-32602` error response that can be correlated to the original request where possible.\n\nObserved behavior was consistent by transport:\n\n- **stdio:** The server emits a `notifications/message` log notification with `level:\"error\"` and `data:\"Internal Server Error\"`, but no JSON-RPC error response is sent for the original request `id`. A follow-up `ping` succeeds.\n- **Streamable HTTP:** The server returns HTTP 400 with a JSON-RPC error response using `id:\"server-error\"` and `code:-32602`, rather than the original request `id`. A follow-up `ping` succeeds over SSE.\n\n### Example Code\n\n```Python\n\"\"\"\nWith a Python SDK MCP server running over stdio or Streamable HTTP,\ncomplete a normal initialization flow, then send these requests in isolation.\n\"\"\"\n\nrequests = [\n # Wrong JSON-RPC version: valid JSON, invalid JSON-RPC envelope.\n {\"jsonrpc\": \"1.0\", \"id\": 3, \"method\": \"ping\", \"params\": {}},\n\n # Missing jsonrpc field: valid JSON, invalid JSON-RPC envelope.\n {\"id\": 4, \"method\": \"ping\", \"params\": {}},\n\n # method is not a string: valid JSON, invalid JSON-RPC envelope.\n {\"jsonrpc\": \"2.0\", \"id\": 8, \"method\": 12345, \"params\": {}},\n]\n```\n\n### Python \u0026 MCP Python SDK\n\n```Text\n* Python: `3.12.3`\n* MCP Python SDK stable release: `v1.27.2` (`62137874ff26dd74d2fea80ff528a7fd9ca7a5e7`)\n* Transports: stdio and Streamable HTTP\n```","author":{"url":"https://github.com/cclabadmin","@type":"Person","name":"cclabadmin"},"datePublished":"2026-06-12T11:49:58.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/2848/python-sdk/issues/2848"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:c52fa6c4-4c89-156e-dbc8-92a275da46fe |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E68A:2681A6:11A3B2:1739A5:6A5AC5E4 |
| html-safe-nonce | b1845ba98a443ee5b02b75d5d12137177bd63173037343a73ee85249bbd32725 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFNjhBOjI2ODFBNjoxMUEzQjI6MTczOUE1OjZBNUFDNUU0IiwidmlzaXRvcl9pZCI6IjY3MDA2MTY3Njk5MDczNzc2MzYiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 7cbb5fcc9e961832a5924eaae2509631283fffc3b0517d26eaf3774554e129a9 |
| hovercard-subject-tag | issue:4648962698 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/modelcontextprotocol/python-sdk/2848/issue_layout |
| twitter:image | https://opengraph.githubassets.com/692205404a1c1313a12434d39c353041232da8c6c4ce8d81c638f3fe97009590/modelcontextprotocol/python-sdk/issues/2848 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/692205404a1c1313a12434d39c353041232da8c6c4ce8d81c638f3fe97009590/modelcontextprotocol/python-sdk/issues/2848 |
| og:image:alt | Initial Checks I confirm that I'm using the latest version of MCP Python SDK I confirm that I searched for my issue in https://github.com/modelcontextprotocol/python-sdk/issues before opening this ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | cclabadmin |
| hostname | github.com |
| expected-hostname | github.com |
| None | f422022de939199d6afcbaac024b42b6232a3498a95f198e17717afb8b46fb15 |
| turbo-cache-control | no-preview |
| go-import | github.com/modelcontextprotocol/python-sdk git https://github.com/modelcontextprotocol/python-sdk.git |
| octolytics-dimension-user_id | 182288589 |
| octolytics-dimension-user_login | modelcontextprotocol |
| octolytics-dimension-repository_id | 862584018 |
| octolytics-dimension-repository_nwo | modelcontextprotocol/python-sdk |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 862584018 |
| octolytics-dimension-repository_network_root_nwo | modelcontextprotocol/python-sdk |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 2fa01ceb3b3a801409f050561abfb062094702d0 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width