Skip to content

Commit f84d1d2

Browse files
committed
function names
1 parent ed443f5 commit f84d1d2

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

src/mcp/client/auth.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -272,14 +272,13 @@ async def _handle_protected_resource_response(self, response: httpx.Response) ->
272272
else:
273273
raise OAuthFlowError(f"Protected Resource Metadata request failed: {response.status_code}")
274274

275-
def _configure_scope_selection(self, init_response: httpx.Response) -> None:
275+
def _select_scopes(self, init_response: httpx.Response) -> None:
276276
"""Select scopes as outlined in the 'Scope Selection Strategy in the MCP spec."""
277277
# Per MCP spec, scope selection priority order:
278278
# 1. Use scope from WWW-Authenticate header (if provided)
279279
# 2. Use all scopes from PRM scopes_supported (if available)
280280
# 3. Omit scope parameter if neither is available
281281
#
282-
# Step 1: Extract scope from WWW-Authenticate header
283282
www_authenticate_scope = self._extract_scope_from_www_auth(init_response)
284283
if www_authenticate_scope is not None:
285284
# Priority 1: WWW-Authenticate header scope
@@ -555,7 +554,7 @@ async def async_auth_flow(self, request: httpx.Request) -> AsyncGenerator[httpx.
555554
await self._handle_protected_resource_response(discovery_response)
556555

557556
# Step 2: Apply scope selection strategy
558-
self._configure_scope_selection(response)
557+
self._select_scopes(response)
559558

560559
# Step 3: Discover OAuth metadata (with fallback for legacy servers)
561560
discovery_urls = self._get_discovery_urls()
@@ -600,7 +599,7 @@ async def async_auth_flow(self, request: httpx.Request) -> AsyncGenerator[httpx.
600599
if error == "insufficient_scope":
601600
try:
602601
# Step 2a: Update the required scopes
603-
self._configure_scope_selection(response)
602+
self._select_scopes(response)
604603

605604
# Step 2b: Perform (re-)authorization
606605
auth_code, code_verifier = await self._perform_authorization()

tests/client/test_auth.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ async def test_prioritize_www_auth_scope_over_prm(
449449
await oauth_provider._handle_protected_resource_response(prm_metadata_response)
450450

451451
# Process the scope selection with WWW-Authenticate header
452-
oauth_provider._configure_scope_selection(init_response_with_www_auth_scope)
452+
oauth_provider._select_scopes(init_response_with_www_auth_scope)
453453

454454
# Verify that WWW-Authenticate scope is used (not PRM scopes)
455455
assert oauth_provider.context.client_metadata.scope == "special:scope from:www-authenticate"
@@ -466,7 +466,7 @@ async def test_prioritize_prm_scopes_when_no_www_auth_scope(
466466
await oauth_provider._handle_protected_resource_response(prm_metadata_response)
467467

468468
# Process the scope selection without WWW-Authenticate scope
469-
oauth_provider._configure_scope_selection(init_response_without_www_auth_scope)
469+
oauth_provider._select_scopes(init_response_without_www_auth_scope)
470470

471471
# Verify that PRM scopes are used
472472
assert oauth_provider.context.client_metadata.scope == "resource:read resource:write"
@@ -483,7 +483,7 @@ async def test_omit_scope_when_no_prm_scopes_or_www_auth(
483483
await oauth_provider._handle_protected_resource_response(prm_metadata_without_scopes_response)
484484

485485
# Process the scope selection without WWW-Authenticate scope
486-
oauth_provider._configure_scope_selection(init_response_without_www_auth_scope)
486+
oauth_provider._select_scopes(init_response_without_www_auth_scope)
487487

488488
# Verify that scope is omitted
489489
assert oauth_provider.context.client_metadata.scope is None

0 commit comments

Comments
 (0)