Skip to content

Commit 8463dc7

Browse files
committed
functionality
1 parent 359e159 commit 8463dc7

File tree

3 files changed

+893
-886
lines changed

3 files changed

+893
-886
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ ipython_config.py
8888
# pyenv
8989
# For a library or package, you might want to ignore these files since the code is
9090
# intended to run in multiple environments; otherwise, check them in:
91-
# .python-version
91+
.python-version
9292

9393
# pipenv
9494
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.

src/mcp/client/auth.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -478,9 +478,16 @@ async def _handle_oauth_metadata_response(self, response: httpx.Response) -> Non
478478
content = await response.aread()
479479
metadata = OAuthMetadata.model_validate_json(content)
480480
self.context.oauth_metadata = metadata
481-
# Apply default scope if needed
482-
if self.context.client_metadata.scope is None and metadata.scopes_supported is not None:
483-
self.context.client_metadata.scope = " ".join(metadata.scopes_supported)
481+
482+
# Only set scope if client_metadata.scope is None
483+
if self.context.client_metadata.scope is None:
484+
# Priority 1: Use PRM's scopes_supported if available
485+
if (self.context.protected_resource_metadata is not None and
486+
self.context.protected_resource_metadata.scopes_supported is not None):
487+
self.context.client_metadata.scope = " ".join(self.context.protected_resource_metadata.scopes_supported)
488+
# Priority 2: Fall back to OAuth metadata scopes if available
489+
elif metadata.scopes_supported is not None:
490+
self.context.client_metadata.scope = " ".join(metadata.scopes_supported)
484491

485492
async def async_auth_flow(self, request: httpx.Request) -> AsyncGenerator[httpx.Request, httpx.Response]:
486493
"""HTTPX auth flow integration."""

0 commit comments

Comments
 (0)