fix: mcp parameter fields are being dropped - #362
Merged
Merged
Conversation
cassiofariasmachado
previously approved these changes
Oct 1, 2026
cassiofariasmachado
approved these changes
Oct 1, 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
mcp_tool_to_langchaininsap_cloud_sdk.agentgateway.converterswas silently dropping all JSON Schema property metadata other thantypeandrequired. This meant fields likedescription,enum,format,examples,minimum/maximum,pattern, and others were never forwarded to the Pydantic model or the LangChain tool schema — so the LLM had no visibility into allowed values, constraints, or hints.The fix introduces a two-bucket mapping strategy:
Fieldkwargs (description,title,examples,deprecated,pattern,minLength/maxLength→min_length/max_length,minimum/maximum→ge/le,exclusiveMinimum/exclusiveMaximum→gt/lt,multipleOf) are forwarded directly asField(...)keyword arguments with the required camelCase → snake_case translation. These are also enforced at Pydantic validation time.enum,default,example,const,format,contentEncoding,uniqueItems,items,properties,required,additionalProperties,oneOf,anyOf,allOf) are collected intojson_schema_extraso they pass through verbatim intomodel_json_schema()and reach the LLM.x-custom-*) are silently ignored — no crash.The full set of fields emitted by the MCP builder (
type,description,title,enum,default,examples,example,const,maxLength,minimum,pattern,format,contentEncoding,uniqueItems,items,properties,additionalProperties,oneOf/anyOf/allOf) are now all handled.Related Issue
Closes #
Type of Change
How to Test
pip install sap-cloud-sdk[langchain]MCPToolwith a richinput_schema— includedescription,enum,format,minimum,maxLength, andexampleson properties.mcp_tool_to_langchain(tool, call_tool, get_user_token).lc_tool.args_schema.model_json_schema()["properties"]— all metadata fields should be present on each property.maxLengthor belowminimumand confirm aValidationErroris raised.uv run pytest tests/agentgateway/unit/test_converters.py -vChecklist
Additional Notes
enumis intentionally forwarded viajson_schema_extrarather than as aLiteraltype — it serves as a hint to the LLM, not a Python validation constraint. This matches how MCP tool schemas are intended to be used.defaultfrom the MCP schema is also injson_schema_extra(notField(default=...)), because MCP'sdefaultis a documentation hint; promoting it to a Python default would silently make required fields optional.examplesfield is native to Pydantic v2'sFieldand goes through the native path.