fix: mcp_tool_to_langchain silently drops odata parameters whose name… - #355
Open
NicoleMGomes wants to merge 4 commits into
Open
NicoleMGomes wants to merge 4 commits into
NicoleMGomes wants to merge 4 commits into
Conversation
NicoleMGomes
marked this pull request as ready for review
September 29, 2026 16:43
cassiofariasmachado
approved these changes
Sep 29, 2026
This branch has not been deployed
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
mcp_tool_to_langchaininconverters.pywas callingpydantic.create_modelwith OData property names directly. Pydantic v2 rejects field names starting with_(raised asNameErrorin newer versions, silently dropped in older ones). Because OData CSDL §15.2 explicitly allows_as a valid first character for identifiers (e.g._VariantConfiguration,_Product), any agent usingmcp_tool_to_langchainagainst an OData MCP server with_-prefixed parameters received a broken tool schema — those parameters were invisible to the LLM and tool calls would fail or produce wrong results.Important: passing the JSON Schema dict directly as
args_schemadoes not work — LangChain internally converts any dict back to a Pydantic model, so the problem persists. The fix instead builds an internalname_mapthat strips leading underscores before passing field names tocreate_model, then restores the original OData names insiderun()before forwarding kwargs tocall_tool. This is transparent to callers.Type of Change
How to Test
MCPToolwhoseinput_schemacontains a_-prefixed property:"VariantConfiguration"(stripped) appears as a required field inlc_tool.args_schema.model_fields.call_toolreceives_VariantConfiguration(restored):uv run pytest tests/agentgateway/unit/test_converters.py -vChecklist
Additional Notes
Teams affected: any agent using
mcp_tool_to_langchainagainst an OData MCP server (e.g. S/4HANA, EWM). The EWM warehouse agent shipped a local_sanitize_mcp_tool_schemaworkaround for this; that workaround is now redundant.