Preserve MCP tool input schema metadata#6507
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces a JSON Schema to Zod converter (mcpInputSchemaToZodObject) to dynamically transform MCP input schemas into Zod schemas for validation within LangChain MCP tools, along with corresponding unit tests. Feedback highlights several limitations in the current converter implementation—such as lack of support for non-string enums, multi-type fields, implicit types, and default values—and suggests a robust refactoring that also throws errors on invalid input types to promote fail-fast behavior.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
|
Thanks for the review. I addressed the schema converter gaps in
I also added regression coverage in Verified with: Commit pushed: |
Summary
Why
Custom MCP tools can expose parameter metadata through JSON Schema. Passing that schema through directly can drop useful tool argument metadata before it reaches the model/tool interface. Converting the schema into the Zod format expected by LangChain preserves that metadata and keeps validation behavior intact.
Fixes #6497.
Validation
corepack pnpm --dir packages/components exec eslint nodes/tools/MCP/core.ts nodes/tools/MCP/core.test.ts --ext ts --report-unused-disable-directives --max-warnings 0$env:NODE_OPTIONS='--max-old-space-size=4096'; corepack pnpm --dir packages/components exec jest nodes/tools/MCP/core.test.ts --runInBand