René's URL Explorer Experiment


Title: streamable_http: HTTP status errors (401/403/5xx) on tools/list, tools/call never reach the caller — indistinguishable from a timeout · Issue #3091 · modelcontextprotocol/python-sdk · GitHub

Open Graph Title: streamable_http: HTTP status errors (401/403/5xx) on tools/list, tools/call never reach the caller — indistinguishable from a timeout · Issue #3091 · modelcontextprotocol/python-sdk

X Title: streamable_http: HTTP status errors (401/403/5xx) on tools/list, tools/call never reach the caller — indistinguishable from a timeout · Issue #3091 · modelcontextprotocol/python-sdk

Description: Description StreamableHTTPTransport._handle_post_request never notifies the caller of a specific pending request when the server returns a non-2xx status (e.g. 401/403). Instead of surfacing as an error to that request, the caller only e...

Open Graph Description: Description StreamableHTTPTransport._handle_post_request never notifies the caller of a specific pending request when the server returns a non-2xx status (e.g. 401/403). Instead of surfacing as an ...

X Description: Description StreamableHTTPTransport._handle_post_request never notifies the caller of a specific pending request when the server returns a non-2xx status (e.g. 401/403). Instead of surfacing as an ...

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

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"streamable_http: HTTP status errors (401/403/5xx) on tools/list, tools/call never reach the caller — indistinguishable from a timeout","articleBody":"## Description\n\n`StreamableHTTPTransport._handle_post_request` never notifies the caller of a specific pending request when the server returns a non-2xx status (e.g. 401/403). Instead of surfacing as an error to that request, the caller only ever observes a read timeout — indistinguishable from a genuinely slow/dead server.\n\n## Root cause (two-level gap)\n\n**1. Missing error path in `_handle_post_request`** (`src/mcp/client/streamable_http.py`):\n\n```python\nasync with ctx.client.stream(\"POST\", self.url, ...) as response:\n    if response.status_code == 202:\n        ...\n        return\n    if response.status_code == 404:\n        ...\n        return\n    response.raise_for_status()   # \u003c-- no try/except around this\n    ...\n```\n\nCompare to its sibling `_handle_json_response` a few lines below, which *does* wrap its work in `try`/`except` and forwards the failure:\n\n```python\nasync def _handle_json_response(self, response, read_stream_writer, is_initialization=False):\n    try:\n        content = await response.aread()\n        message = JSONRPCMessage.model_validate_json(content)\n        ...\n        await read_stream_writer.send(session_message)\n    except Exception as exc:\n        logger.exception(\"Error parsing JSON response\")\n        await read_stream_writer.send(exc)\n```\n\n`_handle_post_request`'s `raise_for_status()` failure has no equivalent — it propagates out of the fire-and-forget task spawned via `tg.start_soon(handle_request_async)` in `post_writer`, uncaught, with no attempt to notify the specific pending request.\n\n**2. Even the \"obvious\" fix doesn't work, because of how `read_stream` is consumed.** I patched in a `try`/`except httpx.HTTPStatusError` around `raise_for_status()` that forwards the exception via `await ctx.read_stream_writer.send(exc)`, mirroring `_handle_json_response`'s pattern exactly. It made no observable difference to callers.\n\nLooking at `BaseSession._receive_loop` (`src/mcp/shared/session.py`):\n\n```python\nasync for message in self._read_stream:\n    if isinstance(message, Exception):\n        await self._handle_incoming(message)\n    elif isinstance(message.message.root, JSONRPCRequest):\n        ...\n    elif isinstance(message.message.root, JSONRPCNotification):\n        ...\n    else:  # Response or error\n        await self._handle_response(message)\n```\n\nA bare `Exception` on the read stream is routed to `_handle_incoming` — a generic side-channel for unsolicited connection-level issues. Only the `else` branch (`_handle_response`) resolves the specific pending future in `self._response_streams[request_id]` that the original caller is `await`-ing on. Since a bare exception carries no request id, it can never reach `_handle_response`, so the caller's pending request is never resolved by this path either — it can only ever time out.\n\nA real fix needs `_handle_post_request` to construct a proper `JSONRPCError` (carrying the *original request's* id) on an HTTP-status failure and route it through the normal response channel, the same way request-validation failures are already handled inside `BaseSession._receive_loop`:\n\n```python\nerror_response = JSONRPCError(\n    jsonrpc=\"2.0\",\n    id=message.message.root.id,\n    error=ErrorData(code=..., message=..., data=...),\n)\nsession_message = SessionMessage(message=JSONRPCMessage(error_response))\nawait self._write_stream.send(session_message)\n```\n\n## Why it matters\n\nAny client that wants to distinguish \"the server rejected this call\" (e.g. expired/invalid credentials — should fail fast, non-retryable) from \"the server is slow/unreachable\" (should retry) cannot do so over streamable HTTP: both degrade identically as a timeout. We hit this building a Temporal-based SDK that reclassifies MCP failures into a retryable/non-retryable degradation contract — a 401 currently retries `maximum_attempts` times and only then degrades as a *transient* failure, burning retries on what should be an immediate non-retryable auth failure.\n\n## Repro\n\nPoint an `MCPServerStreamableHTTP`/`MCPToolset` client at a server that returns HTTP 401 for `tools/list` or `tools/call`. Observe:\n- No `httpx.HTTPStatusError` (or any status-carrying exception) ever reaches the caller.\n- The caller's `await` only resolves once its own read timeout elapses.\n- The eventual exception (a bare timeout) is indistinguishable from a real 504/slow-server case.\n\n## Environment\n\n- `mcp` 1.25.0 / 1.28.1 (installed via `fastmcp`, which pins `mcp\u003c2.0`)\n- Confirmed via source inspection of `mcp/client/streamable_http.py` and `mcp/shared/session.py`, and via two targeted patch experiments (see root cause above) — not yet checked against the `mcp` 2.0 beta line.\n\nHappy to help test a fix or discuss further.\n","author":{"url":"https://github.com/afterrburn","@type":"Person","name":"afterrburn"},"datePublished":"2026-07-13T19:03:59Z","url":"https://github.com/modelcontextprotocol/python-sdk/issues/3091"}

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:ad5e31a0-939c-af99-045e-706c1cf93ab4
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idE202:1F7384:11F84D7:17C5C97:6B011747
html-safe-nonced839a8cf979c654c2f97b4e82f807d0bace218c6a36387c87845c261a2a6b6cf
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFMjAyOjFGNzM4NDoxMUY4NEQ3OjE3QzVDOTc6NkIwMTE3NDciLCJ2aXNpdG9yX2lkIjoiMjM3MjIxMDM1MzIwMDI0MDQ1NSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmacb2a58490320a8c298e628ff8a545c2956478fff59080c23a00421f98dfcbf86c
hovercard-subject-tagissue:4876745685
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/3091/issue_layout
twitter:imagehttps://opengraph.githubassets.com/6271ff754d1118824535e58f32504510739a8902ebbfc1001348e39af3d97dac/modelcontextprotocol/python-sdk/issues/3091
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/6271ff754d1118824535e58f32504510739a8902ebbfc1001348e39af3d97dac/modelcontextprotocol/python-sdk/issues/3091
og:image:altDescription StreamableHTTPTransport._handle_post_request never notifies the caller of a specific pending request when the server returns a non-2xx status (e.g. 401/403). Instead of surfacing as an ...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameafterrburn
hostnamegithub.com
expected-hostnamegithub.com
Nonecc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c
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
release8c77c9e8439031ad54c75a250694842892f693e1
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/modelcontextprotocol/python-sdk/issues/3091#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmodelcontextprotocol%2Fpython-sdk%2Fissues%2F3091
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%2F3091
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/3091
Reloadhttps://github.com/modelcontextprotocol/python-sdk/issues/3091
Reloadhttps://github.com/modelcontextprotocol/python-sdk/issues/3091
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/3091
New issuehttps://github.com/login?return_to=https://github.com/modelcontextprotocol/python-sdk/issues/3091
streamable_http: HTTP status errors (401/403/5xx) on tools/list, tools/call never reach the caller — indistinguishable from a timeouthttps://github.com/modelcontextprotocol/python-sdk/issues/3091#top
https://github.com/afterrburn
afterrburnhttps://github.com/afterrburn
on Jul 13, 2026https://github.com/modelcontextprotocol/python-sdk/issues/3091#issue-4876745685
https://github.com/Ben-Home
Ben-Homehttps://github.com/Ben-Home
on Jul 13, 2026https://github.com/modelcontextprotocol/python-sdk/issues/3091#issuecomment-4962292707
https://github.com/himanshu-commits
himanshu-commitshttps://github.com/himanshu-commits
on Jul 13, 2026https://github.com/modelcontextprotocol/python-sdk/issues/3091#issuecomment-4962925967
@afterrburnhttps://github.com/afterrburn
https://github.com/afterrburn
afterrburnhttps://github.com/afterrburn
on Jul 13, 2026https://github.com/modelcontextprotocol/python-sdk/issues/3091#issuecomment-4963153102
https://github.com/himanshu-commits
himanshu-commitshttps://github.com/himanshu-commits
on Jul 13, 2026https://github.com/modelcontextprotocol/python-sdk/issues/3091#issuecomment-4963484738
https://github.com/himanshu-commits
himanshu-commitshttps://github.com/himanshu-commits
on Jul 13, 2026https://github.com/modelcontextprotocol/python-sdk/issues/3091#issuecomment-4963780850
@afterrburnhttps://github.com/afterrburn
himanshu-commitshttps://github.com/himanshu-commits
on Jul 13, 2026https://github.com/modelcontextprotocol/python-sdk/issues/3091#event-27936256111
fix(client): catch read failures on the non-2xx bodyhttps://github.com/himanshu-commits/python-sdk/commit/a674d2ac2dbecb2aeff0837ed445fd0f2f99d865
a674d2ahttps://github.com/himanshu-commits/python-sdk/commit/a674d2ac2dbecb2aeff0837ed445fd0f2f99d865
https://github.com/zsxh1990
zsxh1990https://github.com/zsxh1990
on Jul 14, 2026https://github.com/modelcontextprotocol/python-sdk/issues/3091#issuecomment-4968956848
himanshu-commitshttps://github.com/himanshu-commits
on Jul 14, 2026https://github.com/modelcontextprotocol/python-sdk/issues/3091#event-27966734619
feat(client): carry the originating HTTP status in ErrorData.datahttps://github.com/himanshu-commits/python-sdk/commit/4c2c11a13b2453566857c41244f73afd2142f6c1
4c2c11ahttps://github.com/himanshu-commits/python-sdk/commit/4c2c11a13b2453566857c41244f73afd2142f6c1
https://github.com/himanshu-commits
himanshu-commitshttps://github.com/himanshu-commits
on Jul 14, 2026https://github.com/modelcontextprotocol/python-sdk/issues/3091#issuecomment-4970277395
#3092https://github.com/modelcontextprotocol/python-sdk/pull/3092
#3094https://github.com/modelcontextprotocol/python-sdk/pull/3094
fix(client): surface non-2xx HTTP responses to the waiting caller #3092https://github.com/modelcontextprotocol/python-sdk/pull/3092
@afterrburnhttps://github.com/afterrburn
feat(client): carry the originating HTTP status in ErrorData.data #3094https://github.com/modelcontextprotocol/python-sdk/pull/3094
@afterrburnhttps://github.com/afterrburn
@afterrburnhttps://github.com/afterrburn
test: add tests for non-2xx HTTP status handling (fixes #3091) #3093https://github.com/modelcontextprotocol/python-sdk/pull/3093
@zsxh1990https://github.com/zsxh1990
https://github.com/maxisbey
maxisbeyhttps://github.com/maxisbey
on Aug 14, 2026https://github.com/modelcontextprotocol/python-sdk/issues/3091#issuecomment-5292546904
#2110https://github.com/modelcontextprotocol/python-sdk/issues/2110
#3094https://github.com/modelcontextprotocol/python-sdk/pull/3094
#2110https://github.com/modelcontextprotocol/python-sdk/issues/2110
#2110https://github.com/modelcontextprotocol/python-sdk/issues/2110
AI Disclaimerhttps://gist.github.com/maxisbey/6123d132484e4c533eab519a2800693d
maxisbeyhttps://github.com/maxisbey
not plannedhttps://github.com/modelcontextprotocol/python-sdk/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Anot-planned
on Aug 14, 2026https://github.com/modelcontextprotocol/python-sdk/issues/3091#event-29453899249
Sign up for freehttps://github.com/signup?return_to=https://github.com/modelcontextprotocol/python-sdk/issues/3091
Sign in to commenthttps://github.com/login?return_to=https://github.com/modelcontextprotocol/python-sdk/issues/3091
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.