Exclude allow_all_keys servers from team-scoped MCP server dropdown

When a team is selected in the Create Key UI, the MCP server dropdown
now only shows servers the team has explicit access to, not global
allow_all_keys servers. Those servers are already accessible at request
time without needing to be attached to a key.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
yuneng-jiang 2026-03-11 22:53:55 -07:00
parent 7391404f24
commit c72760711d

View file

@ -646,12 +646,14 @@ if MCP_AVAILABLE:
team_id: str,
) -> List[LiteLLM_MCPServerTable]:
"""
Return MCP servers scoped to a team: team's allowed servers + allow_all_keys servers.
Return MCP servers explicitly allowed by the team.
Used by the Create Key UI to populate the MCP server dropdown.
Does NOT include allow_all_keys servers those are globally
accessible at request time and don't need to be attached to a key.
"""
from litellm.proxy.auth.auth_checks import get_team_object
from litellm.proxy.management_helpers.object_permission_utils import (
_get_allow_all_keys_server_ids,
_get_team_allowed_mcp_servers,
)
from litellm.proxy.proxy_server import prisma_client, user_api_key_cache
@ -663,9 +665,7 @@ if MCP_AVAILABLE:
check_db_only=True,
)
team_server_ids = await _get_team_allowed_mcp_servers(team_obj)
allow_all_server_ids = _get_allow_all_keys_server_ids()
all_allowed_ids = team_server_ids | allow_all_server_ids
all_allowed_ids = await _get_team_allowed_mcp_servers(team_obj)
if not all_allowed_ids:
return []
@ -693,7 +693,7 @@ if MCP_AVAILABLE:
team_id: Optional[str] = Query(
None,
description="Filter MCP servers by team scope. When provided, returns only "
"servers the team has access to plus globally available (allow_all_keys) servers. "
"servers the team has explicit access to. "
"Used by the Create Key UI to show team-scoped MCP servers.",
),
):