fix: mcp tool converter sending none values#180
Merged
Conversation
85daa74 to
9c31104
Compare
cassiofariasmachado
previously approved these changes
Jun 23, 2026
98461bf to
4303453
Compare
cassiofariasmachado
previously approved these changes
Jun 24, 2026
The merge-base changed after approval.
91b6245 to
08d7c41
Compare
cassiofariasmachado
approved these changes
Jun 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes
mcp_tool_to_langchainin the Agent Gateway converter so that optional MCP tool parameters are no longer forwarded tocall_mcp_toolasNonevalues, and adds anomit_noneconfiguration option to control this behaviour.Root cause: Optional fields in the generated Pydantic
args_schemawere typed asstr | Nonewith a plainNonedefault. LangChain passes all schema fields — including optional ones the LLM did not supply — to the tool'srunclosure as keyword arguments. This causedcall_mcp_toolto receive explicitNonefor every optional parameter, which breaks downstream MCP tool invocations that distinguish between an absent parameter and a null one.Changes:
str | NonewithField(default=None)so Pydantic acceptsNonefrom LangChain's validation layer, while the field is still not inrequired.runclosure stripsNonevalues fromkwargsbefore forwarding tocall_tool(controlled by the newomit_noneflag).omit_none: bool = Trueonmcp_tool_to_langchain— set toFalseto forwardNonevalues explicitly to the MCP server._make_tool()fixture removes duplication; newTestMcpToolToLangchainInvocationclass covers end-to-end LangChain tool invocation including theomit_none=Falsepath.# ty: ignorecomments fromtests/adms/unit/test_client.pyandtests/destination/unit/test_client.pythat causedtytype-check pre-commit failures.Type of Change
How to Test
uv syncomit_none=FalseforwardsNoneexplicitly:uvx pre-commit run --all-filesChecklist
Additional Notes
omit_noneis keyword-only (declared after*) to prevent positional misuse. The defaultTruepreserves existing behaviour — no changes needed for current callers.