Commit Graph

93 Commits

Author SHA1 Message Date
Yuta Saito 6a60b3d848 test: completions mcp output test 2026-01-23 15:17:14 +09:00
Yuta Saito ed67bf2705 feat: Add MCP tools response to chat completions 2026-01-22 15:32:04 +09:00
Yuta Saito ab11ceff32 tests: patch MCP client mocks via module alias to avoid real network calls 2026-01-20 12:31:27 +09:00
Yuta Saito 51cf782292 chore: switch experimental client to streamable_http_client API 2026-01-20 07:37:50 +09:00
YutaSaito bb7aad9de1 Merge pull request #19319 from BerriAI/litellm_test_mcp_integration
[test] mcp integration test
2026-01-19 14:38:02 +09:00
Yuta Saito 44a166a792 fix: ci mcp version up 2026-01-19 14:27:00 +09:00
Yuta Saito a141aa6026 test: temporary skip 2026-01-19 13:57:40 +09:00
Yuta Saito 1fbbe0a983 test: restore global MCP server manager after access-group test 2026-01-19 12:29:37 +09:00
Yuta Saito 30c4a38179 test: const 2026-01-19 12:03:26 +09:00
Yuta Saito 20b6468222 test: refactor 2026-01-19 11:17:44 +09:00
Yuta Saito c2b5e9c669 test: MCP E2E streamable_http 2026-01-19 11:12:36 +09:00
Yuta Saito 737fec600f test: add mcp e2e test 2026-01-19 10:49:39 +09:00
Yuta Saito d31c609600 test: Let MCP tool-execution mock accept new kwargs for streaming tests 2026-01-19 07:00:14 +09:00
Yuta Saito 4ad78236ab test: Fail MCP streaming test when LiteLLM logs errors during follow-up calls 2026-01-19 06:46:39 +09:00
Yuta Saito cd19039e39 test: Parametrize MCP streaming test to cover OpenAI and Anthropic models 2026-01-19 06:22:05 +09:00
Yuta Saito 1c2942d808 test: add mcp completions test 2026-01-15 15:47:45 +09:00
Yuta Saito df37770a70 test: add permission test 2026-01-14 07:58:21 +09:00
Yuta Saito 35f9a75d55 feat: add UI support for configuring meta URLs 2026-01-02 15:07:37 +09:00
Yuta Saito 34b500c7f5 feat: support MCP stdio header env overrides 2025-12-22 12:58:31 +09:00
Yuta Saito ed5cbdac2f feat: add support for using MCPs on /chat/completions 2025-12-10 10:55:33 +09:00
YutaSaito b5133c4c7d Feat/mcp preserve tool metadata calltoolresult (#17561)
* feat(mcp): preserve tool metadata and full CallToolResult in MCP gateway

This PR fixes two issues that prevented ChatGPT from rendering MCP UI widgets
when proxied through LiteLLM:

1. Preserve Tool Metadata in tools/list
   - Modified _create_prefixed_tools() to mutate tools in place instead of
     reconstructing them, preserving all fields including metadata/_meta
   - This ensures ChatGPT can see 'openai/outputTemplate' URIs in tools/list
     and will call resources/read to fetch widgets

2. Preserve Full CallToolResult (structuredContent + metadata)
   - Changed call_mcp_tool() and _handle_managed_mcp_tool() to return full
     CallToolResult objects instead of just content
   - Updated error handlers to return CallToolResult with isError flag
   - Wrapped local tool results in CallToolResult objects
   - This preserves structuredContent and metadata fields needed for widget rendering

Files changed:
- litellm/proxy/_experimental/mcp_server/mcp_server_manager.py
- litellm/proxy/_experimental/mcp_server/server.py

Fixes issues where ChatGPT could not render MCP UI widgets when using
LiteLLM as an MCP gateway.

* feat(mcp): Preserve tool metadata and return full CallToolResult for ChatGPT UI widgets

- Preserve metadata and _meta fields when creating prefixed tools
- Return full CallToolResult instead of just content list
- Ensures ChatGPT can discover and render UI widgets via openai/outputTemplate
- Fixes metadata stripping that prevented widget rendering in ChatGPT

Changes:
- mcp_server_manager.py: Mutate tools in place to preserve all fields including metadata
- server.py: Return CallToolResult with structuredContent and metadata preserved
- Added test to verify metadata preservation

* fix: guard cost calculator when BaseModel lacks _hidden_params

---------

Co-authored-by: Afroz Ahmad <aahmad@Afrozs-MacBook-Pro.local>
Co-authored-by: Afroz Ahmad <aahmad@KNDMCPTMZH3.sephoraus.com>
2025-12-05 16:15:22 -08:00
Ishaan Jaffer 6530749c89 test fixes 2025-11-26 11:42:12 -08:00
YutaSaito b72b49757e feat: add backend support for OAuth2 auth_type registration via UI (#17006) 2025-11-23 21:52:18 -08:00
YutaSaito f0b10b854b chore: remove unused MCP_PROTOCOL_VERSION_HEADER_NAME constant (#17008) 2025-11-23 21:51:11 -08:00
Ishaan Jaffer 0c28af8705 test MCP server 2025-11-22 10:02:15 -08:00
Ishaan Jaffer fc0eac2d10 test_get_tools_from_mcp_servers 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
yuneng-jiang 00ecb99f3e [Fix] UI MCP Tool Test Regression (#16695)
* Fix UI MCP testing tool regression

* Fixed linting
2025-11-15 15:31:04 -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 8e0b66a814 fix: exclude unauthorized MCP servers from allowed server list (#16551)
* fix: exclude unauthorized MCP servers from allowed server list

* fix: test after resolving merge conflicts
2025-11-13 12:33:54 -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 6eb74bd62a Feat/persist mcp credentials in db (#16308)
* feat: persist mcp credentials in db

* feat: remove Auth Value field from MCP Tool Testing Playground

* fix: test
2025-11-07 19:22:49 -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
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
Vinod Singh d4aadda692 Auth Header Fix for MCP Tool Call (#15736)
* fixed the Auth header for MCP Tool Call

* Final fix for Auth header

* testcase for mcp_auth_header_extraction, insensitive_alias_matching, insensitive_servername_matching added
2025-10-21 13:58:03 -07:00
Yuta Saito 5359a0d6a6 fix: test 2025-09-30 07:25:32 +09:00
Yuta Saito be5010a675 test: fix tests 2025-09-29 07:21:32 +09:00
Krrish Dholakia 9403efa511 test: fix tests 2025-09-28 08:54:15 -07:00
Krrish Dholakia 1256dd53d9 test: update tests 2025-09-28 08:53:11 -07:00
Krrish Dholakia 340262c85f feat(server.py): only show allowed mcp tools 2025-09-27 20:57:12 -07:00
Krrish Dholakia 5d6889dc92 test: update tests 2025-09-27 10:40:06 -07:00
Ishaan Jaffer a6795a6560 test fix 2025-09-19 18:05:36 -07:00
Ishaan Jaffer dec15a80a2 test: mcp test fix 2025-09-19 17:52:32 -07:00
Ishaan Jaffer c3f150b13d mcp test fix 2025-09-19 17:41:15 -07: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
Ishaan Jaff a13aa4740a [Fixes] Bug fixes to using LiteLLM MCP Gateway (#14392)
* fix: use _get_mcp_servers_in_path

* fix checks for using litellm_proxy as MCP tool provider

* fix: fix mcp_tools_with_litellm_proxy

* fix: fix aresponses_api_with_mcp

* aresponses_api_with_mcp

* test_mcp_allowed_tools_filtering

* fix: _filter_mcp_tools_by_allowed_tools

* fix: _filter_mcp_tools_by_allowed_tools

* test_streaming_responses_api_with_mcp_tools

* fixes: test tools transfrom MCP->OpenaI spec

* test_streaming_responses_api_with_mcp_tools

* fix: chat ui allow multi select with allowed tools

* fix: use correct MCP events with litellm proxy response API

* fix get_event_model_class

* fix litellm proxy MCP handler

* fix MCPEnhancedStreamingIterator

* chat ui show list tools result

* UI: show MCP events

* fix stream iterator

* fixes: litellm proxy mcp handler

* test responses + mcp

* fix: update responses api with mcp handling

* ruff check fix

* central: _process_mcp_tools_to_openai_format

* fix: refactor code

* test_mcp_allowed_tools_filtering

* test mcp with litellm proxy

* fix mcp call

* demo: video using MCP ui

* fixes for using stream iterator

* test_no_duplicate_mcp_tools_in_streaming_e2e

* docs fix

* fix code snippet
2025-09-10 19:12:11 -07:00
Ishaan Jaff 1f42e41c8d [Bug]: Fix Authorization header not being sent to configured MCP servers (#14422)
* test: test_mcp_server_config_auth_value_header_used

* fix: authentication_token

* docs: fix instructions on using responses api with MCPs

* mcp fixes
2025-09-10 16:41:08 -07:00
Ishaan Jaff 68d250973c [Feature]: Support "Token" MCPAuth (#14359)
* add MCPAuth.authorization type

* test: Token Auth MCP

* fix: _get_auth_headers to handle auth_type == MCPAuth.authorization

* docs auth types with MCP on config.yaml

* test_mcp_server_works_without_config_auth_value
2025-09-08 18:25:41 -07:00