Skip to content

Commit 9ad0728

Browse files
committed
feat(keycardai-mcp): dcr can be toggled on/off
1 parent 2375a3a commit 9ad0728

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

packages/mcp/src/keycardai/mcp/server/auth/provider.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ def __init__(
192192
private_key_storage: PrivateKeyStorageProtocol | None = None,
193193
private_key_storage_dir: str | None = None,
194194
client_factory: ClientFactory | None = None,
195+
enable_dynamic_client_registration: bool | None = None,
195196
):
196197
"""Initialize the KeyCard auth provider.
197198
@@ -227,6 +228,7 @@ def __init__(
227228
self.client_name = mcp_server_name or "MCP Server OAuth Client"
228229
self.enable_multi_zone = enable_multi_zone
229230
self.client_factory = client_factory or DefaultClientFactory()
231+
self.enable_dynamic_client_registration = enable_dynamic_client_registration
230232

231233
self._clients: dict[str, AsyncClient | None] = {}
232234

@@ -310,7 +312,7 @@ async def _get_or_create_client(self, auth_info: dict[str, str] | None = None) -
310312
"""
311313
client_config = ClientConfig(
312314
client_name=self.client_name,
313-
enable_metadata_discovery=True
315+
enable_metadata_discovery=True,
314316
)
315317

316318
if self.enable_private_key_identity:
@@ -330,7 +332,9 @@ async def _get_or_create_client(self, auth_info: dict[str, str] | None = None) -
330332
raise AuthProviderConfigurationError()
331333
auth_strategy = self.auth.get_auth_for_zone(auth_info['zone_id'])
332334

333-
if isinstance(auth_strategy, NoneAuth) or self.enable_private_key_identity:
335+
if self.enable_dynamic_client_registration is not None:
336+
client_config.auto_register_client = self.enable_dynamic_client_registration
337+
elif isinstance(auth_strategy, NoneAuth):
334338
client_config.auto_register_client = True
335339

336340
client = self.client_factory.create_async_client(

0 commit comments

Comments
 (0)