@@ -272,14 +272,13 @@ async def _handle_protected_resource_response(self, response: httpx.Response) ->
272
272
else :
273
273
raise OAuthFlowError (f"Protected Resource Metadata request failed: { response .status_code } " )
274
274
275
- def _configure_scope_selection (self , init_response : httpx .Response ) -> None :
275
+ def _select_scopes (self , init_response : httpx .Response ) -> None :
276
276
"""Select scopes as outlined in the 'Scope Selection Strategy in the MCP spec."""
277
277
# Per MCP spec, scope selection priority order:
278
278
# 1. Use scope from WWW-Authenticate header (if provided)
279
279
# 2. Use all scopes from PRM scopes_supported (if available)
280
280
# 3. Omit scope parameter if neither is available
281
281
#
282
- # Step 1: Extract scope from WWW-Authenticate header
283
282
www_authenticate_scope = self ._extract_scope_from_www_auth (init_response )
284
283
if www_authenticate_scope is not None :
285
284
# Priority 1: WWW-Authenticate header scope
@@ -555,7 +554,7 @@ async def async_auth_flow(self, request: httpx.Request) -> AsyncGenerator[httpx.
555
554
await self ._handle_protected_resource_response (discovery_response )
556
555
557
556
# Step 2: Apply scope selection strategy
558
- self ._configure_scope_selection (response )
557
+ self ._select_scopes (response )
559
558
560
559
# Step 3: Discover OAuth metadata (with fallback for legacy servers)
561
560
discovery_urls = self ._get_discovery_urls ()
@@ -600,7 +599,7 @@ async def async_auth_flow(self, request: httpx.Request) -> AsyncGenerator[httpx.
600
599
if error == "insufficient_scope" :
601
600
try :
602
601
# Step 2a: Update the required scopes
603
- self ._configure_scope_selection (response )
602
+ self ._select_scopes (response )
604
603
605
604
# Step 2b: Perform (re-)authorization
606
605
auth_code , code_verifier = await self ._perform_authorization ()
0 commit comments