René's URL Explorer Experiment


Title: fix: propagate HTTP errors from transports instead of silently logging by MaxwellCalkin · Pull Request #2249 · modelcontextprotocol/python-sdk · GitHub

Open Graph Title: fix: propagate HTTP errors from transports instead of silently logging by MaxwellCalkin · Pull Request #2249 · modelcontextprotocol/python-sdk

X Title: fix: propagate HTTP errors from transports instead of silently logging by MaxwellCalkin · Pull Request #2249 · modelcontextprotocol/python-sdk

Description: Note: This PR was authored by Claude (AI), operated by @MaxwellCalkin. Summary Fixes #2110 When an MCP server returns non-2xx HTTP status codes (401/403/404/5xx), the Streamable HTTP and SSE transports silently log the error but don't propagate it to the caller. The caller hangs indefinitely waiting for a response on the read stream. Changes New HttpError exception class (src/mcp/shared/exceptions.py): Preserves the original HTTP status code is_auth_error property to distinguish 401/403 from other failures Optional body field for response body context Exported from the top-level mcp package Streamable HTTP transport (src/mcp/client/streamable_http.py): _handle_post_request: 401/403 responses now raise HttpError (in addition to sending a JSONRPCError for request messages), so the caller gets an exception instead of hanging _handle_post_request: Generic 4xx/5xx responses also raise HttpError instead of silently returning _handle_post_request: HTTP 404 error message now includes "(HTTP 404)" and data={"http_status": 404} to preserve HTTP-level context _handle_post_request: All error responses include data={"http_status": } in the JSONRPCError post_writer: handle_request_async now wraps calls in try/except and forwards exceptions through read_stream_writer.send(exc) so callers don't hang post_writer: Outer exception handler also forwards errors through the read stream SSE transport (src/mcp/client/sse.py): post_writer: 401/403 responses detected before raise_for_status() and forwarded as HttpError through the read stream post_writer: httpx.HTTPStatusError from raise_for_status() converted to HttpError and forwarded through the read stream post_writer: Generic exceptions forwarded through the read stream instead of being silently logged Before # Caller hangs forever waiting for a response that will never come async with streamable_http_client("https://example.com/mcp") as (read, write): await write.send(SessionMessage(request)) response = await read.receive() # blocks indefinitely on 401/403/5xx After # Caller receives an HttpError exception through the read stream async with streamable_http_client("https://example.com/mcp") as (read, write): await write.send(SessionMessage(request)) response = await read.receive() # receives HttpError or JSONRPCError with http_status # Or catch it directly from mcp.shared.exceptions import HttpError try: ... except HttpError as e: if e.is_auth_error: print(f"Auth failed: {e.status_code}") Test plan Verify existing tests pass (no behavioral change for 2xx responses) Verify 401/403 responses raise HttpError with is_auth_error == True Verify 404 responses include HTTP status in error data Verify 5xx responses raise HttpError and don't cause caller to hang Verify HttpError is importable from mcp top-level package

Open Graph Description: Note: This PR was authored by Claude (AI), operated by @MaxwellCalkin. Summary Fixes #2110 When an MCP server returns non-2xx HTTP status codes (401/403/404/5xx), the Streamable HTTP and SSE transp...

X Description: Note: This PR was authored by Claude (AI), operated by @MaxwellCalkin. Summary Fixes #2110 When an MCP server returns non-2xx HTTP status codes (401/403/404/5xx), the Streamable HTTP and SSE transp...

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

X: @github

direct link

Domain: github.com

route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:6c3784e9-e93f-eed8-42c9-44a19d74b700
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idB1A6:3DA5AD:1C25AC7:292F7F5:6A60B65E
html-safe-noncef91c8de6023596510073c777ed841093278cd074ed86c675162e815aa1f7142c
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCMUE2OjNEQTVBRDoxQzI1QUM3OjI5MkY3RjU6NkE2MEI2NUUiLCJ2aXNpdG9yX2lkIjoiNzg0NjcyMTA0MDQyOTM5NzU5OCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac24f7671b85029de0894cbdc0d7a8c37b93ebc9a121a8c3246e599dfc423b1517
hovercard-subject-tagpull_request:3369387394
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/2249/files
twitter:imagehttps://avatars.githubusercontent.com/u/101308415?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/101308415?s=400&v=4
og:image:altNote: This PR was authored by Claude (AI), operated by @MaxwellCalkin. Summary Fixes #2110 When an MCP server returns non-2xx HTTP status codes (401/403/404/5xx), the Streamable HTTP and SSE transp...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None35671f8a6946a7a2a81d51ae49f5465bdc5f925c23c9cb839206b24345dbe8d9
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
release746dc49090e6e3995bb502dce0f8807393e36eda
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/modelcontextprotocol/python-sdk/pull/2249/files#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmodelcontextprotocol%2Fpython-sdk%2Fpull%2F2249%2Ffiles
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub Copilot appDirect agents from issue to mergehttps://github.com/features/ai/github-app
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
Code QualityEnforce quality at mergehttps://github.com/features/code-quality
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
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
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
View all resourceshttps://github.com/resources
GitHub SponsorsFund open source developershttps://github.com/open-source/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/open-source/accelerator
GitHub Starshttps://stars.github.com
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://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
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmodelcontextprotocol%2Fpython-sdk%2Fpull%2F2249%2Ffiles
Sign up https://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/2249/files
Reloadhttps://github.com/modelcontextprotocol/python-sdk/pull/2249/files
Reloadhttps://github.com/modelcontextprotocol/python-sdk/pull/2249/files
Please reload this pagehttps://github.com/modelcontextprotocol/python-sdk/pull/2249/files
modelcontextprotocol https://github.com/modelcontextprotocol
python-sdkhttps://github.com/modelcontextprotocol/python-sdk
Notifications https://github.com/login?return_to=%2Fmodelcontextprotocol%2Fpython-sdk
Fork 3.7k https://github.com/login?return_to=%2Fmodelcontextprotocol%2Fpython-sdk
Star 23.7k https://github.com/login?return_to=%2Fmodelcontextprotocol%2Fpython-sdk
Code https://github.com/modelcontextprotocol/python-sdk
Issues 267 https://github.com/modelcontextprotocol/python-sdk/issues
Pull requests 312 https://github.com/modelcontextprotocol/python-sdk/pulls
Actions https://github.com/modelcontextprotocol/python-sdk/actions
Projects https://github.com/modelcontextprotocol/python-sdk/projects
Models https://github.com/modelcontextprotocol/python-sdk/models
Security and quality 6 https://github.com/modelcontextprotocol/python-sdk/security
Insights https://github.com/modelcontextprotocol/python-sdk/pulse
Code https://github.com/modelcontextprotocol/python-sdk
Issues https://github.com/modelcontextprotocol/python-sdk/issues
Pull requests https://github.com/modelcontextprotocol/python-sdk/pulls
Actions https://github.com/modelcontextprotocol/python-sdk/actions
Projects https://github.com/modelcontextprotocol/python-sdk/projects
Models https://github.com/modelcontextprotocol/python-sdk/models
Security and quality https://github.com/modelcontextprotocol/python-sdk/security
Insights https://github.com/modelcontextprotocol/python-sdk/pulse
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
MaxwellCalkinhttps://github.com/MaxwellCalkin
modelcontextprotocol:mainhttps://github.com/modelcontextprotocol/python-sdk/tree/main
MaxwellCalkin:fix/http-error-propagationhttps://github.com/MaxwellCalkin/python-sdk/tree/fix/http-error-propagation
Conversation 5 https://github.com/modelcontextprotocol/python-sdk/pull/2249
Commits 4 https://github.com/modelcontextprotocol/python-sdk/pull/2249/commits
Checks 28 https://github.com/modelcontextprotocol/python-sdk/pull/2249/checks
Files changed https://github.com/modelcontextprotocol/python-sdk/pull/2249/files
Please reload this pagehttps://github.com/modelcontextprotocol/python-sdk/pull/2249/files
fix: propagate HTTP errors from transports instead of silently logging https://github.com/modelcontextprotocol/python-sdk/pull/2249/files#top
Show all changes 4 commits https://github.com/modelcontextprotocol/python-sdk/pull/2249/files
642ca88 fix: add HttpError exception class for HTTP error propagation MaxwellCalkin Mar 8, 2026 https://github.com/modelcontextprotocol/python-sdk/pull/2249/commits/642ca880eac5d94e7cb00b3dffbb2595d28b22ac
7605dfd fix: propagate HTTP errors in StreamableHTTP transport instead of sil… MaxwellCalkin Mar 8, 2026 https://github.com/modelcontextprotocol/python-sdk/pull/2249/commits/7605dfdce48c04d4c808bcd016783123bca89393
7d60257 fix: propagate HTTP errors in SSE transport instead of silently logging MaxwellCalkin Mar 8, 2026 https://github.com/modelcontextprotocol/python-sdk/pull/2249/commits/7d602574139d1abd278f01d01968d799ea3a9b1d
715d47d fix: export HttpError from mcp package MaxwellCalkin Mar 8, 2026 https://github.com/modelcontextprotocol/python-sdk/pull/2249/commits/715d47d2397a0658e55112bbf3d7fdc5d9910f52
Clear filters https://github.com/modelcontextprotocol/python-sdk/pull/2249/files
Please reload this pagehttps://github.com/modelcontextprotocol/python-sdk/pull/2249/files
Please reload this pagehttps://github.com/modelcontextprotocol/python-sdk/pull/2249/files
__init__.py https://github.com/modelcontextprotocol/python-sdk/pull/2249/files#diff-208c9cff9cd42bad47f1042db6861d931673ca78db6de12bd4d8f65885f8f126
sse.py https://github.com/modelcontextprotocol/python-sdk/pull/2249/files#diff-41ed2e8548ae223801c0a37a6b50ce913e24f0e660bbbc2ddd91686820c86336
streamable_http.py https://github.com/modelcontextprotocol/python-sdk/pull/2249/files#diff-e8c18a3067a9b157c5c39a947f53d395afeb00e7026dad2d5a279011da943b5e
exceptions.py https://github.com/modelcontextprotocol/python-sdk/pull/2249/files#diff-78c8edd9357c34d072f24eac006407d819a6743472714abaf9a3c915d9be9d8a
src/mcp/__init__.pyhttps://github.com/modelcontextprotocol/python-sdk/pull/2249/files#diff-208c9cff9cd42bad47f1042db6861d931673ca78db6de12bd4d8f65885f8f126
View file https://github.com/MaxwellCalkin/python-sdk/blob/715d47d2397a0658e55112bbf3d7fdc5d9910f52/src/mcp/__init__.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/modelcontextprotocol/python-sdk/pull/2249/{{ revealButtonHref }}
https://github.com/modelcontextprotocol/python-sdk/pull/2249/files#diff-208c9cff9cd42bad47f1042db6861d931673ca78db6de12bd4d8f65885f8f126
https://github.com/modelcontextprotocol/python-sdk/pull/2249/files#diff-208c9cff9cd42bad47f1042db6861d931673ca78db6de12bd4d8f65885f8f126
https://github.com/modelcontextprotocol/python-sdk/pull/2249/files#diff-208c9cff9cd42bad47f1042db6861d931673ca78db6de12bd4d8f65885f8f126
https://github.com/modelcontextprotocol/python-sdk/pull/2249/files#diff-208c9cff9cd42bad47f1042db6861d931673ca78db6de12bd4d8f65885f8f126
src/mcp/client/sse.pyhttps://github.com/modelcontextprotocol/python-sdk/pull/2249/files#diff-41ed2e8548ae223801c0a37a6b50ce913e24f0e660bbbc2ddd91686820c86336
View file https://github.com/MaxwellCalkin/python-sdk/blob/715d47d2397a0658e55112bbf3d7fdc5d9910f52/src/mcp/client/sse.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/modelcontextprotocol/python-sdk/pull/2249/{{ revealButtonHref }}
https://github.com/modelcontextprotocol/python-sdk/pull/2249/files#diff-41ed2e8548ae223801c0a37a6b50ce913e24f0e660bbbc2ddd91686820c86336
https://github.com/modelcontextprotocol/python-sdk/pull/2249/files#diff-41ed2e8548ae223801c0a37a6b50ce913e24f0e660bbbc2ddd91686820c86336
https://github.com/modelcontextprotocol/python-sdk/pull/2249/files#diff-41ed2e8548ae223801c0a37a6b50ce913e24f0e660bbbc2ddd91686820c86336
Bortlesboathttps://github.com/Bortlesboat
Mar 9, 2026https://github.com/modelcontextprotocol/python-sdk/pull/2249/files#r2908152888
Learn morehttps://docs.github.com/articles/managing-disruptive-comments/#hiding-a-comment
Please reload this pagehttps://github.com/modelcontextprotocol/python-sdk/pull/2249/files
slykarhttps://github.com/slykar
Mar 11, 2026https://github.com/modelcontextprotocol/python-sdk/pull/2249/files#r2919709007
Learn morehttps://docs.github.com/articles/managing-disruptive-comments/#hiding-a-comment
#2273https://github.com/modelcontextprotocol/python-sdk/pull/2273
Please reload this pagehttps://github.com/modelcontextprotocol/python-sdk/pull/2249/files
https://github.com/modelcontextprotocol/python-sdk/pull/2249/files#diff-41ed2e8548ae223801c0a37a6b50ce913e24f0e660bbbc2ddd91686820c86336
src/mcp/client/streamable_http.pyhttps://github.com/modelcontextprotocol/python-sdk/pull/2249/files#diff-e8c18a3067a9b157c5c39a947f53d395afeb00e7026dad2d5a279011da943b5e
View file https://github.com/MaxwellCalkin/python-sdk/blob/715d47d2397a0658e55112bbf3d7fdc5d9910f52/src/mcp/client/streamable_http.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/modelcontextprotocol/python-sdk/pull/2249/{{ revealButtonHref }}
https://github.com/modelcontextprotocol/python-sdk/pull/2249/files#diff-e8c18a3067a9b157c5c39a947f53d395afeb00e7026dad2d5a279011da943b5e
https://github.com/modelcontextprotocol/python-sdk/pull/2249/files#diff-e8c18a3067a9b157c5c39a947f53d395afeb00e7026dad2d5a279011da943b5e
https://github.com/modelcontextprotocol/python-sdk/pull/2249/files#diff-e8c18a3067a9b157c5c39a947f53d395afeb00e7026dad2d5a279011da943b5e
Bortlesboathttps://github.com/Bortlesboat
Mar 9, 2026https://github.com/modelcontextprotocol/python-sdk/pull/2249/files#r2908152883
Learn morehttps://docs.github.com/articles/managing-disruptive-comments/#hiding-a-comment
Please reload this pagehttps://github.com/modelcontextprotocol/python-sdk/pull/2249/files
https://github.com/modelcontextprotocol/python-sdk/pull/2249/files#diff-e8c18a3067a9b157c5c39a947f53d395afeb00e7026dad2d5a279011da943b5e
https://github.com/modelcontextprotocol/python-sdk/pull/2249/files#diff-e8c18a3067a9b157c5c39a947f53d395afeb00e7026dad2d5a279011da943b5e
https://github.com/modelcontextprotocol/python-sdk/pull/2249/files#diff-e8c18a3067a9b157c5c39a947f53d395afeb00e7026dad2d5a279011da943b5e
src/mcp/shared/exceptions.pyhttps://github.com/modelcontextprotocol/python-sdk/pull/2249/files#diff-78c8edd9357c34d072f24eac006407d819a6743472714abaf9a3c915d9be9d8a
View file https://github.com/MaxwellCalkin/python-sdk/blob/715d47d2397a0658e55112bbf3d7fdc5d9910f52/src/mcp/shared/exceptions.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/modelcontextprotocol/python-sdk/pull/2249/{{ revealButtonHref }}
https://github.com/modelcontextprotocol/python-sdk/pull/2249/files#diff-78c8edd9357c34d072f24eac006407d819a6743472714abaf9a3c915d9be9d8a
https://github.com/modelcontextprotocol/python-sdk/pull/2249/files#diff-78c8edd9357c34d072f24eac006407d819a6743472714abaf9a3c915d9be9d8a
Please reload this pagehttps://github.com/modelcontextprotocol/python-sdk/pull/2249/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.