Commit Graph

71 Commits

Author SHA1 Message Date
Sameer Kankute 082c8af37f Fix: litellm user auth not passing issue 2025-12-02 11:25:32 +05:30
YutaSaito b72b49757e feat: add backend support for OAuth2 auth_type registration via UI (#17006) 2025-11-23 21:52:18 -08:00
Ishaan Jaffer b2812af0a0 fix MCP tests 2025-11-22 10:02:15 -08:00
YutaSaito 93affcb732 [Feat] mcp resources support (#16800)
* feat: mcp prompts support

* feat: mcp resources support
2025-11-20 14:53:44 -08:00
YutaSaito 0b586d26fc refactor: drop MCPClient.connect and use run_with_session lifecycle (#16696)
Surface detailed connection errors by handling HTTP failures
2025-11-15 17:54:27 -08:00
Ishaan Jaffer 0699430206 test logging tests + mcp server QA checks 2025-11-15 08:58:46 -08:00
YutaSaito f487f4e3a9 feat: add dynamic OAuth2 metadata discovery for MCP servers (#16676)
* feat: add dynamic OAuth2 metadata discovery for MCP servers

* fix: lint error
2025-11-14 18:14:43 -08:00
YutaSaito 2843dab7fe fix: allow tool call even when server name prefix is missing (#16425)
* fix: allow tool call even when server name prefix is missing

* fix: test

* fix: test

* fix: test
2025-11-12 13:50:52 -08:00
YutaSaito 8e27b6c0b4 [MCP] configure static mcp header (#16179)
* feat: configure extra mcp headers in ui

* doc: static header

* build: add new migration file

* chore: add missing image file

* fix: test
2025-11-03 21:06:36 -08:00
Talal 5e10ea4136 Improve(mcp): respect X-Forwarded- headers in OAuth endpoints (#16036)
* fix(mcp): respect X-Forwarded-Proto header in OAuth endpoints

When LiteLLM proxy is deployed behind a reverse proxy (like nginx or a load balancer) that terminates SSL/TLS, the proxy receives HTTP requests internally but should expose HTTPS URLs externally. This change detects the X-Forwarded-Proto header and uses it to construct correct redirect URIs and endpoint URLs.

Changes:
- Added X-Forwarded-Proto detection to authorize, token, oauth_protected_resource_mcp, oauth_authorization_server_mcp, and register_client endpoints
- Added comprehensive tests for X-Forwarded-Proto header support across all affected endpoints
- Fixed existing tests to properly mock request.headers

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* fix formatting

* feat(mcp): support X-Forwarded-Host for proxy base URL reconstruction

Extended X-Forwarded-Proto support to also handle X-Forwarded-Host and X-Forwarded-Port headers. This allows LiteLLM to correctly construct redirect URIs and endpoint URLs when deployed behind a reverse proxy that changes the host/port.

Example scenario:
- Internal URL: http://localhost:8888/github/mcp
- External URL: https://proxy.abc.com/github/mcp
- Proxy sets: X-Forwarded-Proto: https, X-Forwarded-Host: proxy.abc.com

Changes:
- Added get_request_base_url() helper function to centralize X-Forwarded-* header handling
- Replaced all inline X-Forwarded-Proto checks with calls to the helper function
- Helper handles X-Forwarded-Proto, X-Forwarded-Host, and X-Forwarded-Port
- Added tests for X-Forwarded-Host scenarios in authorize and token endpoints

Fixes issue where protected resource URL mismatch occurred:
  Error: Protected resource http://proxy.abc.com:8888/github/mcp
  does not match expected https://proxy.abc.com/github/mcp

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* chore: replace Yelp-specific hostnames with generic examples

Changed all references from chatproxy.yelpcorp.com to proxy.example.com in:
- test_proxy_forwarding.py (default host parameter)
- TEST_PROXY_FORWARDING.md (documentation examples)
- discoverable_endpoints.py (docstring example)
- test_discoverable_endpoints.py (test mock data)

This makes the code more generic and suitable for open source.
All 13 tests still passing.

* remove accidentally added files

* fix formatting

* add new test for get_base_url

---------

Co-authored-by: Claude <noreply@anthropic.com>
2025-10-29 19:11:32 -07:00
YutaSaito c0890e7d33 [Feat] add support for dynamic client registration (#15921) (enables Atlassian MCP to work via Oauth on LiteLLM)
* feat: add support for dynamic client registration #13856

* fix: test

* feat: return 401 when oauth2_header is missing for OAuth2-based MCP servers
2025-10-26 10:13:46 -07:00
Talal 46d55bd92a fix: Add response_type + PKCE parameters to OAuth authorization endpoint (#15720)
* fix: Add response_type parameter to OAuth authorization endpoint

Fixes #15684

OAuth providers like Google require the response_type parameter during
the authorization flow. This commit adds response_type=code to the
authorization redirect parameters, which is required by the OAuth 2.0
specification (RFC 6749 Section 4.1.1).

Changes:
- Added response_type=code to authorization params in discoverable_endpoints.py
- Added test coverage for the response_type parameter

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* fix oauth flow by forwarding code_challenge and forwarding code_verifier

---------

Co-authored-by: Claude <noreply@anthropic.com>
2025-10-21 09:43:19 -07:00
Krrish Dholakia ace862189c test(test_mcp_server_manager.py): add unit testing 2025-10-09 14:52:46 -07:00
Krish Dholakia d921df1baf Merge pull request #15343 from BerriAI/litellm_dev_10_08_2025_p1
MCP - support converting OpenAPI specs to MCP servers
2025-10-08 19:10:04 -07:00
Ishaan Jaffer c4022ade49 test mapped tests MCP 2025-10-08 18:34:30 -07:00
Krrish Dholakia cd13e533a2 feat(mcp_server_manager.py): expand allowed/disallowed list 2025-10-08 16:06:17 -07:00
Krrish Dholakia 28698933fc feat(mcp_server_manager.py): ensure list tools for openapi servers works as expected 2025-10-08 15:59:42 -07:00
Ishaan Jaffer e1ab3620ee fix: mapped tests 2025-10-07 17:55:52 -07:00
Ishaan Jaff 36c971a6fd [MCP Gateway] QA/Fixes - Ensure Team/Key level enforcement works for MCPs (#15305)
* fix: _set_object_permission

* fix: _set_object_permission on teams

* fix: _set_object_permission

* fixes for team/key permissions

* statsh: object permission view

* fix: MCPServerPermissions

* fix: _get_team_object_permission

* test mcp checks for permissions

* fix server checks with prefix names

* test_list_tools_strips_prefix_when_matching_permissions

* ruff fix

* docs - refactor MCP

* docs update MCP docs

* docs allowed tools
2025-10-07 17:34:48 -07:00
Ishaan Jaff 930f88078e [MCP Gateway] Backend - Allow storing allowed tools by team/key (#15243)
* add mcp_tool_permissions column to LiteLLM_ObjectPermissionTable

* add mcp_tool_permissions

* add LiteLLM_ObjectPermissionTable

* test key/team mgmt

* fix code QA check

* fix check_tool_permission_for_key_team

* test_key_tool_permission_allows_permitted_tool

* test_list_tools_filters_by_key_team_permissions

* fix _get_tools_from_mcp_servers

* fix logger.debug

* fix check_tool_permission_for_key_team

* fix: filter_tools_by_key_team_permissions

* fix _get_team_object_permission

* fix _set_object_permission

* fix handle_update_object_permission_common

* fix add allowed tools to keys

* test add key/team level tool permissions for MCPs
2025-10-06 18:49:32 -07:00
Krrish Dholakia 2d1000c461 test: update tests 2025-10-04 15:31:25 -07:00
Krish Dholakia a9037ab61f Merge branch 'main' into litellm_dev_10_03_2025_p1 2025-10-04 15:23:31 -07:00
Krrish Dholakia 3816d3b36f test: add unit testing 2025-10-03 17:27:49 -07:00
Krrish Dholakia c043ad6c2b fix: replace list in for set in
faster
2025-10-03 17:17:20 -07:00
Krrish Dholakia 69edc546c0 fix(mcp_server_manager.py): don't return an invalid server id on list servers
Prevents user from hitting 'server not found' error, even when they see it being listed on litellm ui
2025-10-03 17:15:15 -07:00
Yuta Saito 359aaa947f test: fix test_mcp_server.py 2025-10-04 08:18:15 +09:00
rishiganesh2002 d36c8d6bbe [Feat] MCP Gateway Fine-grained Tools Addition (#15153)
* feat: UI to add specific tools under creating MCP connection

* chore: pydantic + prisma changes

* feat: adding specific MCP tools now works

* fix: allowed tools filtering

* chore: filtered list to mcp server cost config

* chore: update Readme

* chore: refactor the filtering

* test: Added tests

When the allowed_tests is null, empty list or populated

* chore: resolve the proxy issue

* feat: updating MCP tool filtering
2025-10-03 10:16:29 -07:00
Krrish Dholakia 0cd61a6a6a fix: simplify testing 2025-09-30 12:37:25 -07:00
Krrish Dholakia 9ed83d44e3 test: remove unnecessary test 2025-09-29 13:35:34 -07:00
Krrish Dholakia bc6e6e7a28 fix(auth_checks.py): add auth checks to mcp server on call tools 2025-09-29 13:13:10 -07:00
Krish Dholakia 0d738b2899 Merge pull request #14986 from uc4w6c/fix/remove-servername-prefix-mcp_tools-tests
Fix/remove servername prefix mcp tools tests
2025-09-28 18:00:23 -07:00
Krrish Dholakia f32b0364c4 fix: fix tests 2025-09-28 17:55:46 -07:00
Yuta Saito dae7d08ff2 Revert "Revert "Merge pull request #14720 from uc4w6c/feat/remove-servername-prefix-mcp_tools""
This reverts commit a88d774f94.
2025-09-29 07:12:24 +09:00
Krrish Dholakia 53d0cbb1b7 fix: update tests + logic for passing multiple headers 2025-09-28 09:09:11 -07:00
Krrish Dholakia 526156ed9d feat(mcp/): allows admin to prevent llm's from accidentally deleting github repo's even if user is allowed to do this 2025-09-27 19:36:11 -07:00
Krrish Dholakia 0ff7177373 feat(user_api_key_auth_mcp.py): pass extra headers from clientside straight through - allow multiple clientside headers
Closes LIT-952
2025-09-27 17:11:06 -07:00
Krrish Dholakia 5cdeb63cdd test: fix tests 2025-09-27 11:09:25 -07:00
Krrish Dholakia 7278ae5305 test: fix tests 2025-09-27 10:03:54 -07:00
Krrish Dholakia ac09d29c0e test(tests/): add unit test to confirm oauth2 headers forwarded on receipt 2025-09-27 09:30:07 -07:00
Ishaan Jaffer a88d774f94 Revert "Merge pull request #14720 from uc4w6c/feat/remove-servername-prefix-mcp_tools"
This reverts commit 7216983f48, reversing
changes made to e377e30e95.
2025-09-23 14:14:43 -07:00
Krish Dholakia e912b89549 Merge branch 'main' into feat/remove-servername-prefix-mcp_tools 2025-09-22 22:43:12 -07:00
Uzair Ali 3e9540f589 feat: enable custom fields in mcp_info configuration (#14794)
Allow proxy admins to add arbitrary metadata fields to MCP servers
in config.yaml under mcp_servers.<server>.mcp_info, similar to how
model_info already works.

Changes:
- Changed MCPInfo from TypedDict to Dict[str, Any] for flexibility
- Updated load_servers_from_config to preserve all custom fields
- Updated add_update_server to handle arbitrary fields from database
- Added comprehensive unit tests covering all scenarios
2025-09-22 21:15:35 -07:00
Ishaan Jaffer c3f150b13d mcp test fix 2025-09-19 17:41:15 -07:00
Yuta Saito 7d93856c93 fix: correct mistake introduced during conflict resolution 2025-09-20 06:44:06 +09:00
Yuta Saito a8059f80f4 feat: remove server_name prefix from list_tools when only one server is present (#14504) 2025-09-19 18:29:43 +09:00
Yuta Saito 7f8b1d0708 test: fix failing tests after conflict resolution 2025-09-19 07:48:37 +09:00
Yuta Saito 654f1d3290 fix: stop including spec_version in MCP server registration inserts 2025-09-19 07:06:15 +09:00
Yuta Saito 6c291093e9 fix: remove adding Mcp-Protocol-Version header (#14069)
The Mcp-Protocol-Version header is already handled in the MCP Python SDK, so the explicit addition on LiteLLM Proxy was redundant.
2025-09-19 07:05:20 +09:00
Krrish Dholakia 00d8dedd16 test: update test 2025-09-17 17:44:14 -07:00
Krrish Dholakia 1954bbffc0 test: fix test on ci/cd 2025-09-17 16:53:07 -07:00