René's URL Explorer Experiment


Title: Http errors are not handled properly by streamable_http · Issue #1835 · modelcontextprotocol/python-sdk · GitHub

Open Graph Title: Http errors are not handled properly by streamable_http · Issue #1835 · modelcontextprotocol/python-sdk

X Title: Http errors are not handled properly by streamable_http · Issue #1835 · modelcontextprotocol/python-sdk

Description: Initial Checks I confirm that I'm using the latest version of MCP Python SDK I confirm that I searched for my issue in https://github.com/modelcontextprotocol/python-sdk/issues before opening this issue Description Description When using...

Open Graph Description: Initial Checks I confirm that I'm using the latest version of MCP Python SDK I confirm that I searched for my issue in https://github.com/modelcontextprotocol/python-sdk/issues before opening this ...

X Description: Initial Checks I confirm that I'm using the latest version of MCP Python SDK I confirm that I searched for my issue in https://github.com/modelcontextprotocol/python-sdk/issues before opening t...

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

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Http errors are not handled properly by streamable_http","articleBody":"### Initial Checks\n\n- [x] I confirm that I'm using the latest version of MCP Python SDK\n- [x] I confirm that I searched for my issue in https://github.com/modelcontextprotocol/python-sdk/issues before opening this issue\n\n### Description\n\n## Description\nWhen using Kiro-CLI with a remote fastMCP server, one issue was observed that when the MCP tool call gets a 403 http error, the cli would hang indefinitely instead of showing an error response.\n\n## Root Cause\nIn `mcp/client/streamable_http.py`, the `_handle_post_request()` method calls `response.raise_for_status()` but doesn't catch the resulting `httpx.HTTPStatusError` exception and convert it to an MCP error response. Without a response message, the client waits indefinitely.\n\n## Expected Behavior\nHTTP errors should be caught and converted to MCP JSON-RPC error responses so clients can handle them gracefully.\n\n## Proposed Fix\nWrap the `response.raise_for_status()` call in a try/except block that catches `httpx.HTTPStatusError` and:\n1. Creates a JSONRPCError with appropriate error details\n2. Sends it to the read stream so the client receives the error\n\nThe temporary patch that fixs the problem:\n~~~\n@wraps(original_handle_post_request)\n    async def _handle_post_request_patched(self, ctx: RequestContext) -\u003e None:  # type: ignore\n        \"\"\"Patched version of _handle_post_request that converts HTTP errors to MCP errors.\n        \n        This ensures that HTTP errors (like 403 Forbidden) during tool calls are properly\n        converted to MCP error messages and sent back to the client, preventing hangs.\n        \"\"\"\n        try:\n            return await original_handle_post_request(self, ctx)\n        except httpx.HTTPStatusError as http_error:\n            logger.warning('HTTP error in MCP client: %s %s', http_error.response.status_code, http_error.request.url)\n            \n            # Extract the request ID if this was a request (not a notification)\n            message = ctx.session_message.message\n            request_id = None\n            if isinstance(message.root, mcp.types.JSONRPCRequest):\n                request_id = message.root.id\n            \n            if request_id is not None:\n                # Try to parse the error response as an MCP error\n                response = http_error.response\n                try:\n                    await response.aread()\n                    error_body = response.json()\n                    error_message = error_body.get('message', f'HTTP {response.status_code} error')\n                except Exception:\n                    error_message = f'HTTP {response.status_code} error'\n                \n                # Create an MCP error response\n                jsonrpc_error = mcp.types.JSONRPCError(\n                    jsonrpc=\"2.0\",\n                    id=request_id,\n                    error=mcp.types.ErrorData(\n                        code=-32603,  # Internal error\n                        message=error_message\n                    )\n                )\n                \n                # Send the error to the read stream\n                session_message = SessionMessage(mcp.types.JSONRPCMessage(jsonrpc_error))\n                await ctx.read_stream_writer.send(session_message)\n                logger.info('Sent MCP error response for HTTP %s', response.status_code)\n            else:\n                # For notifications, just log the error\n                logger.debug('HTTP error for notification (no response sent): %s', http_error)\n\n    StreamableHTTPTransport._handle_post_request = _handle_post_request_patched\n    logger.info('Successfully patched MCP client StreamableHTTPTransport._handle_post_request')\n~~~\n\n### Python \u0026 MCP Python SDK\n\n```Text\npython: 3.10.0\nMCP SDK: 1.25.0\n```","author":{"url":"https://github.com/yuxiaorun","@type":"Person","name":"yuxiaorun"},"datePublished":"2026-01-06T18:53:41.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/1835/python-sdk/issues/1835"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:dd84750e-7903-e7a4-b2e5-32d0dc37d49f
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idE818:240318:E570BF:14920F5:6A633018
html-safe-noncebabc732e43dc1c1cc31dece33119e40c58d507164a342fdfc202e617dfc50fd1
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFODE4OjI0MDMxODpFNTcwQkY6MTQ5MjBGNTo2QTYzMzAxOCIsInZpc2l0b3JfaWQiOiIxMDMzNzg1MDc1MDE1Mjk5MDk3IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmacc5595070206c5de3caab1afe763c73d0b159e134cee3dfe040b77e6c48d9444b
hovercard-subject-tagissue:3786173755
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/1835/issue_layout
twitter:imagehttps://opengraph.githubassets.com/68962fc9c5acbd874705180ce0b7adcf3ab0d1bc7e98007f5254fd872fb4cc55/modelcontextprotocol/python-sdk/issues/1835
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/68962fc9c5acbd874705180ce0b7adcf3ab0d1bc7e98007f5254fd872fb4cc55/modelcontextprotocol/python-sdk/issues/1835
og:image:altInitial Checks I confirm that I'm using the latest version of MCP Python SDK I confirm that I searched for my issue in https://github.com/modelcontextprotocol/python-sdk/issues before opening this ...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameyuxiaorun
hostnamegithub.com
expected-hostnamegithub.com
Nonedf6e1c2adcceb061ec8c4106a1b34f38280f08e13f2b195c661c202834cbc3b1
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
release822a0ff2a479845adcdd40a1a7b1734a56e05818
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/modelcontextprotocol/python-sdk/issues/1835#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmodelcontextprotocol%2Fpython-sdk%2Fissues%2F1835
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%2Fissues%2F1835
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%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=modelcontextprotocol%2Fpython-sdk
Reloadhttps://github.com/modelcontextprotocol/python-sdk/issues/1835
Reloadhttps://github.com/modelcontextprotocol/python-sdk/issues/1835
Reloadhttps://github.com/modelcontextprotocol/python-sdk/issues/1835
Please reload this pagehttps://github.com/modelcontextprotocol/python-sdk/issues/1835
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 270 https://github.com/modelcontextprotocol/python-sdk/issues
Pull requests 317 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
Http errors are not handled properly by streamable_httphttps://github.com/modelcontextprotocol/python-sdk/issues/1835#top
https://github.com/yuxiaorun
yuxiaorunhttps://github.com/yuxiaorun
on Jan 6, 2026https://github.com/modelcontextprotocol/python-sdk/issues/1835#issue-3786173755
https://github.com/modelcontextprotocol/python-sdk/issueshttps://github.com/modelcontextprotocol/python-sdk/issues
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.