fix(mcp): pass tool outputSchema to Vercel AI SDK dynamicTool#1964
fix(mcp): pass tool outputSchema to Vercel AI SDK dynamicTool#1964wucm667 wants to merge 2 commits intoMCPJam:mainfrom
Conversation
MCP tools can declare an outputSchema in their tool description, but the inspector was only using it for client-side validation and UI display. The outputSchema was never included in the structured tool definitions sent to the LLM via the Vercel AI SDK. This fixes the tool converters in both convertMCPToolsToVercelTools and the TestAgent tool conversion to include outputSchema when available, enabling LLMs to correctly interpret all response fields.
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
WalkthroughThis change enhances tool conversion by introducing support for Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
thanks for putting this up @wucm667! i'll merge this tomorrow 🫡 |
Fixes #1956
Problem
When an MCP server declares a tool with an
outputSchema, the inspector reads it for client-side validation and UI display, but does NOT include it in the structured tool definitions sent to the LLM via the Vercel AI SDK. As a result, the LLM cannot interpret custom response fields defined in the output schema.Changes
File 1:
sdk/src/mcp-client-manager/tool-converters.tsoutputSchemafrom the MCP tool description alongsidename,description, andinputSchemaoutputSchematodynamicTool()when available (automatic mode)File 2:
sdk/src/TestAgent.tsoutputSchemain thedynamicTool()call for the test agent's tool conversionImpact
Before this fix, an MCP tool like:
Where
WeatherDatahas a custom fieldx: int, would not pass the output schema to the LLM. The LLM could not interpret thexfield in the response.After this fix, the output schema is included in the tool definition, allowing the LLM to correctly understand and use all response fields.