modelcontextprotocol / modelcontextprotocol/python-sdk

ClientAuthenticator ignores token_endpoint_auth_method="none" when client_secret is stored

未关闭 适合新手
#1,842 6 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

auth bug needs confirmation needs decision P2
主要语言
Python
星标
24.3k
派生
4k
平均合并
1 天 1 小时
30 天内合并 PR
31

描述

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

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

从 src/mcp/server/auth/middleware/client_auth.py 中链接的 ClientAuthenticator 逻辑开始。重现 token_endpoint_auth_method 为 none 且已存储客户端密钥的情况,然后验证此方法不要求请求凭据,并且其他方法仍保留其检查。添加或更新相关的身份验证测试,以覆盖此行为。

由索引模型根据 Issue 内容生成。

评估

技术栈
python
领域
authentication
Issue 类型
缺陷
难度
2/5
预计耗时
1-3 小时
活跃度
冷清
描述清晰度
描述清楚
新手友好度
72/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。