Title: fix: reject duplicate JSON-RPC request IDs with 409 Conflict (fixes #2655) by kaXianc2-gom · Pull Request #2944 · modelcontextprotocol/python-sdk · GitHub
Open Graph Title: fix: reject duplicate JSON-RPC request IDs with 409 Conflict (fixes #2655) by kaXianc2-gom · Pull Request #2944 · modelcontextprotocol/python-sdk
X Title: fix: reject duplicate JSON-RPC request IDs with 409 Conflict (fixes #2655) by kaXianc2-gom · Pull Request #2944 · modelcontextprotocol/python-sdk
Description: Summary Fixes #2655: StreamableHTTPServerTransport now detects and rejects duplicate JSON-RPC request IDs before overwriting the in-flight stream slot. Before: A client sending two requests with the same id on the same session would silently overwrite the first request's (send, receive) stream pair in _request_streams. The original caller hangs until timeout; the response may route to the wrong caller. After: The server returns HTTP 409 Conflict with a JSON-RPC -32600 Invalid Request error, preserving the original in-flight stream. Changes _handle_post_request — added collision check before stream registration, mirroring the existing GET_STREAM_KEY guard at line 695 _create_error_response — added optional keyword-only request_id parameter so the JSON-RPC error envelope carries the offending id instead of null AI Assistance Disclosure This contribution was developed with AI assistance (Claude / Anthropic Claude Code). Verification Process Synced sandbox to upstream main (2397319) uv sync --no-group docs installed all dependencies Baseline test suite: 2269 passed, 12 skipped, 1 xfailed (×3, no flakes) Applied fix (18 lines in streamable_http.py, +1 noqa: C901) Added targeted test test_duplicate_request_id_rejected_with_409: Seeds _request_streams with an in-flight request POSTs a duplicate request with the same id Asserts 409 status, correct JSON-RPC error envelope with the id, and original stream preserved Full test suite after upstream merge: 2571 passed, 12 skipped, 9 xfailed ruff format + ruff check: all clean Cross-Validation Scenario Before After Normal request (unique id) ✅ ✅ Duplicate id while original in-flight ❌ silent overwrite ✅ 409 + preserved stream Duplicate id after original completed ✅ normal (stream cleaned) ✅ same Error response id field ❌ always null ✅ carries the request id GET_STREAM_KEY collision (existing) ✅ ✅ (unchanged) 🤖 Generated with Claude Code
Open Graph Description: Summary Fixes #2655: StreamableHTTPServerTransport now detects and rejects duplicate JSON-RPC request IDs before overwriting the in-flight stream slot. Before: A client sending two requests with th...
X Description: Summary Fixes #2655: StreamableHTTPServerTransport now detects and rejects duplicate JSON-RPC request IDs before overwriting the in-flight stream slot. Before: A client sending two requests with th...
Opengraph URL: https://github.com/modelcontextprotocol/python-sdk/pull/2944
X: @github
Domain: github.com
| 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 | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:69df9ec6-3096-370f-5035-1b6073e2eb85 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | 98C0:2564F:EB0EEB:136AE9C:6B010145 |
| html-safe-nonce | 68545e83fde96b1ac26096c1ad0909c2e9584b08427d60ef1c9efb5a294a5771 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5OEMwOjI1NjRGOkVCMEVFQjoxMzZBRTlDOjZCMDEwMTQ1IiwidmlzaXRvcl9pZCI6IjE2OTUzMDQxODMyNjk5NTI2OSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | d1070c8f5d2529b8e4bc8a0537147ae243460ba6006949cbf5ae95a97141b175 |
| hovercard-subject-tag | pull_request:3908816272 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,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/modelcontextprotocol/python-sdk/pull/2944/files |
| twitter:image | https://avatars.githubusercontent.com/u/288512724?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/288512724?s=400&v=4 |
| og:image:alt | Summary Fixes #2655: StreamableHTTPServerTransport now detects and rejects duplicate JSON-RPC request IDs before overwriting the in-flight stream slot. Before: A client sending two requests with th... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | cb7fa109eca7d4156c889f474306b0e91336055e9adf8fd4684b61e49094d124 |
| turbo-cache-control | no-preview |
| diff-view | unified |
| 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 full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 2b59d31a4e44f08b7af67a4b67f8fd0af3befe2a |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width