Skip to content

Commit b271600

Browse files
committed
set scopes on client metadata if supported
1 parent d6b8d58 commit b271600

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/mcp/client/auth.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,10 @@ async def _register_oauth_client(
175175
auth_base_url = self._get_authorization_base_url(server_url)
176176
registration_url = urljoin(auth_base_url, "/register")
177177

178+
# Handle default scope
179+
if client_metadata.scope is None and metadata and metadata.scopes_supported is not None:
180+
client_metadata.scope = " ".join(metadata.scopes_supported)
181+
178182
# Serialize client metadata
179183
registration_data = client_metadata.model_dump(
180184
by_alias=True, mode="json", exclude_none=True
@@ -356,7 +360,7 @@ async def _perform_oauth_flow(self) -> None:
356360
if returned_state is None or not secrets.compare_digest(
357361
returned_state, self._auth_state
358362
):
359-
raise Exception("State parameter mismatch")
363+
raise Exception(f"State parameter mismatch: {returned_state} != {self._auth_state}")
360364

361365
# Clear state after validation
362366
self._auth_state = None

0 commit comments

Comments
 (0)