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 摘要。