Repository navigation
feat(mcp): add all-proxy-mcpservers sentinel to grant teams every MCP server - #32012
ryan-crabbe-berri merged 10 commits into
Conversation
Teams can now be scoped to the all-proxy-mcpservers sentinel so they gain access to every MCP server on the proxy without listing each id. The sentinel expands to the live registry at request time, so a server added later is picked up with no change to the team's stored permission. The team ceiling that validates a key's MCP scope expands the sentinel too, so a key can be scoped to any server (including one registered after the team) and still pass subset validation Expose the option in the team create and edit forms via a new exclusive "All Proxy MCP Servers" choice in MCPServerSelector, mirroring the existing "No MCP Servers" sentinel
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Greptile SummaryThis PR introduces an
Confidence Score: 5/5Safe to merge. The sentinel is correctly scoped to the team path, the proxy-admin gate is enforced at both team creation and update, and the "inert passthrough" design for non-team entities means a misplaced sentinel grants nothing rather than everything. The authorization boundary between team-only expansion and non-team passthrough is clearly established and tested at each layer. The admin gate fetches the live DB row before deciding, so the "preserve existing grant" case is correct even when a team admin round-trips an edit. No existing tests were weakened, and all new tests use mocks with no real network calls. No files require special attention.
|
| Filename | Overview |
|---|---|
| litellm/proxy/management_helpers/object_permission_utils.py | Adds _get_all_mcp_server_ids, _existing_object_permission_mcp_servers, and enforce_all_proxy_mcp_servers_grant_is_admin_only; sentinel detection injected into _resolve_team_allowed_mcp_servers. Logic is sound: admin gate correctly fetches existing DB value before blocking, and the early return to _get_all_mcp_server_ids() correctly supersedes access-group resolution when the sentinel is present. |
| litellm/proxy/_experimental/mcp_server/auth/user_api_key_auth_mcp.py | Adds sentinel expansion in _get_allowed_mcp_servers_for_team only; the shared expand_permission_list code path (used for keys, orgs, end-users) is deliberately NOT modified, so the sentinel stays inert for non-team entities. Early return correctly drops the already-computed team_access_group_servers, which is safe because the sentinel already grants a superset of any access-group server. |
| litellm/proxy/management_endpoints/team_endpoints.py | Wires enforce_all_proxy_mcp_servers_grant_is_admin_only into both new_team and update_team before object-permission persistence. new_team always passes existing_object_permission_id=None (correct for creation); update_team passes the live row's object_permission_id so the "already granted" path works correctly. |
| tests/test_litellm/proxy/_experimental/mcp_server/auth/test_user_api_key_auth_mcp.py | Adds four well-scoped mock tests covering: sentinel does not expand on non-team path, team resolver expands dynamically, sentinel on a key grants nothing, and end-to-end team-ceiling × key intersection. All tests are correctly mocked with no real network calls. |
| tests/test_litellm/proxy/management_helpers/test_object_permission_utils.py | Adds six mock tests for the admin gate and team-ceiling scenarios (dynamic expansion, post-registration server acceptance, concrete-list rejection). Coverage is thorough and no existing assertions were weakened. |
| ui/litellm-dashboard/src/components/mcp_server_management/MCPServerSelector.tsx | Adds allowAllProxyMcpServers prop that renders an exclusive "All Proxy MCP Servers" option, mirrors the existing allowNoMcpServers pattern exactly. Exclusivity is enforced both on selection (early return) and visually (disabling other options when selected). |
| ui/litellm-dashboard/src/components/permissions/MCPServerPermissions.tsx | Adds grantsAllProxyMcpServers branch to display component — green badge "All" and descriptive row when sentinel is present. The sentinel is correctly filtered out of the mergedItems list to avoid showing it as a raw server entry alongside the special message. |
| ui/litellm-dashboard/src/components/mcp_tools/constants.ts | Adds ALL_PROXY_MCP_SERVERS_SENTINEL = "all-proxy-mcpservers" constant, matching the backend SpecialMCPServerName.all_proxy_servers enum value. Follows the same pattern as the existing NO_MCP_SERVERS_SENTINEL. |
| ui/litellm-dashboard/src/components/OldTeams.tsx | One-line change: wires `allowAllProxyMcpServers={isProxyAdminRole(userRole |
| ui/litellm-dashboard/src/components/team/TeamInfo.tsx | One-line change: wires allowAllProxyMcpServers={is_proxy_admin} into the team-edit form's MCPServerSelector, symmetric with OldTeams.tsx. |
Reviews (2): Last reviewed commit: "fix(mcp): require proxy admin to grant a..." | Re-trigger Greptile
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
PR overviewAll previously flagged issues have been addressed. No open security concerns remain on this pull request. Security reviewNo open security issues remain on this pull request. Fixed/addressed: 1 · PR risk: 0/10 |
…itellm_all_proxy_mcps_sentinel # Conflicts: # litellm/proxy/_experimental/mcp_server/mcp_server_manager.py
…-key The sentinel was expanded inside the shared expand_permission_list, which also feeds the key, org, end_user and agent resolvers. A key whose stored object_permission ever held all-proxy-mcpservers (a stale write, a configured default, or a bug) would silently resolve to every MCP server at runtime, and a teamless key had nothing to cap it, so all servers got injected. Only write-time validation stripping the value stood between that value and a full grant Move the expansion out of expand_permission_list and into _get_allowed_mcp_servers_for_team so the sentinel is honored only where it is settable (a team). Anywhere else it now passes through as an inert literal that matches no registered server and is denied downstream. Reserved-id protection already blocks a real server from taking that id
… into litellm_all_proxy_mcps_sentinel
Granting a team every MCP server on the proxy is a proxy-wide authorization decision, but team create/update let any caller who can manage a team set object_permission.mcp_servers, with no ceiling check. Org admins reach /team/update by default (org_admin_allowed_routes) and _verify_team_access also admits team admins, so a non-proxy-admin could set all-proxy-mcpservers and self-grant their team access to every MCP server on the proxy, including servers never assigned to that team Gate the grant in new_team and update_team: a non-proxy-admin cannot add the all-proxy-mcpservers sentinel. The check is scoped to newly adding it, so a team a proxy admin already scoped to all-proxy can still be edited by a team admin without being forced to strip the sentinel. The UI only offers the "All Proxy MCP Servers" option to proxy admins in the team create and edit forms
|
@greptileai re review |
…n all-proxy team A team scoped to the all-proxy-mcpservers sentinel could be opened in the team edit form by a team admin or org admin (canEditTeam admits them), but the "All Proxy MCP Servers" option in MCPServerSelector was rendered only behind the proxy-admin-gated allowAllProxyMcpServers flag. For a non-proxy-admin the stored sentinel was hydrated into the selected value with no matching Select.Option, so antd showed the raw all-proxy-mcpservers literal as a chip, and adding another server could persist a mixed [all-proxy-mcpservers, <id>] value. Render the option whenever the sentinel is present in the value, not only when the caller may grant it, and drive the real-option disabling off presence too so the selection stays exclusive. A non-proxy-admin now sees the friendly label read-only and cannot build a mixed state; only a proxy admin can newly add it, which the backend already enforces. Adds regression tests: the selector shows the friendly option (not the raw literal) when the sentinel is stored but the grant flag is off, plus exclusive emit and disabled-real-options coverage, and MCPServerPermissions renders the green "All" state instead of the raw sentinel string.
antd renders a Select option's children inside the selected tag, so the all-proxy option showed both "All Proxy MCP Servers" and the green "All servers" type-hint in the chip, which say the same thing. Collapse the option to a single green "All Proxy MCP Servers" label so the dropdown row and the chip read cleanly without the duplication.
Use the same blue (#1890ff) as regular MCP server entries for the "All Proxy MCP Servers" option/chip instead of green.
Match the blue used by the selector chip and regular server entries so the "All Proxy MCP Servers" badge and row in MCPServerPermissions are consistent across the team/key/org detail views. The red "Blocked" state for no-mcp-servers is unchanged.
Relevant issues
Linear ticket
Resolves LIT-4132
Pre-Submission checklist
Please complete all items before asking a LiteLLM maintainer to review your PR
@greptileaiand received a Confidence Score of at least 4/5 before requesting a maintainer reviewDelays in PR merge?
If you're seeing a delay in your PR being merged, ping the LiteLLM Team on Slack (#pr-review).
Screenshots / Proof of Fix
Config used (note
require_key_mcp_access_defined: true, so a key inherits no MCP servers from its team by default and must be scoped explicitly), with two stdio MCP serversserver_xandserver_yEach stdio server exposes one tool,
<name>_whoami, so a key'stools/listmakes its scope visibleNegative control, proving it is the sentinel and not a blanket allow: a team scoped to
server_xonly rejects a key that asks forserver_zAuthorization: only a proxy admin can grant a team the sentinel. A team admin (non proxy admin) is blocked, and is not forced to strip a grant a proxy admin already made
UI: the "All Proxy MCP Servers" option shows up in the team create form (http://localhost:4000/ui/?page=teams -> Create Team -> Allowed MCP Servers) and the team edit form (Team -> Settings -> MCP Servers). Selecting it is exclusive and stores
all-proxy-mcpserverson the team'sobject_permission.mcp_serversType
🆕 New Feature
Changes
Adds an
all-proxy-mcpserverssentinel (the already reservedSpecialMCPServerName.all_proxy_serversvalue) that scopes a team to every MCP server on the proxyThe sentinel is a team-only grant, and the runtime honors it only on the team path.
_get_allowed_mcp_servers_for_teamexpands it to the liveget_registry()id set, so a team scoped to it picks up servers registered later with no permission change, and_resolve_team_allowed_mcp_serversexpands it too so the ceiling used byvalidate_key_mcp_servers_against_teamcovers any server a key asks for, including one added after the team was created. The sharedexpand_permission_list, which also feeds the key, org, end_user and agent resolvers, deliberately does NOT expand the sentinel; anywhere other than a team it passes through as an inert literal that matches no registered server and is denied downstream. That keeps a key that ever stores the sentinel (a stale write, a configured default, or a bug) from silently resolving to every server, rather than relying on write-time validation to strip it. Reserved-id protection already blocks a real server from taking that idGranting a team every MCP server on the proxy is a proxy-wide authorization decision, so
new_teamandupdate_teamnow require a proxy admin to newly add the sentinel viaenforce_all_proxy_mcp_servers_grant_is_admin_only. Without this a non-proxy-admin who can manage a team (an org admin reaches/team/updateby default, and_verify_team_accessalso admits team admins) could setall-proxy-mcpserversand self-grant their team access to every MCP server on the proxy. The check is scoped to newly adding the sentinel, so a team a proxy admin already scoped to all-proxy can still be edited by a team admin without being forced to strip itOn the dashboard,
MCPServerSelectorgains anallowAllProxyMcpServersprop that renders an exclusive "All Proxy MCP Servers" option, wired into the team create and edit forms (only for proxy admins) and surfaced inMCPServerPermissions. When a non-proxy-admin (a team admin or org admin, both admitted bycanEditTeam) opens a team already scoped to the sentinel, the option still renders read-only so the stored value shows as the friendly label rather than the rawall-proxy-mcpserversliteral, and the selection stays exclusive so a mixed[all-proxy-mcpservers, <id>]state cannot be built; newly granting the sentinel remains proxy-admin-only, enforced on the backendScenario 2 above reflects the change through the standard management-object cache TTL (60s by default,
user_api_key_cache_ttl); the write itself is immediate, as/key/infoshows. This matches how every other key or team update propagates today and is intentionally left out of scope