modelcontextprotocol / modelcontextprotocol/python-sdk

ClientAuthenticator ignores token_endpoint_auth_method="none" when client_secret is stored

Open Beginner friendly
#1,842 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

auth bug needs confirmation needs decision P2
Dominant language
Python
Stars
24.3k
Forks
4k
Avg merge
1d 1h
Merged PRs (30d)
31

Description

Initial Checks
Description

ClientAuthenticator behavior is only partially honoring token_endpoint_auth_method="none":

https://github.com/modelcontextprotocol/python-sdk/blob/6b69f6354ad01e08abc8e1b81390c3a45132f594/src/mcp/server/auth/middleware/client_auth.py#L102-L104

Essentially:

  • token_endpoint_auth_method="none" => skip extracting credentials from the request (correct)
  • client.client_secret exists => raise error if no credentials were extracted from the request (incorrect)

If token_endpoint_auth_method="none" is set, it should never be checking for a client_secret value on the request, regardless of whether a secret has ever been generated for the client.

Suggested fix is to condition the client.client_secret check on token_endpoint_auth_method not being none:

        if token_endpoint_auth_method != "none" and client.client_secret:  # pragma: no branch
            if not request_client_secret:
                raise AuthenticationError("Client secret is required")  # pragma: no cover
Example Code

Python & MCP Python SDK
1.25.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/server/auth/middleware/client_auth.py at the linked ClientAuthenticator logic. Reproduce the case where token_endpoint_auth_method is none while a client secret is stored, then verify that request credentials are not required for this method and that other methods retain their checks. Add or update the relevant authentication test to cover the behavior.

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
Quiet
Clarity
Clearly specified
Newbie friendliness
72/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.