Skip to content

Commit 84b85c1

Browse files
committed
fix: remove unnecessary DCR fallback, rely on storage-loaded client info
The _initialize() method already loads client_info from storage before the OAuth flow runs. When pre-registered credentials are in storage, the 'if not self.context.client_info' guard skips DCR entirely — no fallback needed.
1 parent 7bff13c commit 84b85c1

File tree

1 file changed

+4
-13
lines changed

1 file changed

+4
-13
lines changed

src/mcp/client/auth/oauth2.py

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
import httpx
1919
from pydantic import BaseModel, Field, ValidationError
2020

21-
from mcp.client.auth.exceptions import OAuthFlowError, OAuthRegistrationError, OAuthTokenError
21+
from mcp.client.auth.exceptions import OAuthFlowError, OAuthTokenError
2222
from mcp.client.auth.utils import (
2323
build_oauth_authorization_server_metadata_discovery_urls,
2424
build_protected_resource_metadata_discovery_urls,
@@ -586,18 +586,9 @@ async def async_auth_flow(self, request: httpx.Request) -> AsyncGenerator[httpx.
586586
self.context.get_authorization_base_url(self.context.server_url),
587587
)
588588
registration_response = yield registration_request
589-
try:
590-
client_information = await handle_registration_response(registration_response)
591-
self.context.client_info = client_information
592-
await self.context.storage.set_client_info(client_information)
593-
except OAuthRegistrationError:
594-
# DCR failed — check for pre-registered client credentials
595-
stored_client_info = await self.context.storage.get_client_info()
596-
if stored_client_info:
597-
logger.debug("DCR failed, using pre-registered client credentials")
598-
self.context.client_info = stored_client_info
599-
else:
600-
raise
589+
client_information = await handle_registration_response(registration_response)
590+
self.context.client_info = client_information
591+
await self.context.storage.set_client_info(client_information)
601592

602593
# Step 5: Perform authorization and complete token exchange
603594
token_response = yield await self._perform_authorization()

0 commit comments

Comments
 (0)