Title: Issue · GitHub
Open Graph Title: Issue · modelcontextprotocol/python-sdk
X Title: Issue · modelcontextprotocol/python-sdk
Description: The official Python SDK for Model Context Protocol servers and clients - Issue · modelcontextprotocol/python-sdk
Open Graph Description: The official Python SDK for Model Context Protocol servers and clients - Issue · modelcontextprotocol/python-sdk
X Description: The official Python SDK for Model Context Protocol servers and clients - Issue · modelcontextprotocol/python-sdk
Opengraph URL: https://github.com/modelcontextprotocol/python-sdk
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"401 in Streamable HTTP should be handled gracefully","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\nCurrently, `streamable_http` will call `response.raise_for_status()` when handling POST requests. [(ref)](https://github.com/modelcontextprotocol/python-sdk/blob/9a8592e7d4d69b785df8b5d9d7b694cb6cbb149f/src/mcp/client/streamable_http.py#L278).\n\nThis means that a 401 will bubble up and cause the entire program to crash. \n\nWhile a 401 on server initialize could warrant an exception, we have a use case where a MCP server will return 401 for specific unauthorized operations, and allow others.\n\nThis should be handled gracefully, similar to how [`_handle_unexpected_content_type`](https://github.com/modelcontextprotocol/python-sdk/blob/9a8592e7d4d69b785df8b5d9d7b694cb6cbb149f/src/mcp/client/streamable_http.py#L340C15-L340C46) works, returning a JSONRPC message outlining an unauthorized exception was thrown.\n\nThis would let an agent or other client handle it instead of crashing the program.\n\n\n### Python \u0026 MCP Python SDK\n\n```Text\nPython 3.12 and MCP SDK v1.13.1\n```","author":{"url":"https://github.com/somaraani","@type":"Person","name":"somaraani"},"datePublished":"2025-08-22T21:31:45.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/1295/python-sdk/issues/1295"}
| route-pattern | /:user_id/:repository/issues/:id(.:format) |
| route-controller | issues |
| route-action | show |
| fetch-nonce | v2:34b9e5c7-b5d9-86d6-c043-825fb51ea28f |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E7C6:E401C:573AFC:74B8F5:6A617A95 |
| html-safe-nonce | 601edabd46da6216f77c46e91d2f8e8edf1c08ea785d7bc87558ff7c748e9006 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFN0M2OkU0MDFDOjU3M0FGQzo3NEI4RjU6NkE2MTdBOTUiLCJ2aXNpdG9yX2lkIjoiNTgyNTExMTg0NTgwOTI1NzEwOSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 83ee89a467f5f2183aa72498119f57c2a39ce4965a295da8597eafec5bb25302 |
| hovercard-subject-tag | repository:862584018 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/modelcontextprotocol/python-sdk/issues/1295 |
| twitter:image | https://opengraph.githubassets.com/c422c15b5cb2da1d24a74f358d7a53dbcf8a86e98ab9f76dd884f8e784fd8d8e/modelcontextprotocol/python-sdk |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/c422c15b5cb2da1d24a74f358d7a53dbcf8a86e98ab9f76dd884f8e784fd8d8e/modelcontextprotocol/python-sdk |
| og:image:alt | The official Python SDK for Model Context Protocol servers and clients - Issue · modelcontextprotocol/python-sdk |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | b05bb6314e7e93021a7b7dab54a85cbe48d821938e762c1dff815efd60699622 |
| turbo-cache-control | no-cache |
| go-import | github.com/modelcontextprotocol/python-sdk git https://github.com/modelcontextprotocol/python-sdk.git |
| octolytics-dimension-user_id | 182288589 |
| octolytics-dimension-user_login | modelcontextprotocol |
| octolytics-dimension-repository_id | 862584018 |
| octolytics-dimension-repository_nwo | modelcontextprotocol/python-sdk |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 862584018 |
| octolytics-dimension-repository_network_root_nwo | modelcontextprotocol/python-sdk |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 94389bfdcd393b0a5a274aee94e8a9739d063fe5 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width