René's URL Explorer Experiment


Title: fix: preserve HTTP status codes in streamable HTTP transport error responses by giulio-leone · Pull Request #2176 · modelcontextprotocol/python-sdk · GitHub

Open Graph Title: fix: preserve HTTP status codes in streamable HTTP transport error responses by giulio-leone · Pull Request #2176 · modelcontextprotocol/python-sdk

X Title: fix: preserve HTTP status codes in streamable HTTP transport error responses by giulio-leone · Pull Request #2176 · modelcontextprotocol/python-sdk

Description: Problem The streamable HTTP transport has two error propagation issues that cause clients to hang or receive uninformative error messages: 1. HTTP status codes are discarded in error responses Non-2xx responses produce generic error messages that lose the original HTTP status: 404 → ErrorData(code=INVALID_REQUEST, message="Session terminated") 401/403/500/... → ErrorData(code=INTERNAL_ERROR, message="Server returned an error response") Callers cannot distinguish auth errors (401/403) from server errors (500) or other failures. 2. Transport errors cause caller to hang Connection-level errors (timeouts, DNS failures, refused connections) raised inside _handle_post_request are not caught. When called via tg.start_soon() for JSONRPCRequest messages, the exception propagates to the task group but no JSONRPCError is written to the read stream — the caller blocks indefinitely. Fix Status code preservation Consolidated the separate 404 and >= 400 handlers into a single block that: Reads the response body for error detail Includes HTTP {status}: {body} in the error message Transport error propagation Wrapped _handle_post_request in a try/except that: Catches any exception during the HTTP request Sends a JSONRPCError through the read_stream_writer so the caller gets an error instead of hanging Re-raises the exception so the task group can handle it Test 13 fast tests pass (validation, JSON response, content type, session), 2 consecutive clean runs. Integration tests not affected (verified test_streamable_http_client_json_response passes). Fixes #2110

Open Graph Description: Problem The streamable HTTP transport has two error propagation issues that cause clients to hang or receive uninformative error messages: 1. HTTP status codes are discarded in error responses Non-...

X Description: Problem The streamable HTTP transport has two error propagation issues that cause clients to hang or receive uninformative error messages: 1. HTTP status codes are discarded in error responses Non-...

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

X: @github

direct link

Domain: github.com

IPv4 address: 140.82.114.3

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/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:4c2ff99f-074e-60ae-9444-d89ca30c3ef7
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idBB36:2E654B:1B8D04E:249F055:6B0575F3
html-safe-noncee916ac6a6231aff7763782949d321bdab349a51a638402aeacef225cf0a6568a
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCQjM2OjJFNjU0QjoxQjhEMDRFOjI0OUYwNTU6NkIwNTc1RjMiLCJ2aXNpdG9yX2lkIjoiMjMxMTE0NDM4MjYxMTc1Nzk1IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmace55706c5bf19e5d46549c4aa1ab33c61551605fee76965d141234e6dc08706e3
hovercard-subject-tagpull_request:3338597659
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/2176/files
twitter:imagehttps://avatars.githubusercontent.com/u/6887247?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/6887247?s=400&v=4
og:image:altProblem The streamable HTTP transport has two error propagation issues that cause clients to hang or receive uninformative error messages: 1. HTTP status codes are discarded in error responses Non-...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None507b2d62524c0f595c35a2a2ee8a6ec54b119f245b3c59eaa070013b70ed1ada
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
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
releasee7a883ae3b439b8952652eaa7803e2587f30e339
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/modelcontextprotocol/python-sdk/pull/2176/files#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmodelcontextprotocol%2Fpython-sdk%2Fpull%2F2176%2Ffiles
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%2Fpull%2F2176%2Ffiles
Sign uphttps://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/2176/files
Reloadhttps://github.com/modelcontextprotocol/python-sdk/pull/2176/files
Reloadhttps://github.com/modelcontextprotocol/python-sdk/pull/2176/files
modelcontextprotocolhttps://github.com/modelcontextprotocol
python-sdkhttps://github.com/modelcontextprotocol/python-sdk
Codehttps://github.com/modelcontextprotocol/python-sdk
Issues320 (320)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
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
giulio-leonehttps://github.com/giulio-leone
modelcontextprotocol:mainhttps://github.com/modelcontextprotocol/python-sdk/tree/main
Conversation 1 https://github.com/modelcontextprotocol/python-sdk/pull/2176
Commits 2 https://github.com/modelcontextprotocol/python-sdk/pull/2176/commits
Checks 26 https://github.com/modelcontextprotocol/python-sdk/pull/2176/checks
Files changed https://github.com/modelcontextprotocol/python-sdk/pull/2176/files
Please reload this pagehttps://github.com/modelcontextprotocol/python-sdk/pull/2176/files
fix: preserve HTTP status codes in streamable HTTP transport error responses https://github.com/modelcontextprotocol/python-sdk/pull/2176/files#top
Show all changes 2 commits https://github.com/modelcontextprotocol/python-sdk/pull/2176/files
088c67b fix: preserve HTTP status codes in streamable HTTP transport error re… giulio-leone Feb 28, 2026 https://github.com/modelcontextprotocol/python-sdk/pull/2176/commits/088c67bd5af81f300d9f9a6d7cdc2f04cea86bf3
0176b50 style: apply ruff format giulio-leone Feb 28, 2026 https://github.com/modelcontextprotocol/python-sdk/pull/2176/commits/0176b50f8932c266b0321030c658191f5b8d7f5e
Clear filters https://github.com/modelcontextprotocol/python-sdk/pull/2176/files
Please reload this pagehttps://github.com/modelcontextprotocol/python-sdk/pull/2176/files
Please reload this pagehttps://github.com/modelcontextprotocol/python-sdk/pull/2176/files
src/mcp/client/streamable_http.pyhttps://github.com/modelcontextprotocol/python-sdk/pull/2176/files#diff-e8c18a3067a9b157c5c39a947f53d395afeb00e7026dad2d5a279011da943b5e
View file https://github.com/modelcontextprotocol/python-sdk/blob/0176b50f8932c266b0321030c658191f5b8d7f5e/src/mcp/client/streamable_http.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/modelcontextprotocol/python-sdk/pull/2176/{{ revealButtonHref }}
https://github.com/modelcontextprotocol/python-sdk/pull/2176/files#diff-e8c18a3067a9b157c5c39a947f53d395afeb00e7026dad2d5a279011da943b5e
https://github.com/modelcontextprotocol/python-sdk/pull/2176/files#diff-e8c18a3067a9b157c5c39a947f53d395afeb00e7026dad2d5a279011da943b5e
Please reload this pagehttps://github.com/modelcontextprotocol/python-sdk/pull/2176/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

Response headers:
Servergithub.com
Content-Typetext/html; charset=utf-8
Cache-Controlno-cache

Viewport: width=device-width


URLs of crawlers that visited me.