-
-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Feat/mcp preserve tool metadata calltoolresult #17341
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Feat/mcp preserve tool metadata calltoolresult #17341
Conversation
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.
…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
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Afroz Ahmad seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
|
@aahmadseph what is the problem this is trying to solve? cc: @uc4w6c |
|
@aahmadseph @krrishdholakia |

Title
Relevant issues
Pre-Submission checklist
Please complete all items before asking a LiteLLM maintainer to review your PR
tests/litellm/directory, Adding at least 1 test is a hard requirement - see detailsmake test-unitType
🆕 New Feature
🐛 Bug Fix
🧹 Refactoring
📖 Documentation
🚄 Infrastructure
✅ Test
Changes