modelcontextprotocol / modelcontextprotocol/python-sdk
[v2] Add an end-to-end public-client PKCE server contract
Nessuno ha ancora preso questa issue.
- Lingua principale
- Python
- Stelle
- 24.3k
- Fork
- 4k
- Merge medio
- 1g 1h
- PR unite (30g)
- 31
Descrizione
What happened?
With mcp==2.1.1, an MCP authorization server still cannot advertise and register an OAuth public client consistently without downstream patching:
build_metadata()does not includenoneintoken_endpoint_auth_methods_supported.RegistrationHandlerdefaults an omittedtoken_endpoint_auth_methodtoclient_secret_post, minting a secret even for clients intending to operate as PKCE public clients.- The individual token handler pieces support
token_endpoint_auth_method="none"when it is explicitly supplied, but there is no end-to-end SDK test pinning discovery -> DCR -> authorization-code/PKCE token exchange for a public client.
This is related to #2260, which was closed, and #2261, which remains open. The inconsistency is still present in the published v2 SDK.
For a real MCP server integration, we currently have to monkeypatch metadata generation and DCR's omitted-method behavior at import time. Those patches depend on private implementation details and are difficult to remove safely without a supported end-to-end public-client contract.
What did you expect?
The v2 server auth surface should support a complete public-client PKCE flow without monkeypatching:
- Authorization-server metadata advertises
none. - DCR preserves an explicit
token_endpoint_auth_method="none"and has a documented, interoperable default for omitted methods. - The token endpoint accepts the registered public client without a client secret and verifies the PKCE
code_verifieragainst the authorization code's challenge. - An SDK integration test covers the full flow so future releases do not regress it.
Merging or superseding #2261 plus adding the end-to-end test would provide a clear downstream exit condition.
Code to reproduce
from mcp.server.auth.handlers.register import RegistrationHandler
from mcp.server.auth.routes import build_metadata
# In mcp==2.1.1:
# - build_metadata() omits "none" from token_endpoint_auth_methods_supported
# - RegistrationHandler.handle defaults an omitted token_endpoint_auth_method
# to "client_secret_post"
SDK version
2.1.1
Area
Auth
Related
- #2260
- #2261
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia con mcp.server.auth.routes.build_metadata e mcp.server.auth.handlers.register.RegistrationHandler, quindi segui i token handler per authorization code/PKCE e gli SDK auth test esistenti. Il lavoro è completo quando la discovery non pubblicizza alcun metodo, la registrazione gestisce in modo coerente i metodi espliciti e omessi, lo scambio del token verifica il PKCE code_verifier senza un secret e un test di integrazione end-to-end copre il flusso.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- python
- Ambito
- authentication, backend-api-design, security
- Tipo di issue
- Funzionalità
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Attiva
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 50/100