René's URL Explorer Experiment


Title: Streamable HTTP session lifecycle can retain unreachable sessions and serialize session creation behind slow requests · Issue #3605 · modelcontextprotocol/python-sdk · GitHub

Open Graph Title: Streamable HTTP session lifecycle can retain unreachable sessions and serialize session creation behind slow requests · Issue #3605 · modelcontextprotocol/python-sdk

X Title: Streamable HTTP session lifecycle can retain unreachable sessions and serialize session creation behind slow requests · Issue #3605 · modelcontextprotocol/python-sdk

Description: Summary While implementing a real MCP readiness probe against the Python SDK's stateful Streamable HTTP transport, we found several related session-lifecycle behaviors that can leave server-side sessions retained even though no client ca...

Open Graph Description: Summary While implementing a real MCP readiness probe against the Python SDK's stateful Streamable HTTP transport, we found several related session-lifecycle behaviors that can leave server-side se...

X Description: Summary While implementing a real MCP readiness probe against the Python SDK's stateful Streamable HTTP transport, we found several related session-lifecycle behaviors that can leave server-sid...

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

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Streamable HTTP session lifecycle can retain unreachable sessions and serialize session creation behind slow requests","articleBody":"## Summary\n\nWhile implementing a real MCP readiness probe against the Python SDK's stateful Streamable HTTP transport, we found several related session-lifecycle behaviors that can leave server-side sessions retained even though no client can use or close them.\n\nObserved with `mcp==1.27.1`.\n\nThe cases are especially visible for short-lived probes, but they apply to ordinary clients as well.\n\n## Observed behaviors\n\n### 1. Closed sessions remain retained\n\nAfter a client closes a session with `DELETE`, the session is closed but remains present in the session manager's internal session registry.\n\nFor a long-running server with repeated short-lived sessions, closed entries can therefore accumulate unless the embedding application adds its own cleanup.\n\n### 2. A session can be registered before the initiating request is ultimately accepted\n\nA new session may be registered server-side before later request validation rejects the request.\n\nWe observed this around cases such as an invalid `Host` request. Similar orphaning is possible when initialization is interrupted after the server has registered the session but before the client receives the session id.\n\nThe important lifecycle problem is:\n\n1. the server creates/registers a session;\n2. the request fails or is interrupted before the client learns the session id;\n3. the client therefore cannot address that session;\n4. the client cannot send `DELETE`;\n5. the server retains a session that no client can clean up.\n\nThis also matters when a readiness probe times out or is killed during initialization.\n\n### 3. Session creation can be serialized behind a slow request\n\nThe session-creation path uses shared synchronization such that a slow/stalled opening request can hold the creation path long enough to delay unrelated clients attempting to create sessions.\n\nA client that uploads or stalls slowly during this path can therefore affect other clients' ability to initialize.\n\n## Expected behavior\n\nIdeally the SDK would provide lifecycle semantics such that:\n\n- a session successfully closed with `DELETE` is removed from the session registry when it is no longer needed;\n- if an opening request creates/registers a session but fails before the client can receive/use its session id, that session is automatically closed and removed;\n- interrupted initialization does not leave indefinitely retained unreachable sessions;\n- a slow opening request does not unnecessarily serialize unrelated session creation;\n- applications do not need to infer whether a session was ever successfully exposed to a client in order to garbage-collect it safely.\n\nIf intentional retention is required for protocol reasons, an SDK-owned bounded cleanup/reaping mechanism would avoid each embedding server having to implement its own session lifecycle policy.\n\n## Current application workaround\n\nOur server currently distinguishes sessions that a client has demonstrated knowledge of from sessions whose id was never presented back by any request.\n\nFor an unclaimed session, a grace period starts only after the request that opened it finishes. If no request ever presents that session id, a later request can close/remove the abandoned session after the grace period.\n\nOnce any request presents the session id, the session is treated as claimed and is not subject to this orphan cleanup, even after a long idle period.\n\nThis avoids expiring legitimate long-lived MCP sessions while bounding sessions that became unreachable during initialization.\n\nWe also added a regression test specifically detecting the SDK's retention of closed sessions so the workaround can be removed when upstream lifecycle behavior changes.\n\nThis is only orphan cleanup; it is not an authentication or resource-quota mechanism. A caller that can reach an unauthenticated MCP endpoint can intentionally establish and keep valid sessions open.\n\n## Why this matters for readiness probes\n\nA useful readiness check should exercise the real MCP surface:\n\n`initialize -> initialized -> tools/list -> DELETE`\n\nNormally that cleans up correctly. But the probe process may be timed out/killed, or initialization may be rejected after the server has already registered state. In those cases the client may never receive the session id and therefore cannot perform cleanup itself.\n\nThat turns routine readiness probing into a source of retained server-side state unless the application compensates for the SDK lifecycle behavior.\n\n## Environment\n\n- Python MCP SDK: `mcp==1.27.1`\n- Stateful Streamable HTTP session manager\n- Reproduced with local deterministic tests around abandoned initialization, rejected requests, delayed opening requests, explicit DELETE, and long-lived claimed sessions.\n\nI can provide a minimal reproduction or point to the application-side tests/workaround if useful.","author":{"url":"https://github.com/fegloff","@type":"Person","name":"fegloff"},"datePublished":"2026-10-01T05:10:32Z","url":"https://github.com/modelcontextprotocol/python-sdk/issues/3605"}

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:7153b750-977c-c6a9-fe9f-2eead9dd6711
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idE54A:254EAB:1BA180:25F461:6B00AD80
html-safe-nonceee2df1869c672a599c9279911b641cd98f12596b56d90884380c31446e45500e
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFNTRBOjI1NEVBQjoxQkExODA6MjVGNDYxOjZCMDBBRDgwIiwidmlzaXRvcl9pZCI6Ijg2MTk2NTM1Mjk4MDU1NjUzMTIiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac4b4aa7b0ec3922fe7e988d2c2ed29fcabc0bf6d5ecd15790208f1b070c7d7d90
hovercard-subject-tagissue:5657304583
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/3605/issue_layout
twitter:imagehttps://opengraph.githubassets.com/54d1e8088252fce9def380fa33eef1171f9bf01dcdfaa10688f2ef35fdb95a3e/modelcontextprotocol/python-sdk/issues/3605
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/54d1e8088252fce9def380fa33eef1171f9bf01dcdfaa10688f2ef35fdb95a3e/modelcontextprotocol/python-sdk/issues/3605
og:image:altSummary While implementing a real MCP readiness probe against the Python SDK's stateful Streamable HTTP transport, we found several related session-lifecycle behaviors that can leave server-side se...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamefegloff
hostnamegithub.com
expected-hostnamegithub.com
Nonec0dd5f5d6f515a591019ecd66df2c4eab3379c2d3b0777568a90d8c7ae10b79e
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
release729d8cda69b3d267995675dfbf89ff27ccf61bf6
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/modelcontextprotocol/python-sdk/issues/3605#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmodelcontextprotocol%2Fpython-sdk%2Fissues%2F3605
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%2F3605
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/3605
Reloadhttps://github.com/modelcontextprotocol/python-sdk/issues/3605
Reloadhttps://github.com/modelcontextprotocol/python-sdk/issues/3605
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/3605
New issuehttps://github.com/login?return_to=https://github.com/modelcontextprotocol/python-sdk/issues/3605
Streamable HTTP session lifecycle can retain unreachable sessions and serialize session creation behind slow requestshttps://github.com/modelcontextprotocol/python-sdk/issues/3605#top
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/fegloff
fegloffhttps://github.com/fegloff
on Oct 1, 2026https://github.com/modelcontextprotocol/python-sdk/issues/3605#issue-5657304583
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 1, 2026https://github.com/modelcontextprotocol/python-sdk/issues/3605#event-32225253184
https://github.com/Ben-Home
Ben-Homehttps://github.com/Ben-Home
on Oct 1, 2026https://github.com/modelcontextprotocol/python-sdk/issues/3605#issuecomment-5930950569
https://github.com/Jaswanth1902
Jaswanth1902https://github.com/Jaswanth1902
on Oct 2, 2026https://github.com/modelcontextprotocol/python-sdk/issues/3605#issuecomment-5946046049
modelcontextprotocolhttps://github.com/modelcontextprotocol
Jaswanth1902https://github.com/Jaswanth1902
on Oct 2, 2026https://github.com/modelcontextprotocol/python-sdk/issues/3605#event-32334826586
https://github.com/maxisbey
maxisbeyhttps://github.com/maxisbey
on Oct 6, 2026https://github.com/modelcontextprotocol/python-sdk/issues/3605#issuecomment-6021025719
Claudehttps://anthropic.com/claude-code
#3395https://github.com/modelcontextprotocol/python-sdk/pull/3395
#3426https://github.com/modelcontextprotocol/python-sdk/pull/3426
AI Disclaimerhttps://gist.github.com/maxisbey/6123d132484e4c533eab519a2800693d
Claude Codehttps://claude.ai/code
maxisbeyhttps://github.com/maxisbey
completedhttps://github.com/modelcontextprotocol/python-sdk/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
on Oct 6, 2026https://github.com/modelcontextprotocol/python-sdk/issues/3605#event-32619410602
Sign up for freehttps://github.com/signup?return_to=https://github.com/modelcontextprotocol/python-sdk/issues/3605
Sign in to commenthttps://github.com/login?return_to=https://github.com/modelcontextprotocol/python-sdk/issues/3605
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.