fix: include mcp_tool_permissions server ids in allowed mcp servers#22311
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
|
Greptile SummaryThis PR fixes a bug where servers listed only in
Confidence Score: 4/5
|
| Filename | Overview |
|---|---|
| litellm/proxy/_experimental/mcp_server/auth/user_api_key_auth_mcp.py | Adds mcp_tool_permissions keys to the allowed server set in all three _get_allowed_mcp_servers_for_* functions. Changes are consistent, guarded against None, and deduplicated via set(). |
| tests/test_litellm/proxy/_experimental/mcp_server/auth/test_user_api_key_auth_mcp.py | Adds a regression test verifying servers in mcp_tool_permissions (but not in mcp_servers) are returned in the allowed list. Uses mocks only — no real network calls. Only tests the key function; team and end_user functions are not explicitly tested for this new behavior. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[get_allowed_mcp_servers] --> B[_get_allowed_mcp_servers_for_key]
A --> C[_get_allowed_mcp_servers_for_team]
A --> D[_get_allowed_mcp_servers_for_end_user]
B --> B1[direct mcp_servers]
B --> B2[access_group servers]
B --> B3[mcp_tool_permissions keys ✨ NEW]
B1 & B2 & B3 --> B4["union + deduplicate (set)"]
C --> C1[direct mcp_servers]
C --> C2[access_group servers]
C --> C3[mcp_tool_permissions keys ✨ NEW]
C1 & C2 & C3 --> C4["union + deduplicate (set)"]
D --> D1[direct mcp_servers]
D --> D2[access_group servers]
D --> D3[mcp_tool_permissions keys ✨ NEW]
D1 & D2 & D3 --> D4["union + deduplicate (set)"]
B4 --> E{Both key & team\nhave servers?}
C4 --> E
E -->|Yes| F[Intersection of key ∩ team]
E -->|No| G[Inherit from whichever has servers]
F --> H{end_user has servers?}
G --> H
H -->|Yes| I[Intersection with end_user]
H -->|No| J[Final allowed servers]
I --> J
Last reviewed commit: 0502200
when a key/team/end-user has mcp_tool_permissions for a server but that server is not in mcp_servers, the server was excluded from the allowed list — making the tool permissions useless. now we union the keys from mcp_tool_permissions into the allowed server set alongside direct servers and access group servers. fixes BerriAI#21954
0502200 to
9ad552f
Compare
e3e9ac5
into
BerriAI:litellm_oss_staging_02_28_2026
when a key/team/end-user has mcp_tool_permissions for a server but that server isn't in mcp_servers, the server was excluded from the allowed list — making the tool permissions useless.
now we union the keys from mcp_tool_permissions into the allowed server set in all three functions: _get_allowed_mcp_servers_for_key, _get_allowed_mcp_servers_for_team, _get_allowed_mcp_servers_for_end_user.
test verifies that a server appearing only in tool_permissions is returned in the allowed list.
fixes #21954