Commit graph

35910 commits

Author SHA1 Message Date
Ishaan Jaffer
936f6b8ad5 fix(mcp): handle RecordNotFoundError in update_mcp_toolset; union direct servers with toolset servers 2026-03-23 11:05:32 -07:00
Ishaan Jaffer
97961237f1 fix(mcp): add auth check on toolset resolution in responses API; union mcp_servers in _merge_toolset_permissions 2026-03-23 10:54:57 -07:00
Ishaan Jaffer
e9c4c71a1f fix(mcp): add mcp_toolsets to ObjectPermissionBase, fix multi-toolset overwrite, fix delete 404, allow standalone key toolsets 2026-03-23 10:45:22 -07:00
Ishaan Jaffer
65ae86b407 fix(mcp): toolset access control, asyncio fix, and real unit tests
- server.py: _apply_toolset_scope now enforces that non-admin keys must
  have the requested toolset_id in their mcp_toolsets grant list;
  admin keys always bypass the check.
- mcp_management_endpoints.py: three access-control fixes:
  * fetch_mcp_toolsets: non-admin keys with mcp_toolsets=None now
    return [] instead of all toolsets (only admins get 'all' when
    the field is absent)
  * fetch_mcp_toolset: non-admin keys that haven't been granted the
    requested toolset_id now get 403 instead of the full result
  * add_mcp_toolset: duplicate toolset_name now returns 409 Conflict
    instead of an opaque 500
- proxy_server.py: use asyncio.get_running_loop() instead of
  get_event_loop() inside an already-running coroutine (Python 3.10+).
- test_mcp_toolset_scope.py: replace four hollow tests that only
  asserted local variable properties with real tests that call the
  production fetch_mcp_toolsets() and handle_streamable_http_mcp()
  functions with mocked dependencies.
2026-03-23 10:35:38 -07:00
Ishaan Jaffer
a23b5d5466 fix(mcp): prevent body_iter deadlock + use cached toolset lookup in responses API
- _stream_mcp_asgi_response: add done callback to handler_task that puts
  the EOF sentinel on body_queue when the task exits, preventing body_iter
  from hanging forever if the handler raises after headers are sent.
- litellm_proxy_mcp_handler: replace raw get_mcp_toolset_by_name() DB call
  with global_mcp_server_manager.get_toolset_by_name_cached() so toolset
  resolution uses the 60s TTL cache added for this purpose instead of
  hitting the DB on every responses-API request.
2026-03-23 10:06:54 -07:00
Ishaan Jaffer
399f3f81ba fix(mcp): cache toolset name lookups in MCPServerManager to avoid per-request DB calls 2026-03-21 20:39:55 -07:00
Ishaan Jaffer
03e4a5c9ee test(mcp): add tests for toolset scope enforcement, ContextVar isolation, and access control 2026-03-21 20:35:07 -07:00
Ishaan Jaffer
e883653326 fix(mcp): cache toolset permission lookups to avoid per-request DB calls 2026-03-21 20:34:32 -07:00
Ishaan Jaffer
da6e8a0aad fix(mcp): use ContextVar + StreamingResponse for toolset MCP routes (fixes SSE streaming) 2026-03-21 20:33:51 -07:00
Ishaan Jaffer
b1c682dd53 fix(mcp): replace x-mcp-toolset-id header with ContextVar to prevent client forgery 2026-03-21 20:17:23 -07:00
Ishaan Jaffer
253fd08b72 docs(mcp): add mcp_toolsets to sidebar 2026-03-21 19:01:35 -07:00
Ishaan Jaffer
a6c66625e9 docs(mcp): add MCP Toolsets documentation 2026-03-21 19:01:31 -07:00
Ishaan Jaffer
ab5854d0bf feat(mcp): generate correct server_url for toolsets in playground API calls 2026-03-21 19:01:27 -07:00
Ishaan Jaffer
0de013a06e feat(mcp): pass mcpToolsets to playground chat and responses API calls 2026-03-21 19:01:20 -07:00
Ishaan Jaffer
9d16008ba5 feat(mcp): add Toolsets tab to mcp_servers.tsx 2026-03-21 19:01:16 -07:00
Ishaan Jaffer
b9d8dd5fc5 feat(mcp): add MCPToolsetsTab component for creating and managing toolsets 2026-03-21 19:01:12 -07:00
Ishaan Jaffer
e8cdca5dc9 feat(mcp): pass mcp_toolsets through object_permissions_view 2026-03-21 19:01:06 -07:00
Ishaan Jaffer
a722d95493 feat(mcp): show toolsets section in MCPServerPermissions read view 2026-03-21 19:01:03 -07:00
Ishaan Jaffer
1ef54d25c1 feat(mcp): extract toolsets from combined MCP field in team form 2026-03-21 19:00:58 -07:00
Ishaan Jaffer
b66c20438f feat(mcp): extract toolsets from combined MCP field in key form 2026-03-21 19:00:53 -07:00
Ishaan Jaffer
716aaacad1 feat(mcp): add toolsets (purple) as third option type in MCPServerSelector 2026-03-21 19:00:49 -07:00
Ishaan Jaffer
b448c44001 feat(mcp): add useMCPToolsets React Query hook 2026-03-21 19:00:43 -07:00
Ishaan Jaffer
95c4c7097a feat(mcp): add fetchMCPToolsets, createMCPToolset, updateMCPToolset, deleteMCPToolset API functions 2026-03-21 19:00:38 -07:00
Ishaan Jaffer
3de93154d3 feat(mcp): add MCPToolset and MCPToolsetTool TypeScript types 2026-03-21 19:00:31 -07:00
Ishaan Jaffer
261471ff91 feat(mcp): register toolset routes in proxy_server.py 2026-03-21 19:00:12 -07:00
Ishaan Jaffer
fc1558f6a9 feat(mcp): validate mcp_toolsets in key-vs-team permission check 2026-03-21 18:59:37 -07:00
Ishaan Jaffer
7ac2e590be feat(mcp): register LiteLLM_MCPToolsetTable in prisma client initialization 2026-03-21 18:59:20 -07:00
Ishaan Jaffer
8b338cdf39 feat(mcp): add mcp_toolsets field to LiteLLM_ObjectPermissionTable type 2026-03-21 18:59:05 -07:00
Ishaan Jaffer
848f3666d0 fix(mcp): resolve toolset names in responses API before fetching tools 2026-03-21 18:58:41 -07:00
Ishaan Jaffer
4f3c46bf0c feat(mcp): add _apply_toolset_scope and toolset route handling in server.py 2026-03-21 18:58:04 -07:00
Ishaan Jaffer
bdeb94627e fix(mcp): skip allow_all_keys servers when explicit mcp_servers permission is set (toolset scope fix) 2026-03-21 18:57:23 -07:00
Ishaan Jaffer
0d47695948 feat(mcp): add toolset CRUD endpoints to mcp_management_endpoints 2026-03-21 18:56:52 -07:00
Ishaan Jaffer
0785b3a33a feat(mcp): add toolset_db.py with CRUD helpers for MCPToolset 2026-03-21 18:56:01 -07:00
Ishaan Jaffer
5f82916fbb feat(mcp): add MCPToolset Python types 2026-03-21 18:55:52 -07:00
Ishaan Jaffer
ef5b7bc62d feat(mcp): add prisma migration for MCPToolset table 2026-03-21 18:55:48 -07:00
Ishaan Jaffer
ed47c9464b feat(mcp): add LiteLLM_MCPToolsetTable and mcp_toolsets to ObjectPermissionTable 2026-03-21 18:55:42 -07:00
yuneng-jiang
d8e4fc4dd0
Merge pull request #24260 from BerriAI/litellm_yj_march_19_2026
[Infra] Merge internal dev branch with main
2026-03-20 17:35:19 -07:00
yuneng-jiang
2ca4fa6189
Merge branch 'main' into litellm_yj_march_19_2026 2026-03-20 17:28:41 -07:00
yuneng-jiang
e6e3085845
Merge pull request #24258 from joereyna/fix/anthropic-file-content-test-mock
fix(test): mock get_auth_header instead of get_api_key in anthropic file content test
2026-03-20 16:14:59 -07:00
yuneng-jiang
e678ddea43 Fix unreachable special MCP server name guard in add_mcp_server
The special name check (all_team_servers, all_proxy_servers) was an elif
after the server_id-is-not-None check, making it unreachable since special
names are non-None strings. Split into separate if blocks so the special
name guard runs before the duplicate-ID check.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-20 16:12:48 -07:00
joereyna
f0e0d98f86 fix(test): mock get_auth_header instead of get_api_key in anthropic file content test 2026-03-20 16:07:09 -07:00
yuneng-jiang
6862930538 Revert test to match reverted team MCP manager feature
The team MCP manager feature was reverted in PR #24255, so the test
needs to go back to the original single auth failure test that expects
a 403 for non-admin users.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-20 15:44:00 -07:00
yuneng-jiang
1fad0d557d
Merge pull request #24255 from BerriAI/revert-24171-litellm_/awesome-dhawan
Revert "[Feature] Team MCP Server Manager Role"
2026-03-20 15:42:10 -07:00
yuneng-jiang
c9683c6f97
Revert "[Feature] Team MCP Server Manager Role" 2026-03-20 15:41:57 -07:00
ryan-crabbe
72c307df0e
Merge pull request #24217 from BerriAI/litellm_ryan_march_18
feat: add control plane for multi-proxy worker management
2026-03-20 14:05:19 -07:00
Ryan Crabbe
541863a566 Merge branch 'litellm_ryan_march_18' of https://github.com/BerriAI/litellm into litellm_ryan_march_18 2026-03-20 13:58:32 -07:00
Ryan Crabbe
6f81eb01fe fix: apply Black formatting to ui_sso.py 2026-03-20 13:57:26 -07:00
ryan-crabbe
59b4a05782
Merge branch 'main' into litellm_ryan_march_18 2026-03-20 13:36:37 -07:00
yuneng-jiang
ba4aae02c7 Fix outdated MCP server auth test for team MCP manager flow
The test_create_mcp_server_auth_failure test expected a 403 for non-admin
users, but the team MCP manager feature changed the auth flow to first
check for team_id (400) before checking permissions. Split into two tests:
one for missing team_id (400) and one for non-manager rejection (403).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-20 13:10:10 -07:00
yuneng-jiang
5d317c3a5c Merge remote-tracking branch 'origin' into litellm_yj_march_19_2026 2026-03-20 12:59:21 -07:00