modelcontextprotocol / modelcontextprotocol/python-sdk

OAuthClientProvider._handle_token_response expect json

Open
#1,523 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

bug P2 ready for work
Dominant language
Python
Stars
24.3k
Forks
4k
Avg merge
1d 1h
Merged PRs (30d)
31

Description

Initial Checks
Description

https://github.com/modelcontextprotocol/python-sdk/blob/673423da0d6511127608df3d75360e47e99cb1f1/src/mcp/client/auth.py#L437
OAuthClientProvider._handle_token_response expects JSON, but doesn't specify this in the headers. If the server responds in a different format, an exception will be raised.

For example, https://docs.github.com/en/apps/oauth-apps/building-oauth-apps/authorizing-oauth-apps#2-users-are-redirected-back-to-your-site-by-github
access_token endpoint by default returns form-data and requires the Accept: application/json header to return json.

Example Code

Python & MCP Python SDK
python 3.11.9
mcp=1.16.0

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in src/mcp/client/auth.py at the _handle_token_response reference around line 437, then read the linked GitHub OAuth documentation about the access-token response format. Check how the provider handles the server response and verify completion by confirming the documented form-data response no longer raises an exception while JSON responses remain supported.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
authentication
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
58/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.