Title: Streamable HTTP server silently drops in-flight request when client reuses a JSON-RPC id · Issue #2655 · modelcontextprotocol/python-sdk · GitHub
Open Graph Title: Streamable HTTP server silently drops in-flight request when client reuses a JSON-RPC id · Issue #2655 · modelcontextprotocol/python-sdk
X Title: Streamable HTTP server silently drops in-flight request when client reuses a JSON-RPC id · Issue #2655 · modelcontextprotocol/python-sdk
Description: Summary When a client sends two JSON-RPC requests with the same id on the same Streamable HTTP session before the first response is delivered, StreamableHTTPServerTransport overwrites the per-id response stream slot without warning. The ...
Open Graph Description: Summary When a client sends two JSON-RPC requests with the same id on the same Streamable HTTP session before the first response is delivered, StreamableHTTPServerTransport overwrites the per-id re...
X Description: Summary When a client sends two JSON-RPC requests with the same id on the same Streamable HTTP session before the first response is delivered, StreamableHTTPServerTransport overwrites the per-id re...
Opengraph URL: https://github.com/modelcontextprotocol/python-sdk/issues/2655
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Streamable HTTP server silently drops in-flight request when client reuses a JSON-RPC id","articleBody":"## Summary\n\nWhen a client sends two JSON-RPC requests with the same `id` on the same Streamable HTTP session before the first response is delivered, `StreamableHTTPServerTransport` overwrites the per-id response stream slot without warning. The first request's caller hangs until its read times out, and the second response is delivered to whichever caller wins the race. The server logs nothing.\n\nThe MCP base protocol requires that \"the request ID MUST NOT have been previously used by the requestor within the same session,\" so a duplicate id is a protocol violation by the client. But the server has no way to tell the client (or an operator) that the violation happened, which makes this very hard to diagnose downstream.\n\n## Where it happens\n\nIn [`src/mcp/server/streamable_http.py` lines 534-536 at v1.27.1](https://github.com/modelcontextprotocol/python-sdk/blob/v1.27.1/src/mcp/server/streamable_http.py#L534-L536):\n\n```python\nrequest_id = str(message.root.id)\nself._request_streams[request_id] = anyio.create_memory_object_stream[EventMessage](0)\nrequest_stream_reader = self._request_streams[request_id][1]\n```\n\nThe assignment is unconditional. If `request_id` is already a key in `_request_streams`, the prior `(send, receive)` pair is dropped on the floor. The earlier request's writer eventually tries to push a response into a stream nobody is reading, and the earlier request's caller is reading a stream nobody will ever write to.\n\nThe router side at [lines 1004-1033](https://github.com/modelcontextprotocol/python-sdk/blob/v1.27.1/src/mcp/server/streamable_http.py#L1004-L1033) uses the same `str(id)` keying to dispatch responses, so once the slot has been overwritten, response routing is undefined.\n\n## Reproduction signature\n\nWe hit this through an in-house client that was sending `id: 1` for every concurrent tool call on a shared session. Under concurrent load, calls timed out and at least one caller received the wrong tool's response payload.\n\n## Proposed Behavior\n\nWhen a request arrives with an `id` that already has an in-flight stream registered, the server should reject it with JSON-RPC `-32600 Invalid Request` and leave the existing in-flight request untouched. This:\n\n1. Surfaces the spec violation to the client immediately instead of timing out.\n2. Preserves the in-flight request that arrived first.\n3. Gives operators a log line to diagnose against.\n\nA weaker variant (log-only, no error response) would still be a meaningful improvement over silent data loss.","author":{"url":"https://github.com/dexteradeus","@type":"Person","name":"dexteradeus"},"datePublished":"2026-05-21T19:59:05Z","url":"https://github.com/modelcontextprotocol/python-sdk/issues/2655"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| 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:6d99abac-c62d-f1d4-2ca5-785e4c3293cb |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | CA78:34DB8F:9201E:CA554:6B00B9A3 |
| html-safe-nonce | b524106b16e282366d821773276ad3b7ffc0723c78c0001da3e4561c3691e941 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDQTc4OjM0REI4Rjo5MjAxRTpDQTU1NDo2QjAwQjlBMyIsInZpc2l0b3JfaWQiOiI2NTE2ODQ5MDgyMjYxMDkyNzcxIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | d8b5ae0943b99bbf34a6181f52f9108e25fe5e581d2a4fa6b48db031cba6515c |
| hovercard-subject-tag | issue:4497523735 |
| 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/2655/issue_layout |
| twitter:image | https://opengraph.githubassets.com/dc05ac3bc338b840086a146a2029567e6fe0aa4e177fe0a71aa1c144567ac13a/modelcontextprotocol/python-sdk/issues/2655 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/dc05ac3bc338b840086a146a2029567e6fe0aa4e177fe0a71aa1c144567ac13a/modelcontextprotocol/python-sdk/issues/2655 |
| og:image:alt | Summary When a client sends two JSON-RPC requests with the same id on the same Streamable HTTP session before the first response is delivered, StreamableHTTPServerTransport overwrites the per-id re... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | dexteradeus |
| hostname | github.com |
| expected-hostname | github.com |
| None | 1d07c25977adfc5ff6acb0a962a9bc168c07afbda6fef765f9761c350c2ae4a2 |
| 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 | 5429cbfc6aca8c7b9a086a3c8f47400346f38cc9 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width