- 
                Notifications
    You must be signed in to change notification settings 
- Fork 2.7k
Closed
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
The changes in #1061 overwrite the incoming request object to async_auth_flow with the request returned by self._create_oauth_metadata_request(url).
                    discovery_urls = self._get_discovery_urls()
                    for url in discovery_urls:
                        request = self._create_oauth_metadata_request(url)
                        response = yield requestAfter the auth flow occurs and the (overwritten) request is made, the client tries to parse the result. But the result is OAuth metadata, not a JSONRPC response as expected.
Example errors:
2025-07-18 15:56:35,124 - ERROR - Error parsing JSON response
Traceback (most recent call last):
  File "/src/python/.venv/lib/python3.11/site-packages/mcp/client/streamable_http.py", line 302, in _handle_json_response
    message = JSONRPCMessage.model_validate_json(content)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/src/python/.venv/lib/python3.11/site-packages/pydantic/main.py", line 746, in model_validate_json
    return cls.__pydantic_validator__.validate_json(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pydantic_core._pydantic_core.ValidationError: 11 validation errors for JSONRPCMessage
JSONRPCRequest.method
  Field required [type=missing, input_value={'authorization_endpoint'...code', 'refresh_token']}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.11/v/missing
Example Code
Python & MCP Python SDK
MCP 1.12.0
LucaButBoring
Metadata
Metadata
Assignees
Labels
No labels