Extract OAuth flow logic into reusable components for proxy use cases
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Anfängerfreundlichkeit
- 25/100
- Issue-Typ
- Refactoring
- Klarheit
- Muss geklärt werden
- Aktivitätsstatus
- Ruhig
- Tech-Stack
- python, typescript
- Bereich
- authentication, backend-api-design
Rechercherichtung
Der Issue nennt keine Dateien oder Tests. Beginnen Sie damit, die bestehende OAuth-Implementierung und ihre Helfer für Discovery, Registrierung, interaktiven Ablauf, Token-Abruf und Speicherung zu finden, und sehen Sie sich anschließend #1240 sowie die Anforderungen der Maintainer an. Validieren Sie ein modulares, fortsetzbares Design mit TypeScript-Skizzen, bevor Sie die entsprechenden Python-Änderungen koordinieren; als abgeschlossen gilt die Arbeit, wenn bestehende Client-Flows weiterhin funktionieren und Proxy-Anwendungsfälle Anfragen abfangen und die Authentifizierung fortsetzen können.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Summary
Refactor OAuth implementation so the flow logic and state machine are usable by server-side proxy services, not just client-side browser flows.
Problem
The SDK's OAuth implementation is designed for local client-side flows (opening a browser locally). The business logic is embedded inside an httpx auth module, making it hard to reuse for other scenarios.
While individual helper functions have been extracted (PKCE utilities, token exchange, discovery), the core state machine that orchestrates the OAuth flow is not reusable. Proxy services that need to perform OAuth on behalf of users currently have to reimplement significant portions of the flow themselves — and when the SDK updates its OAuth logic, those reimplementations can fall out of sync.
Goal
- Make the OAuth portions of the SDK compatible with proxy/gateway services that currently use custom workarounds
- When an issue is fixed in the SDK, updating the SDK version should fix it everywhere — no custom OAuth reimplementations needed
- Keep existing client-side flows working
Design Requirements (from maintainer discussion, Feb 2026)
Modularization into zones: Break the monolithic OAuth flow into modular, overridable pieces:
- Discovery — obtaining and potentially customizing discovery URLs
- Client Registration — dynamic client registration
- Interactive Flow — authorization URL generation, redirect handling
- Token Fetching — code exchange, refresh, new token extensions (XA, WIF)
- Token Storage — pluggable storage (already exists)
Key requirements:
- Each zone should operate as a pure function requiring minimal state
- Every HTTP request in the flow must be interceptable — allow injection of a custom HTTP client/fetch interface (httpx client in Python, fetch in TypeScript) for custom headers, metrics, response handling
- Support an "Auth Required" state as an SDK primitive — when a server responds with 401/403 mid-flow, the SDK should capture discovery metadata, scope, and WWW-Authenticate info and surface it so the calling application can handle it (rather than assuming auth happens upfront)
- The flow must be resumable — a caller should be able to pick up an auth flow at any point (e.g., after a redirect returns on a different machine/request)
- Support bypassing discovery when configuration is provided directly (important for enterprise environments with broken discovery)
- Support new token-getting extensions (XA, WIF) that don't require interactive flows
Next steps:
- Draft code sketches (potentially TypeScript first) to validate the modular function approach
- Cross-SDK coordination — this applies to both Python and TypeScript SDKs
Related
- #1240 - Implement OAuth relying on Authlib
- #2053 - Replace Field(description=...) with docstrings in auth models
- Vorherrschende Sprache
- Python
- Sterne
- 24.3k
- Forks
- 4k
- Ø Merge
- 1 T. 19 Min.
- Gemergte PRs (30 T.)
- 29
Beitragsleitfaden
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus modelcontextprotocol/python-sdk
-
v1 v2
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 85/100
modelcontextprotocol/python-sdk#3546 · 5 Kommentare ·
-
v1 v2
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
modelcontextprotocol/python-sdk#3545 · 1 Kommentar ·
-
v1 v2
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 91/100
modelcontextprotocol/python-sdk#3508 · 2 Kommentare ·
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 64/100
modelcontextprotocol/python-sdk#3504 ·
-
v1 v2
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
modelcontextprotocol/python-sdk#3492 · 1 Kommentar ·
Alle Issues in modelcontextprotocol/python-sdk
Ähnliche Issues
-
Add: hunch Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 74/100
AbdelStark/awesome-typesafe#104 ·
-
enhancement
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
DiamondLightSource/dodal#2211 ·
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 88/100
openml/openml-python#1749 ·
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 88/100
sipyourdrink-ltd/bernstein#6191 ·