modelcontextprotocol / modelcontextprotocol/python-sdk
Revocation requires client_secret to be present
還沒有人認領這個 Issue。
- 主要語言
- Python
- 星號
- 24.3k
- 分支
- 4k
- 平均合併
- 1 天 1 小時
- 30 天內合併 PR
- 31
描述
Initial Checks
- I confirm that I'm using the newest release of my line (the latest 2.x, or the latest 1.x if I'm still on v1)
- I confirm that I searched for my issue in https://github.com/modelcontextprotocol/python-sdk/issues before opening this issue
Release line
2.x (current stable)
Description
What happened?
When Claude Code (or any other public client) triggers revocation - revoke handler requires client_secret to be present, as seen here:
Per OAuth 2.0 specifications (RFC 6749 Section 2.3 and RFC 7009 Section 5), public clients do not have a client_secret and identify themselves using only client_id.
This leads to issue when public clients do not sent client secret at all.
In Pydantic v2, defining a field as str | None without a default value still marks the field as required (i.e., nullable value, but the key must exist in the request body).
Steps to reproduce
- Authenticate using a public OAuth client (e.g., Claude Code CLI).
- Trigger token revocation (e.g., re-authenticating or logging out).
- The authorization server returns a
400 Bad Requestwith:
{"error":"invalid_request","error_description":"client_secret: Field required"}
Expected behavior
client_secret should be optional so public clients can revoke tokens without sending a client_secret key.
Fix
Adding default value for client_secret:
client_secret: str | None = None
Workaround
As workaround I'm overriding Request type:
from mcp.server.auth.handlers import revoke
class FixedRevocationRequest(revoke.RevocationRequest):
client_secret: str | None = None
revoke.RevocationRequest = FixedRevocationRequest
Example Code
from mcp.server.auth.handlers.revoke import RevocationRequest
from pydantic import ValidationError
# Simulate a public client request: client_secret parameter omitted entirely
form_no_secret = {"token": "abc", "client_id": "local-scurri-mcp"}
try:
req = RevocationRequest.model_validate(form_no_secret)
print("no-secret: OK ->", req)
except ValidationError as e:
print("no-secret: FAILS ->", e.errors()[0]["msg"])
Python & MCP Python SDK
MCP version: 2.2.0
Python version: 3.13.9
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
研究方向
從 src/mcp/server/auth/handlers/revoke.py 中的 RevocationRequest 開始,檢查相關的驗證行為。確認公用戶端的撤銷請求可以省略 client_secret,然後使用僅包含 token 和 client_id 的 Pydantic 範例來驗證驗證是否成功。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- python
- 領域
- authentication
- Issue 類型
- 缺陷
- 難度
- 1/5
- 預估耗時
- 1 小時以內
- 活躍度
- 活躍
- 描述清晰度
- 描述清楚
- 新手友好度
- 91/100