René's URL Explorer Experiment


Title: Streamable HTTP notification triggers duplicate response after HTTP 202 · Issue #3631 · modelcontextprotocol/python-sdk · GitHub

Open Graph Title: Streamable HTTP notification triggers duplicate response after HTTP 202 · Issue #3631 · modelcontextprotocol/python-sdk

X Title: Streamable HTTP notification triggers duplicate response after HTTP 202 · Issue #3631 · modelcontextprotocol/python-sdk

Description: Initial Checks I confirm that I'm using the newest release of my line (the latest 2.x, or the latest 1.x if I'm still on v1) I confirm that I searched for my issue in https://github.com/modelcontextprotocol/python-sdk/issues before openi...

Open Graph Description: Initial Checks I confirm that I'm using the newest release of my line (the latest 2.x, or the latest 1.x if I'm still on v1) I confirm that I searched for my issue in https://github.com/modelcontex...

X Description: Initial Checks I confirm that I'm using the newest release of my line (the latest 2.x, or the latest 1.x if I'm still on v1) I confirm that I searched for my issue in https://github.com/mod...

Opengraph URL: https://github.com/modelcontextprotocol/python-sdk/issues/3631

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Streamable HTTP notification triggers duplicate response after HTTP 202","articleBody":"### Initial Checks\n\n- [x] I confirm that I'm using the newest release of my line (the latest 2.x, or the latest 1.x if I'm still on v1)\n- [x] I confirm that I searched for my issue in https://github.com/modelcontextprotocol/python-sdk/issues before opening this issue\n\n### Release line\n\n2.x (current stable)\n\n### Description\n\n## Summary\n\nMCP 2.1.1 can send HTTP 202 for a JSON-RPC notification and then raise `ClosedResourceError` when writing the notification to a closed internal session writer.\n\nThe outer error handler then attempts to send a second HTTP error response after the 202 response has already started. This can result in an unhandled `ExceptionGroup` or duplicate-response error.\n\n## Environment\n\n* MCP: 2.1.1\n* FastMCP: 4.0.3\n* Python: 3.11\n* Transport: Streamable HTTP\n* Notification: `notifications/initialized`\n\n## Expected behavior\n\nOnce MCP has sent HTTP 202 for a notification, a closed internal session writer should not trigger:\n\n* A second HTTP response.\n* An unhandled exception.\n* A second write attempt to the closed writer.\n\n## Actual behavior\n\nThe notification path currently:\n\n1. Sends HTTP 202 Accepted.\n2. Calls `writer.send(session_message)`.\n3. Raises `ClosedResourceError` because the writer is closed.\n4. Enters the broad POST error handler.\n5. Attempts to send an HTTP 500 response after the 202 response has already started.\n6. Attempts another write through the closed writer.\n\nThis can result in an unhandled `ExceptionGroup` or duplicate-response failure.\n\n## Minimal reproduction\n\n1. Create a `StreamableHTTPServerTransport` with JSON response mode enabled.\n2. Call `transport.connect()`.\n3. Close `transport._read_stream_writer`.\n4. Send a JSON-RPC `notifications/initialized` POST request through `transport.handle_request` with ASGI exceptions enabled.\n5. Observe the unhandled exception after the initial HTTP 202 response has started.\n\n## Evidence\n\nThe closed writer failure originates in:\n\n`mcp/shared/_context_streams.py:37`\n\nThe notification handler sends HTTP 202 before attempting to write the notification to the internal session stream.\n\n## Related issues\n\nThis is related to the closed-writer handling discussed in #2064, but the failure occurs on the MCP v2 notification path.\n\n## Temporary workaround\n\nI added a version-specific safeguard that:\n\n* Preserves the original HTTP 202 response.\n* Prevents the invalid secondary HTTP response.\n* Prevents the final `ClosedResourceError` from escaping.\n\nThe SDK still emits the initial `Error handling POST request` log because that logging occurs before the workaround can intercept the secondary failure.\n\n\n### Example Code\n\n```Python\nInstall the reproduction dependencies:\n\n\n\npython -m pip install \"mcp==2.1.1\" \"httpx==0.28.1\"\n\n\nRun this script:\n\n\n\nimport asyncio\n\nimport httpx\nfrom mcp.server.streamable_http import StreamableHTTPServerTransport\n\nasync def main() -> None:\n    transport = StreamableHTTPServerTransport(\n        mcp_session_id=None,\n        is_json_response_enabled=True,\n    )\n\n    async with transport.connect():\n        assert transport._read_stream_writer is not None\n\n        # Simulate a terminated MCP session after the transport connects.\n        await transport._read_stream_writer.aclose()\n\n        async with httpx.AsyncClient(\n            transport=httpx.ASGITransport(\n                app=transport.handle_request,\n                raise_app_exceptions=True,\n            ),\n            base_url=\"http://testserver\",\n        ) as client:\n            response = await client.post(\n                \"/mcp\",\n                headers={\n                    \"accept\": \"application/json\",\n                    \"content-type\": \"application/json\",\n                },\n                json={\n                    \"jsonrpc\": \"2.0\",\n                    \"method\": \"notifications/initialized\",\n                    \"params\": {},\n                },\n            )\n\n    print(response.status_code)\n\nasyncio.run(main())\n\n\nActual Result\nThe notification handler first sends `HTTP 202 Accepted`.\n\nIt then calls:\n\n\nawait writer.send(session_message)\n\n\nThe closed writer raises:\n\n\nanyio.ClosedResourceError\n\n\nThe outer error handler then attempts a second HTTP error response after the `202` response started. With `raise_app_exceptions=True`, the reproduction exits nonzero with an `ExceptionGroup` that contains the closed-writer failure and duplicate-response error.\n\nRelevant trace locations:\n\nmcp/server/streamable_http.py\nmcp/shared/_context_streams.py:37\nanyio/streams/memory.py\n```\n\n### Python & MCP Python SDK\n\n```Text\nPython: 3.11.14\nMCP Python SDK: 2.1.1\nFastMCP: 4.0.3 in the production incident container\nTransport: Streamable HTTP\n```","author":{"url":"https://github.com/lecton-apptio","@type":"Person","name":"lecton-apptio"},"datePublished":"2026-10-02T17:12:26Z","url":"https://github.com/modelcontextprotocol/python-sdk/issues/3631"}

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/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:4cc34630-9263-8572-50f7-7c1527ed993b
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idA3EC:2F9718:1634C:1E6C9:6B00B733
html-safe-noncef837baf0377285becab9cfb939650f80a91fada82a7d603c62e0152da6c43602
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBM0VDOjJGOTcxODoxNjM0QzoxRTZDOTo2QjAwQjczMyIsInZpc2l0b3JfaWQiOiI0OTU2MTQxODgwOTQyNzMzMzEiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac2a10e6ddb9b3d868cc82a69e759980dae5034d4713259d309f4d64024d791490
hovercard-subject-tagissue:5680800407
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/modelcontextprotocol/python-sdk/3631/issue_layout
twitter:imagehttps://opengraph.githubassets.com/294542cf92365e7859618bd305fe9f3b929d20573529a212fe5beb444b3d84b1/modelcontextprotocol/python-sdk/issues/3631
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/294542cf92365e7859618bd305fe9f3b929d20573529a212fe5beb444b3d84b1/modelcontextprotocol/python-sdk/issues/3631
og:image:altInitial Checks I confirm that I'm using the newest release of my line (the latest 2.x, or the latest 1.x if I'm still on v1) I confirm that I searched for my issue in https://github.com/modelcontex...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamelecton-apptio
hostnamegithub.com
expected-hostnamegithub.com
None1d07c25977adfc5ff6acb0a962a9bc168c07afbda6fef765f9761c350c2ae4a2
turbo-cache-controlno-preview
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
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release5429cbfc6aca8c7b9a086a3c8f47400346f38cc9
ui-targetcanary-1
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/modelcontextprotocol/python-sdk/issues/3631#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmodelcontextprotocol%2Fpython-sdk%2Fissues%2F3631
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%2Fissues%2F3631
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=modelcontextprotocol%2Fpython-sdk
Reloadhttps://github.com/modelcontextprotocol/python-sdk/issues/3631
Reloadhttps://github.com/modelcontextprotocol/python-sdk/issues/3631
Reloadhttps://github.com/modelcontextprotocol/python-sdk/issues/3631
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
https://github.com/modelcontextprotocol/python-sdk
New issuehttps://github.com/login?return_to=https://github.com/modelcontextprotocol/python-sdk/issues/3631
New issuehttps://github.com/login?return_to=https://github.com/modelcontextprotocol/python-sdk/issues/3631
Streamable HTTP notification triggers duplicate response after HTTP 202https://github.com/modelcontextprotocol/python-sdk/issues/3631#top
bugSomething isn't workinghttps://github.com/modelcontextprotocol/python-sdk/issues?q=state%3Aopen%20label%3A%22bug%22
v1Affects the v1.x maintenance linehttps://github.com/modelcontextprotocol/python-sdk/issues?q=state%3Aopen%20label%3A%22v1%22
v2Affects the v2 line (2.x on main)https://github.com/modelcontextprotocol/python-sdk/issues?q=state%3Aopen%20label%3A%22v2%22
https://github.com/lecton-apptio
lecton-apptiohttps://github.com/lecton-apptio
on Oct 2, 2026https://github.com/modelcontextprotocol/python-sdk/issues/3631#issue-5680800407
https://github.com/modelcontextprotocol/python-sdk/issueshttps://github.com/modelcontextprotocol/python-sdk/issues
#2064https://github.com/modelcontextprotocol/python-sdk/issues/2064
claudehttps://github.com/apps/claude
v2Affects the v2 line (2.x on main)https://github.com/modelcontextprotocol/python-sdk/issues?q=state%3Aopen%20label%3A%22v2%22
v1Affects the v1.x maintenance linehttps://github.com/modelcontextprotocol/python-sdk/issues?q=state%3Aopen%20label%3A%22v1%22
on Oct 2, 2026https://github.com/modelcontextprotocol/python-sdk/issues/3631#event-32353523273
https://github.com/premanand8800
premanand8800https://github.com/premanand8800
on Oct 3, 2026https://github.com/modelcontextprotocol/python-sdk/issues/3631#issuecomment-5971523807
2118f14https://github.com/modelcontextprotocol/python-sdk/commit/2118f14f8a19bc158d8a1cf90af58d85d187f849
https://github.com/premanand8800/python-sdk/tree/fix/notification-202-closed-sessionhttps://github.com/premanand8800/python-sdk/tree/fix/notification-202-closed-session
@lecton-apptiohttps://github.com/lecton-apptio
https://github.com/rupak-eng
rupak-enghttps://github.com/rupak-eng
on Oct 4, 2026https://github.com/modelcontextprotocol/python-sdk/issues/3631#issuecomment-5976607199
https://github.com/Ben-Home
Ben-Homehttps://github.com/Ben-Home
on Oct 5, 2026https://github.com/modelcontextprotocol/python-sdk/issues/3631#issuecomment-5999253365
https://github.com/Varshith-Kali
Varshith-Kalihttps://github.com/Varshith-Kali
on Oct 7, 2026https://github.com/modelcontextprotocol/python-sdk/issues/3631#issuecomment-6040182119
#3641https://github.com/modelcontextprotocol/python-sdk/issues/3641
#3631https://github.com/modelcontextprotocol/python-sdk/issues/3631
claudehttps://github.com/apps/claude
bugSomething isn't workinghttps://github.com/modelcontextprotocol/python-sdk/issues?q=state%3Aopen%20label%3A%22bug%22
on Oct 8, 2026https://github.com/modelcontextprotocol/python-sdk/issues/3631#event-32781198300
https://github.com/lecton-apptio
lecton-apptiohttps://github.com/lecton-apptio
on Nov 20, 2026https://github.com/modelcontextprotocol/python-sdk/issues/3631#issuecomment-7044150491
@Varshith-Kalihttps://github.com/Varshith-Kali
#3192https://github.com/modelcontextprotocol/python-sdk/pull/3192
Sign up for freehttps://github.com/signup?return_to=https://github.com/modelcontextprotocol/python-sdk/issues/3631
Sign in to commenthttps://github.com/login?return_to=https://github.com/modelcontextprotocol/python-sdk/issues/3631
bugSomething isn't workinghttps://github.com/modelcontextprotocol/python-sdk/issues?q=state%3Aopen%20label%3A%22bug%22
v1Affects the v1.x maintenance linehttps://github.com/modelcontextprotocol/python-sdk/issues?q=state%3Aopen%20label%3A%22v1%22
v2Affects the v2 line (2.x on main)https://github.com/modelcontextprotocol/python-sdk/issues?q=state%3Aopen%20label%3A%22v2%22
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.