Skip to content

Commit 654b30d

Browse files
authored
Merge pull request #32 from sacha-development-stuff/codex/fix-failing-test_register_client_skip_if_registered
Skip OAuth registration when client info already exists
2 parents 541d0b9 + a5b45f7 commit 654b30d

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

src/mcp/client/auth/oauth2.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -224,14 +224,15 @@ async def _handle_oauth_metadata_response(self, response: httpx.Response) -> Non
224224
def _create_registration_request(self, metadata: OAuthMetadata | None = None) -> httpx.Request | None:
225225
context = getattr(self, "context", None)
226226

227-
if metadata is not None:
228-
if self._client_info:
229-
return None
230-
if context and context.client_info:
231-
self._client_info = context.client_info
232-
return None
233-
elif context and context.client_info and not self._client_info:
227+
if self._client_info:
228+
return None
229+
230+
if context and context.client_info:
234231
self._client_info = context.client_info
232+
return None
233+
234+
# If we reach this point we don't yet have stored client information, so
235+
# proceed with building a dynamic registration request.
235236

236237
if metadata and metadata.registration_endpoint:
237238
registration_url = str(metadata.registration_endpoint)

0 commit comments

Comments
 (0)