René's URL Explorer Experiment


Title: fix(server): reject concurrent duplicate JSON-RPC request ids by arimu1 · Pull Request #3221 · modelcontextprotocol/python-sdk · GitHub

Open Graph Title: fix(server): reject concurrent duplicate JSON-RPC request ids by arimu1 · Pull Request #3221 · modelcontextprotocol/python-sdk

X Title: fix(server): reject concurrent duplicate JSON-RPC request ids by arimu1 · Pull Request #3221 · modelcontextprotocol/python-sdk

Description: Summary Stateful streamable HTTP registers each in-flight request's response stream in a per-session dict keyed by the bare JSON-RPC request id. _handle_post_request assigned that slot unconditionally, so a second concurrent POST reusing an in-flight id silently overwrote the first request's stream and responses were cross-wired (one caller received the other's payload; the other hung). Both response modes (JSON and SSE) now reject the collision with HTTP 409 Conflict and a JSON-RPC INVALID_REQUEST error instead of overwriting. The SSE path reserves the routing slot before EventStore.store_event (priming) so a concurrent same-id POST cannot pass the guard during that await — a race left open by a simpler check-before-register approach when resumability is enabled. If priming raises, the reservation is released. Sequential reuse of an id after the earlier request has completed remains allowed. Fixes #3137 Related Prior attempt #3163 (self-closed, unmerged) covered the basic guard but not the priming race window. Related open work on the same class of bug: #3060 / #3063 (transport) and #3064 (dispatcher). This PR targets #3137 and improves on #3163 by closing the priming TOCTOU. Test plan test_post_duplicate_request_id_rejected_while_first_still_in_flight (SSE) — second POST gets 409; first still completes with its own result test_json_response_duplicate_request_id_rejected_while_first_still_in_flight (JSON mode) test_request_id_reuse_after_completion_allowed — sequential reuse still works test_duplicate_request_id_rejected_during_priming_event_store — guard holds across gated priming await uv run --frozen pytest tests/shared/test_streamable_http.py — 69 passed uv run --frozen ruff check / ruff format --check on touched files uv run --frozen pyright on touched files Disclosure This change was written with AI assistance (Grok / Cursor); I reviewed the diff, ran the tests above, and can answer questions about the change.

Open Graph Description: Summary Stateful streamable HTTP registers each in-flight request's response stream in a per-session dict keyed by the bare JSON-RPC request id. _handle_post_request assigned that slot uncondit...

X Description: Summary Stateful streamable HTTP registers each in-flight request's response stream in a per-session dict keyed by the bare JSON-RPC request id. _handle_post_request assigned that slot unco...

Opengraph URL: https://github.com/modelcontextprotocol/python-sdk/pull/3221

X: @github

direct link

Domain: github.com

react-profiling0
react-import-mapreact,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-controllerpull_requests
route-actionfiles
fetch-noncev2:c39f7ef6-ee97-b348-a9fc-e2e19aaa6ba1
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-id8CD6:237673:D21C28:119D266:6B010137
html-safe-nonce82c1dcffab7eaad99b5330c1552acc7d7fb7798f2c3e51fe7116b30eac379eff
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4Q0Q2OjIzNzY3MzpEMjFDMjg6MTE5RDI2Njo2QjAxMDEzNyIsInZpc2l0b3JfaWQiOiI1MzUzNjY2NDkyNzYyMjI2OTk5IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmac37a8100e473247dc77f3e281757de37fdb19b37dea2b2c8bc81b9214512127d8
hovercard-subject-tagpull_request:4170463717
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/modelcontextprotocol/python-sdk/pull/3221/files
twitter:imagehttps://avatars.githubusercontent.com/u/19286898?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/19286898?s=400&v=4
og:image:altSummary Stateful streamable HTTP registers each in-flight request's response stream in a per-session dict keyed by the bare JSON-RPC request id. _handle_post_request assigned that slot uncondit...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
Nonecb7fa109eca7d4156c889f474306b0e91336055e9adf8fd4684b61e49094d124
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/modelcontextprotocol/python-sdk git https://github.com/modelcontextprotocol/python-sdk.git
octolytics-dimension-user_id182288589
octolytics-dimension-user_loginmodelcontextprotocol
octolytics-dimension-repository_id862584018
octolytics-dimension-repository_nwomodelcontextprotocol/python-sdk
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id862584018
octolytics-dimension-repository_network_root_nwomodelcontextprotocol/python-sdk
turbo-body-classeslogged-out env-production page-responsive full-width
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release2b59d31a4e44f08b7af67a4b67f8fd0af3befe2a
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/modelcontextprotocol/python-sdk/pull/3221/files#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmodelcontextprotocol%2Fpython-sdk%2Fpull%2F3221%2Ffiles
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmodelcontextprotocol%2Fpython-sdk%2Fpull%2F3221%2Ffiles
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=modelcontextprotocol%2Fpython-sdk
Reloadhttps://github.com/modelcontextprotocol/python-sdk/pull/3221/files
Reloadhttps://github.com/modelcontextprotocol/python-sdk/pull/3221/files
Reloadhttps://github.com/modelcontextprotocol/python-sdk/pull/3221/files
modelcontextprotocolhttps://github.com/modelcontextprotocol
python-sdkhttps://github.com/modelcontextprotocol/python-sdk
Codehttps://github.com/modelcontextprotocol/python-sdk
Issues308 (308)https://github.com/modelcontextprotocol/python-sdk/issues
Pull requests112 (112)https://github.com/modelcontextprotocol/python-sdk/pulls
Actionshttps://github.com/modelcontextprotocol/python-sdk/actions
Projectshttps://github.com/modelcontextprotocol/python-sdk/projects
Security and quality12 (12)https://github.com/modelcontextprotocol/python-sdk/security
Insightshttps://github.com/modelcontextprotocol/python-sdk/insights
Sign up for GitHub https://github.com/signup?return_to=%2Fmodelcontextprotocol%2Fpython-sdk%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2Fmodelcontextprotocol%2Fpython-sdk%2Fissues%2Fnew%2Fchoose
arimu1https://github.com/arimu1
modelcontextprotocol:mainhttps://github.com/modelcontextprotocol/python-sdk/tree/main
arimu1:fix/streamable-http-duplicate-request-id-3137https://github.com/arimu1/python-sdk/tree/fix/streamable-http-duplicate-request-id-3137
Conversation 7 https://github.com/modelcontextprotocol/python-sdk/pull/3221
Commits 3 https://github.com/modelcontextprotocol/python-sdk/pull/3221/commits
Checks 29 https://github.com/modelcontextprotocol/python-sdk/pull/3221/checks
Files changed https://github.com/modelcontextprotocol/python-sdk/pull/3221/files
Please reload this pagehttps://github.com/modelcontextprotocol/python-sdk/pull/3221/files
fix(server): reject concurrent duplicate JSON-RPC request ids https://github.com/modelcontextprotocol/python-sdk/pull/3221/files#top
Show all changes 3 commits https://github.com/modelcontextprotocol/python-sdk/pull/3221/files
5fd834e fix(server): reject concurrent duplicate JSON-RPC request ids arimu1 Jul 30, 2026 https://github.com/modelcontextprotocol/python-sdk/pull/3221/commits/5fd834ede4b2a96c614f24f13cac59d58730d548
47f7a39 fix(server): type-preserve streamable HTTP request stream keys arimu1 Jul 31, 2026 https://github.com/modelcontextprotocol/python-sdk/pull/3221/commits/47f7a39dea6081e61e51e895946147c6e99d7118
1e6a108 test(server): register router streams under type-preserving keys arimu1 Aug 1, 2026 https://github.com/modelcontextprotocol/python-sdk/pull/3221/commits/1e6a108c6bc5dd5f1f9433464e29a8efb458f6e0
Clear filters https://github.com/modelcontextprotocol/python-sdk/pull/3221/files
Please reload this pagehttps://github.com/modelcontextprotocol/python-sdk/pull/3221/files
Please reload this pagehttps://github.com/modelcontextprotocol/python-sdk/pull/3221/files
streamable_http.py https://github.com/modelcontextprotocol/python-sdk/pull/3221/files#diff-0119e4c1bbf2fde7ba89b9c9f5bc472ccc2332f84e96e47cf9e45cebef801da3
test_streamable_http_router.py https://github.com/modelcontextprotocol/python-sdk/pull/3221/files#diff-19d95b11a9e1249b7955143f91e9e2f482f5b09493dc88875c57b3ee08d58c08
test_streamable_http.py https://github.com/modelcontextprotocol/python-sdk/pull/3221/files#diff-57d1f3c64af36960aa61b1d77387fb6201b90fbc2f3d606bf2761315ce618cc5
src/mcp/server/streamable_http.pyhttps://github.com/modelcontextprotocol/python-sdk/pull/3221/files#diff-0119e4c1bbf2fde7ba89b9c9f5bc472ccc2332f84e96e47cf9e45cebef801da3
View file https://github.com/arimu1/python-sdk/blob/1e6a108c6bc5dd5f1f9433464e29a8efb458f6e0/src/mcp/server/streamable_http.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/modelcontextprotocol/python-sdk/pull/3221/{{ revealButtonHref }}
https://github.com/modelcontextprotocol/python-sdk/pull/3221/files#diff-0119e4c1bbf2fde7ba89b9c9f5bc472ccc2332f84e96e47cf9e45cebef801da3
https://github.com/modelcontextprotocol/python-sdk/pull/3221/files#diff-0119e4c1bbf2fde7ba89b9c9f5bc472ccc2332f84e96e47cf9e45cebef801da3
https://github.com/modelcontextprotocol/python-sdk/pull/3221/files#diff-0119e4c1bbf2fde7ba89b9c9f5bc472ccc2332f84e96e47cf9e45cebef801da3
https://github.com/modelcontextprotocol/python-sdk/pull/3221/files#diff-0119e4c1bbf2fde7ba89b9c9f5bc472ccc2332f84e96e47cf9e45cebef801da3
cubic-dev-aihttps://github.com/apps/cubic-dev-ai
Jul 31, 2026https://github.com/modelcontextprotocol/python-sdk/pull/3221/files#r3691565364
Learn morehttps://docs.github.com/articles/managing-disruptive-comments/#hiding-a-comment
Please reload this pagehttps://github.com/modelcontextprotocol/python-sdk/pull/3221/files
Please reload this pagehttps://github.com/modelcontextprotocol/python-sdk/pull/3221/files
https://github.com/modelcontextprotocol/python-sdk/pull/3221/files#diff-0119e4c1bbf2fde7ba89b9c9f5bc472ccc2332f84e96e47cf9e45cebef801da3
https://github.com/modelcontextprotocol/python-sdk/pull/3221/files#diff-0119e4c1bbf2fde7ba89b9c9f5bc472ccc2332f84e96e47cf9e45cebef801da3
https://github.com/modelcontextprotocol/python-sdk/pull/3221/files#diff-0119e4c1bbf2fde7ba89b9c9f5bc472ccc2332f84e96e47cf9e45cebef801da3
https://github.com/modelcontextprotocol/python-sdk/pull/3221/files#diff-0119e4c1bbf2fde7ba89b9c9f5bc472ccc2332f84e96e47cf9e45cebef801da3
cubic-dev-aihttps://github.com/apps/cubic-dev-ai
Jul 31, 2026https://github.com/modelcontextprotocol/python-sdk/pull/3221/files#r3691565369
Learn morehttps://docs.github.com/articles/managing-disruptive-comments/#hiding-a-comment
Please reload this pagehttps://github.com/modelcontextprotocol/python-sdk/pull/3221/files
https://github.com/modelcontextprotocol/python-sdk/pull/3221/files#diff-0119e4c1bbf2fde7ba89b9c9f5bc472ccc2332f84e96e47cf9e45cebef801da3
https://github.com/modelcontextprotocol/python-sdk/pull/3221/files#diff-0119e4c1bbf2fde7ba89b9c9f5bc472ccc2332f84e96e47cf9e45cebef801da3
tests/server/test_streamable_http_router.pyhttps://github.com/modelcontextprotocol/python-sdk/pull/3221/files#diff-19d95b11a9e1249b7955143f91e9e2f482f5b09493dc88875c57b3ee08d58c08
View file https://github.com/arimu1/python-sdk/blob/1e6a108c6bc5dd5f1f9433464e29a8efb458f6e0/tests/server/test_streamable_http_router.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/modelcontextprotocol/python-sdk/pull/3221/{{ revealButtonHref }}
https://github.com/modelcontextprotocol/python-sdk/pull/3221/files#diff-19d95b11a9e1249b7955143f91e9e2f482f5b09493dc88875c57b3ee08d58c08
https://github.com/modelcontextprotocol/python-sdk/pull/3221/files#diff-19d95b11a9e1249b7955143f91e9e2f482f5b09493dc88875c57b3ee08d58c08
https://github.com/modelcontextprotocol/python-sdk/pull/3221/files#diff-19d95b11a9e1249b7955143f91e9e2f482f5b09493dc88875c57b3ee08d58c08
https://github.com/modelcontextprotocol/python-sdk/pull/3221/files#diff-19d95b11a9e1249b7955143f91e9e2f482f5b09493dc88875c57b3ee08d58c08
Please reload this pagehttps://github.com/modelcontextprotocol/python-sdk/pull/3221/files
Please reload this pagehttps://github.com/modelcontextprotocol/python-sdk/pull/3221/files
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.