-
Notifications
You must be signed in to change notification settings - Fork 0
[pull] main from modelcontextprotocol:main #84
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Review these changes at https://app.gitnotebooks.com/Stars1233/python-sdk/pull/84 |
Reviewer's GuideThis PR overhauls the OAuth integration by introducing a dedicated OAuthContext and PKCEParameters model, refactoring the OAuth client provider into request-builder/response-handler steps, and extending the FastMCP server to support a clear Authorization Server (AS) vs Resource Server (RS) separation with RFC 9728 discovery and token introspection via a TokenVerifier protocol. Sequence diagram for OAuth flow with AS/RS separation and token introspectionsequenceDiagram
actor User
participant Client
participant ResourceServer as RS
participant AuthorizationServer as AS
User->>Client: Initiate authentication
Client->>RS: Discover /.well-known/oauth-protected-resource
RS-->>Client: Returns AS URL
Client->>AS: Discover /.well-known/oauth-authorization-server
AS-->>Client: Returns OAuth metadata
Client->>AS: Register client
AS-->>Client: Returns client info
Client->>AS: Authorize (redirect via browser)
User->>AS: Authenticate and consent
AS-->>Client: Redirect with auth code
Client->>AS: Exchange code for token
AS-->>Client: Returns access token
Client->>RS: Call protected resource with Bearer token
RS->>AS: Introspect token
AS-->>RS: Token info (active/claims)
RS-->>Client: Returns resource
ER diagram for ProtectedResourceMetadata and OAuthMetadataerDiagram
PROTECTED_RESOURCE_METADATA {
string resource
string[] authorization_servers
string[] scopes_supported
string[] bearer_methods_supported
string resource_documentation
}
OAUTH_METADATA {
string issuer
string authorization_endpoint
string token_endpoint
string registration_endpoint
string[] scopes_supported
}
PROTECTED_RESOURCE_METADATA ||--o{ OAUTH_METADATA : "authorization_servers"
Class diagram for new OAuthContext and PKCEParametersclassDiagram
class OAuthContext {
+str server_url
+OAuthClientMetadata client_metadata
+TokenStorage storage
+Callable redirect_handler
+Callable callback_handler
+float timeout
+ProtectedResourceMetadata? protected_resource_metadata
+OAuthMetadata? oauth_metadata
+str? auth_server_url
+OAuthClientInformationFull? client_info
+OAuthToken? current_tokens
+float? token_expiry_time
+anyio.Lock lock
+get_authorization_base_url(server_url: str) str
+update_token_expiry(token: OAuthToken) None
+is_token_valid() bool
+can_refresh_token() bool
+clear_tokens() None
}
class PKCEParameters {
+str code_verifier
+str code_challenge
+generate() PKCEParameters
}
Class diagram for TokenVerifier protocol and ProviderTokenVerifierclassDiagram
class TokenVerifier {
<<protocol>>
+verify_token(token: str) AccessToken|None
}
class ProviderTokenVerifier {
+OAuthAuthorizationServerProvider provider
+verify_token(token: str) AccessToken|None
}
TokenVerifier <|.. ProviderTokenVerifier
Class diagram for IntrospectionTokenVerifier (Resource Server)classDiagram
class IntrospectionTokenVerifier {
+str introspection_endpoint
+verify_token(token: str) AccessToken|None
}
TokenVerifier <|.. IntrospectionTokenVerifier
Class diagram for ProtectedResourceMetadata (RFC 9728)classDiagram
class ProtectedResourceMetadata {
+AnyHttpUrl resource
+List[AnyHttpUrl] authorization_servers
+List[str]? scopes_supported
+List[str]? bearer_methods_supported
+AnyHttpUrl? resource_documentation
}
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
See Commits and Changes for more details.
Created by
pull[bot] (v2.0.0-alpha.1)
Can you help keep this open source service alive? 💖 Please sponsor : )
Summary by Sourcery
Refactor OAuth client provider and server components to support OAuth 2.1 flows with PKCE, separate Authorization Server and Resource Server roles, and protected resource discovery (RFC 9728). Introduce structured context, token verifier protocol, new exception types, and comprehensive example implementations.
New Features:
Enhancements:
Documentation:
Tests: