-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Open
Labels
needs confirmationNeeds confirmation that the PR is actually required or needed.Needs confirmation that the PR is actually required or needed.
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
Currently, streamable_http
will call response.raise_for_status()
when handling POST requests. (ref).
This means that a 401 will bubble up and cause the entire program to crash.
While 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.
This should be handled gracefully, similar to how _handle_unexpected_content_type
works, returning a JSONRPC message outlining an unauthorized exception was thrown.
This would let an agent or other client handle it instead of crashing the program.
Python & MCP Python SDK
Python 3.12 and MCP SDK v1.13.1
Metadata
Metadata
Assignees
Labels
needs confirmationNeeds confirmation that the PR is actually required or needed.Needs confirmation that the PR is actually required or needed.