Skip to content

feat(mcp): add all-proxy-mcpservers sentinel to grant teams every MCP server - #32012

Merged
ryan-crabbe-berri merged 10 commits into
litellm_internal_stagingfrom
litellm_all_proxy_mcps_sentinel
Jul 3, 2026
Merged

ryan-crabbe-berri merged 10 commits into
litellm_internal_stagingfrom
litellm_all_proxy_mcps_sentinel

Conversation

@ryan-crabbe-berri

@ryan-crabbe-berri ryan-crabbe-berri commented Jul 3, 2026 •

Copy link
Copy Markdown
Contributor

Relevant issues

Linear ticket

Resolves LIT-4132

Pre-Submission checklist

Please complete all items before asking a LiteLLM maintainer to review your PR

  • I have added meaningful tests
  • My PR passes all CI/CD checks (e.g., lint, format, unit tests)
  • My PR's scope is as isolated as possible; it only solves 1 specific problem
  • I have requested a Greptile review by commenting @greptileai and received a Confidence Score of at least 4/5 before requesting a maintainer review

Delays 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 servers server_x and server_y

general_settings:
  master_key: sk-1234
  require_key_mcp_access_defined: true
mcp_servers:
  server_x: { transport: stdio, command: python, args: [mcp_stdio_server.py, server_x] }
  server_y: { transport: stdio, command: python, args: [mcp_stdio_server.py, server_y] }

Each stdio server exposes one tool, <name>_whoami, so a key's tools/list makes its scope visible

MK=sk-1234; B=http://localhost:4000
SX=bdaf0abddc5e2c5d646c6ebc64cdf97a   # server_x's server_id

# 1) Team scoped to ALL PROXY MCP SERVERS via the new sentinel
TEAM_ID=$(curl -s -X POST $B/team/new -H "Authorization: Bearer $MK" -H 'Content-Type: application/json' \
  -d '{"team_alias":"all-proxy-mcp-team","object_permission":{"mcp_servers":["all-proxy-mcpservers"]}}' | jq -r .team_id)

# 2) BEFORE: key under the team, scoped to server_x only
K1=$(curl -s -X POST $B/key/generate -H "Authorization: Bearer $MK" -H 'Content-Type: application/json' \
  -d "{\"team_id\":\"$TEAM_ID\",\"object_permission\":{\"mcp_servers\":[\"$SX\"]}}" | jq -r .key)
curl -s $B/mcp-rest/tools/list -H "Authorization: Bearer $K1" \
  | jq -c '{total:(.tools|length), whoami:[.tools[].name|select(endswith("_whoami"))]}'
# -> {"total":1,"whoami":["server_x_whoami"]}

# 3) Add a 3rd MCP server, server_z, to the proxy live (via the management API)
SZ=$(curl -s -X POST $B/v1/mcp/server -H "Authorization: Bearer $MK" -H 'Content-Type: application/json' \
  -d '{"server_name":"server_z","transport":"stdio","command":"python","args":["mcp_stdio_server.py","server_z"]}' | jq -r .server_id)

# 4) SCENARIO 1: a NEW key under the same team scoped to server_z works
K2=$(curl -s -X POST $B/key/generate -H "Authorization: Bearer $MK" -H 'Content-Type: application/json' \
  -d "{\"team_id\":\"$TEAM_ID\",\"object_permission\":{\"mcp_servers\":[\"$SZ\"]}}" | jq -r .key)
curl -s $B/mcp-rest/tools/list -H "Authorization: Bearer $K2" \
  | jq -c '{total:(.tools|length), whoami:[.tools[].name|select(endswith("_whoami"))]}'
# -> {"total":1,"whoami":["server_z_whoami"]}

# 5) SCENARIO 2: UPDATING the existing key to add server_z works
curl -s -X POST $B/key/update -H "Authorization: Bearer $MK" -H 'Content-Type: application/json' \
  -d "{\"key\":\"$K1\",\"object_permission\":{\"mcp_servers\":[\"$SX\",\"$SZ\"]}}" >/dev/null
curl -s "$B/key/info?key=$K1" -H "Authorization: Bearer $MK" | jq -c '.info.object_permission.mcp_servers'
# -> ["bdaf0abddc5e2c5d646c6ebc64cdf97a","<server_z id>"]   (persisted immediately)
curl -s $B/mcp-rest/tools/list -H "Authorization: Bearer $K1" \
  | jq -c '{total:(.tools|length), whoami:[.tools[].name|select(endswith("_whoami"))]}'
# -> {"total":2,"whoami":["server_x_whoami","server_z_whoami"]}   (within the management-object cache TTL, 60s by default)

Negative control, proving it is the sentinel and not a blanket allow: a team scoped to server_x only rejects a key that asks for server_z

TEAM2=$(curl -s -X POST $B/team/new -H "Authorization: Bearer $MK" -H 'Content-Type: application/json' \
  -d "{\"team_alias\":\"only-x-team\",\"object_permission\":{\"mcp_servers\":[\"$SX\"]}}" | jq -r .team_id)
curl -s -X POST $B/key/generate -H "Authorization: Bearer $MK" -H 'Content-Type: application/json' \
  -d "{\"team_id\":\"$TEAM2\",\"object_permission\":{\"mcp_servers\":[\"$SZ\"]}}" | jq -c .error
# -> 403: "Key requests MCP servers not allowed by team '...': ['<server_z id>']. Team allows: ['<server_x id>']."

Authorization: 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

# caller = a team admin (internal_user), reaching /team/update via a delegated allowed_routes key
# team T has the user as an 'admin' member and no MCP grant yet
1) TEAM ADMIN grants team all-proxy MCPs (not yet granted):   HTTP 403   -> stored mcp: null
2) PROXY ADMIN grants the same:                               HTTP 200   -> stored mcp: ["all-proxy-mcpservers"]
3) TEAM ADMIN edits that team, sentinel already present:      HTTP 200   (round-trip allowed, not forced to strip)
4) TEAM ADMIN creates a NEW team with the sentinel:           HTTP 403
# 403 body: {"error": "Only a proxy admin can grant a team access to all proxy MCP servers ('all-proxy-mcpservers')."}

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-mcpservers on the team's object_permission.mcp_servers

Screenshot 2026-07-03 at 1 16 37 PM Screenshot 2026-07-03 at 1 16 28 PM Screenshot 2026-07-03 at 1 16 15 PM Screenshot 2026-07-03 at 1 02 04 PM

Type

🆕 New Feature

Changes

Adds an all-proxy-mcpservers sentinel (the already reserved SpecialMCPServerName.all_proxy_servers value) that scopes a team to every MCP server on the proxy

The sentinel is a team-only grant, and the runtime honors it only on the team path. _get_allowed_mcp_servers_for_team expands it to the live get_registry() id set, so a team scoped to it picks up servers registered later with no permission change, and _resolve_team_allowed_mcp_servers expands it too so the ceiling used by validate_key_mcp_servers_against_team covers any server a key asks for, including one added after the team was created. The shared expand_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 id

Granting a team every MCP server on the proxy is a proxy-wide authorization decision, so new_team and update_team now require a proxy admin to newly add the sentinel via enforce_all_proxy_mcp_servers_grant_is_admin_only. Without this a non-proxy-admin who can manage a team (an org admin reaches /team/update by default, and _verify_team_access also admits team admins) could set all-proxy-mcpservers and 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 it

On the dashboard, MCPServerSelector gains an allowAllProxyMcpServers prop that renders an exclusive "All Proxy MCP Servers" option, wired into the team create and edit forms (only for proxy admins) and surfaced in MCPServerPermissions. When a non-proxy-admin (a team admin or org admin, both admitted by canEditTeam) 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 raw all-proxy-mcpservers literal, 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 backend

Scenario 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/info shows. This matches how every other key or team update propagates today and is intentionally left out of scope

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

codecov Bot commented Jul 3, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 92.00000% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...tellm/proxy/management_endpoints/team_endpoints.py 50.00% 1 Missing ⚠️
...roxy/management_helpers/object_permission_utils.py 95.23% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@greptile-apps

greptile-apps Bot commented Jul 3, 2026 •

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR introduces an all-proxy-mcpservers sentinel value that allows a team to be granted access to every MCP server registered on the proxy, with the set resolved dynamically at request time so servers added after team creation are automatically included.

  • Backend: The sentinel is expanded only in the team resolver (_get_allowed_mcp_servers_for_team, _resolve_team_allowed_mcp_servers); the shared expand_permission_list path used by keys, orgs, end-users, and agents deliberately does NOT expand it, so a stale or erroneous sentinel stored on a non-team entity silently grants nothing rather than silently granting everything.
  • Admin gate: enforce_all_proxy_mcp_servers_grant_is_admin_only is called at both new_team and update_team entry points; it reads the existing DB row before raising so a team admin editing a team a proxy admin already scoped to all-proxy is not forced to strip the grant.
  • UI: MCPServerSelector gains an exclusive "All Proxy MCP Servers" option (shown only to proxy admins), and MCPServerPermissions renders a distinct green "All" badge when the sentinel is stored, consistent with the existing "Blocked" / count display pattern.

Confidence Score: 5/5

Safe 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.

Important Files Changed

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>
@veria-ai

veria-ai Bot commented Jul 3, 2026 •

Copy link
Copy Markdown
Contributor

PR overview

All previously flagged issues have been addressed. No open security concerns remain on this pull request.

Security review

No 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
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
@ryan-crabbe-berri

Copy link
Copy Markdown
Contributor Author

@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.
@ryan-crabbe-berri
ryan-crabbe-berri merged commit 57ca48a into litellm_internal_staging Jul 3, 2026
76 checks passed
@ryan-crabbe-berri
ryan-crabbe-berri deleted the litellm_all_proxy_mcps_sentinel branch July 3, 2026 20:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants