René's URL Explorer Experiment


Title: 2026-07-28 SSE responses share one header list, so in-place middleware appends leak across responses · Issue #3701 · modelcontextprotocol/python-sdk · GitHub

Open Graph Title: 2026-07-28 SSE responses share one header list, so in-place middleware appends leak across responses · Issue #3701 · modelcontextprotocol/python-sdk

X Title: 2026-07-28 SSE responses share one header list, so in-place middleware appends leak across responses · Issue #3701 · 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/3701

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"2026-07-28 SSE responses share one header list, so in-place middleware appends leak across responses","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\nOn the 2026-07-28 HTTP entry, `handle_modern_request` starts every SSE response with the module-level `_SSE_HEADERS` list itself:\n\n```python\nawait send({\"type\": \"http.response.start\", \"status\": _OK_STATUS, \"headers\": _SSE_HEADERS})\n```\n\nASGI middleware that adds a header with `message[\"headers\"].append(...)` therefore appends to the SDK's shared list. The header stays there for the life of the process, so every later SSE response carries one more copy, along with the values set for earlier requests. JSON responses aren't affected, because they build their own header list.\n\nWe hit this in production with an observability middleware that appended an `x-correlation-id`. After about 250 SSE responses in one process, our edge proxy's HTTP client rejected the responses as malformed. Only calls that commit to SSE (a notification, or more than 15 s without one) take this path, so fast calls and most test suites never touch it, and a restart hid it for a while.\n\nThe middleware shouldn't mutate a list it doesn't own; Starlette's `MutableHeaders(scope=message)` copies for exactly this reason. Passing `list(_SSE_HEADERS)` would keep one middleware's mistake from turning into process-wide header growth and cross-request header leakage.\n\nExpected: each SSE response gets its own header list.\n\n### Example Code\n\n```python\nimport asyncio\nimport httpx\nfrom mcp.server.mcpserver import Context, MCPServer\nfrom mcp.server.transport_security import TransportSecuritySettings\n\nmcp = MCPServer(\"repro\")\n\n@mcp.tool()\nasync def slow(ctx: Context) -> str:\n    await ctx.report_progress(1, 2)  # any notification commits the response to SSE\n    return \"done\"\n\ninner = mcp.streamable_http_app(\n    transport_security=TransportSecuritySettings(enable_dns_rebinding_protection=False)\n)\n\nasync def app(scope, receive, send):  # middleware that appends in place\n    async def send2(msg):\n        if msg[\"type\"] == \"http.response.start\":\n            msg[\"headers\"].append((b\"x-correlation-id\", b\"abc\"))\n        await send(msg)\n    await inner(scope, receive, send2)\n\ndef body(i):\n    return {\"jsonrpc\": \"2.0\", \"id\": i, \"method\": \"tools/call\",\n            \"params\": {\"name\": \"slow\", \"arguments\": {}, \"_meta\": {\n                \"progressToken\": i,\n                \"io.modelcontextprotocol/protocolVersion\": \"2026-07-28\",\n                \"io.modelcontextprotocol/clientInfo\": {\"name\": \"r\", \"version\": \"0\"},\n                \"io.modelcontextprotocol/clientCapabilities\": {}}}}\n\nasync def main():\n    async with inner.router.lifespan_context(inner):\n        async with httpx.AsyncClient(transport=httpx.ASGITransport(app=app), base_url=\"http://localhost\") as c:\n            for i in range(1, 6):\n                r = await c.post(\"/mcp\", json=body(i), headers={\n                    \"accept\": \"application/json, text/event-stream\",\n                    \"mcp-protocol-version\": \"2026-07-28\",\n                    \"mcp-method\": \"tools/call\", \"mcp-name\": \"slow\"})\n                print(i, len(r.headers.get_list(\"x-correlation-id\")))\n\nasyncio.run(main())\n```\n\nOutput: `1 1`, `2 2`, `3 3`, `4 4`, `5 5`.\n\nI have a fix ready (`list(_SSE_HEADERS)` plus a regression test in `tests/server/test_streamable_http_modern.py` that fails before and passes after) and would be glad to open the PR if you assign this to me. Open PR #3192 carries the same line, in case that's the better place for it.\n\nAI disclosure: I used Claude Code to find the line, write the repro, and draft this issue. I hit the bug in production and have checked the repro and the fix myself.\n\n### Python & MCP Python SDK\n\n```\nPython 3.13, mcp 2.3.0 (also present on main at 754254c)\n```\n","author":{"url":"https://github.com/mgoldsborough","@type":"Person","name":"mgoldsborough"},"datePublished":"2026-10-13T21:36:41Z","url":"https://github.com/modelcontextprotocol/python-sdk/issues/3701"}

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:3e687401-c42e-0f4c-b10a-024ed7aad70d
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idB0B6:26ECEB:D1D9:1103F:6B00B72F
html-safe-nonce2b4c1ed1a4a35b3e99bd80e5837b866a147b2661a822fde74d65c0ba65d909fc
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCMEI2OjI2RUNFQjpEMUQ5OjExMDNGOjZCMDBCNzJGIiwidmlzaXRvcl9pZCI6IjE0MjkyMDIxMDY3MTUyNTY2MjMiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac307dc4976ec615d6f046187085845604bb06903c05d9ab5daa7174895d221da0
hovercard-subject-tagissue:5838107985
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/3701/issue_layout
twitter:imagehttps://opengraph.githubassets.com/8a3141b12403ebda372ec1307e7f0997f8b3d80647169faff4ea4f5762b5c823/modelcontextprotocol/python-sdk/issues/3701
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/8a3141b12403ebda372ec1307e7f0997f8b3d80647169faff4ea4f5762b5c823/modelcontextprotocol/python-sdk/issues/3701
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:usernamemgoldsborough
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-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/modelcontextprotocol/python-sdk/issues/3701#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmodelcontextprotocol%2Fpython-sdk%2Fissues%2F3701
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%2F3701
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/3701
Reloadhttps://github.com/modelcontextprotocol/python-sdk/issues/3701
Reloadhttps://github.com/modelcontextprotocol/python-sdk/issues/3701
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/3701
New issuehttps://github.com/login?return_to=https://github.com/modelcontextprotocol/python-sdk/issues/3701
#3726https://github.com/modelcontextprotocol/python-sdk/pull/3726
2026-07-28 SSE responses share one header list, so in-place middleware appends leak across responseshttps://github.com/modelcontextprotocol/python-sdk/issues/3701#top
#3726https://github.com/modelcontextprotocol/python-sdk/pull/3726
bugSomething isn't workinghttps://github.com/modelcontextprotocol/python-sdk/issues?q=state%3Aopen%20label%3A%22bug%22
spec-2026-07-28Concerns the SDK's implementation of the 2026-07-28 MCP spec revisionhttps://github.com/modelcontextprotocol/python-sdk/issues?q=state%3Aopen%20label%3A%22spec-2026-07-28%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/mgoldsborough
mgoldsboroughhttps://github.com/mgoldsborough
on Oct 13, 2026https://github.com/modelcontextprotocol/python-sdk/issues/3701#issue-5838107985
https://github.com/modelcontextprotocol/python-sdk/issueshttps://github.com/modelcontextprotocol/python-sdk/issues
#3192https://github.com/modelcontextprotocol/python-sdk/pull/3192
claudehttps://github.com/apps/claude
bugSomething isn't workinghttps://github.com/modelcontextprotocol/python-sdk/issues?q=state%3Aopen%20label%3A%22bug%22
v2Affects the v2 line (2.x on main)https://github.com/modelcontextprotocol/python-sdk/issues?q=state%3Aopen%20label%3A%22v2%22
spec-2026-07-28Concerns the SDK's implementation of the 2026-07-28 MCP spec revisionhttps://github.com/modelcontextprotocol/python-sdk/issues?q=state%3Aopen%20label%3A%22spec-2026-07-28%22
on Oct 13, 2026https://github.com/modelcontextprotocol/python-sdk/issues/3701#event-33174230822
https://github.com/er-s-an
er-s-anhttps://github.com/er-s-an
on Oct 14, 2026https://github.com/modelcontextprotocol/python-sdk/issues/3701#issuecomment-6168360785
Kludexhttps://github.com/Kludex
completedhttps://github.com/modelcontextprotocol/python-sdk/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
#3726https://github.com/modelcontextprotocol/python-sdk/pull/3726
on Oct 17, 2026https://github.com/modelcontextprotocol/python-sdk/issues/3701#event-33522302404
Sign up for freehttps://github.com/signup?return_to=https://github.com/modelcontextprotocol/python-sdk/issues/3701
Sign in to commenthttps://github.com/login?return_to=https://github.com/modelcontextprotocol/python-sdk/issues/3701
bugSomething isn't workinghttps://github.com/modelcontextprotocol/python-sdk/issues?q=state%3Aopen%20label%3A%22bug%22
spec-2026-07-28Concerns the SDK's implementation of the 2026-07-28 MCP spec revisionhttps://github.com/modelcontextprotocol/python-sdk/issues?q=state%3Aopen%20label%3A%22spec-2026-07-28%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.