fix(mcp): prevent auto-discovered token_url from triggering 2LO client_credentials grant.

This commit is contained in:
awais qureshi 2026-03-10 17:21:54 +05:00
parent cec3e9e7d4
commit f1ce68d38c
2 changed files with 3 additions and 0 deletions

View file

@ -298,6 +298,7 @@ class MCPServerManager:
resolved_authorization_url = server_config.get("authorization_url") or (
mcp_oauth_metadata.authorization_url if mcp_oauth_metadata else None
)
token_url_from_config = bool(server_config.get("token_url"))
resolved_token_url = server_config.get("token_url") or (
mcp_oauth_metadata.token_url if mcp_oauth_metadata else None
)
@ -322,6 +323,7 @@ class MCPServerManager:
scopes=resolved_scopes,
authorization_url=resolved_authorization_url,
token_url=resolved_token_url,
token_url_from_config=token_url_from_config,
registration_url=resolved_registration_url,
# TODO: utility fn the default values
transport=server_config.get("transport", MCPTransport.http),

View file

@ -47,6 +47,7 @@ class MCPServer(BaseModel):
scopes: Optional[List[str]] = None
authorization_url: Optional[str] = None
token_url: Optional[str] = None
token_url_from_config: bool = False # True only when token_url was explicitly set in user config (not auto-discovered)
registration_url: Optional[str] = None
# AWS SigV4 fields
aws_access_key_id: Optional[str] = None