-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Fall back to the caller-configured scope when the server advertises none #3172
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
218510e
da19abc
aeac39f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -100,21 +100,30 @@ | |
| protected_resource_metadata: ProtectedResourceMetadata | None, | ||
| authorization_server_metadata: OAuthMetadata | None = None, | ||
| client_grant_types: list[str] | None = None, | ||
| configured_scope: str | None = None, | ||
| ) -> str | None: | ||
| """Select effective scopes and augment for refresh token support.""" | ||
| """Select effective scopes and augment for refresh token support. | ||
|
|
||
| A source that yields no scopes (absent, null, or an empty list) offers no guidance, so | ||
| selection falls through to the next source rather than treating "advertised nothing" as | ||
| "request nothing". | ||
| """ | ||
| selected_scope: str | None = None | ||
|
|
||
| # MCP spec scope selection priority: | ||
| # 1. WWW-Authenticate header scope | ||
| # 2. PRM scopes_supported | ||
| # 3. AS scopes_supported (SDK fallback) | ||
| # 4. Omit scope parameter | ||
| if www_authenticate_scope is not None: | ||
| # 4. Scope the caller configured on the provider (SDK fallback) | ||
| # 5. Omit scope parameter | ||
| if www_authenticate_scope: | ||
| selected_scope = www_authenticate_scope | ||
| elif protected_resource_metadata is not None and protected_resource_metadata.scopes_supported is not None: | ||
| elif protected_resource_metadata is not None and protected_resource_metadata.scopes_supported: | ||
| selected_scope = " ".join(protected_resource_metadata.scopes_supported) | ||
| elif authorization_server_metadata is not None and authorization_server_metadata.scopes_supported is not None: | ||
| elif authorization_server_metadata is not None and authorization_server_metadata.scopes_supported: | ||
| selected_scope = " ".join(authorization_server_metadata.scopes_supported) | ||
| else: | ||
| selected_scope = configured_scope or None | ||
|
Check warning on line 126 in src/mcp/client/auth/utils.py
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P2: Clients that previously relied on an omitted Prompt for AI agents
claude[bot] marked this conversation as resolved.
Outdated
|
||
|
|
||
| # SEP-2207: append offline_access when the AS supports it and the client can use refresh tokens | ||
| if ( | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.