Title: mcp_tool_to_langchain parameters conversion error · Issue #190 · SAP/cloud-sdk-python · GitHub
Open Graph Title: mcp_tool_to_langchain parameters conversion error · Issue #190 · SAP/cloud-sdk-python
X Title: mcp_tool_to_langchain parameters conversion error · Issue #190 · SAP/cloud-sdk-python
Description: Describe the Bug Bug Description mcp_tool_to_langchain in src/sap_cloud_sdk/agentgateway/converters.py builds the Pydantic args schema with every field typed as str (or str | None), regardless of the actual type declared in the MCP tool'...
Open Graph Description: Describe the Bug Bug Description mcp_tool_to_langchain in src/sap_cloud_sdk/agentgateway/converters.py builds the Pydantic args schema with every field typed as str (or str | None), regardless of t...
X Description: Describe the Bug Bug Description mcp_tool_to_langchain in src/sap_cloud_sdk/agentgateway/converters.py builds the Pydantic args schema with every field typed as str (or str | None), regardless of t...
Opengraph URL: https://github.com/SAP/cloud-sdk-python/issues/190
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"mcp_tool_to_langchain parameters conversion error","articleBody":"### Describe the Bug\n\n## Bug Description\n\n`mcp_tool_to_langchain` in `src/sap_cloud_sdk/agentgateway/converters.py` builds the\nPydantic args schema with every field typed as `str` (or `str | None`), regardless of\nthe actual type declared in the MCP tool's `input_schema`.\n\n## Root Cause\n\nLines 85–88 of `converters.py` iterate over property *keys* only and hard-code `str`:\n\n```python\nfields: dict[str, Any] = {\n k: (str, ...) if k in required else (str | None, Field(default=None))\n for k in properties # ← values (the property schemas) are never read\n}\n```\n\nThe property schema values (e.g. `{\"type\": \"integer\"}`) are never consulted.\n\n## Impact\n\nWhen an LLM passes a non-string argument (e.g. `limit=10`, `active=true`), Pydantic\ncoerces it to a string (`\"10\"`, `\"true\"`) before forwarding it to `call_tool`. The MCP\nserver then rejects the call because it expects the native JSON type.\n\n## Affected types\n\nAll non-string JSON Schema types are affected: `integer`, `number`, `boolean`, `array`,\n`object`.\n\n## Reproduction\n\n```python\nfrom unittest.mock import AsyncMock\nfrom sap_cloud_sdk.agentgateway import MCPTool\nfrom sap_cloud_sdk.agentgateway.converters import mcp_tool_to_langchain\n\ntool = MCPTool(\n name=\"search\",\n server_name=\"s\",\n description=\"d\",\n input_schema={\n \"type\": \"object\",\n \"required\": [\"limit\"],\n \"properties\": {\n \"limit\": {\"type\": \"integer\"},\n \"active\": {\"type\": \"boolean\"},\n },\n },\n url=\"https://example.com/mcp\",\n)\n\nlc_tool = mcp_tool_to_langchain(tool, AsyncMock(), lambda: \"token\")\nfields = lc_tool.args_schema.model_fields\n\n# Both fields are `str` — should be `int` and `bool`\nprint(fields[\"limit\"].annotation) # \u003cclass 'str'\u003e ← bug\nprint(fields[\"active\"].annotation) # str | None ← bug\n```\n\n## Expected Fix\n\nMap JSON Schema `\"type\"` values to Python types before building the Pydantic model:\n\n| JSON Schema type | Python type |\n|------------------|-------------|\n| `\"string\"` | `str` |\n| `\"integer\"` | `int` |\n| `\"number\"` | `float` |\n| `\"boolean\"` | `bool` |\n| `\"array\"` | `list` |\n| `\"object\"` | `dict` |\n| *(missing/other)*| `Any` |\n\n## Scope\n\nOnly `mcp_tool_to_langchain` in `agentgateway/converters.py` is affected. No other\nconverters exist in the codebase.\n\n\n### Steps to Reproduce\n\n1. Use mcp tool without string argument\n\n### Expected Behavior\n\n1. it should consider parameters other than string\n\n### Screenshots\n\n_No response_\n\n### Used Versions\n\n- Python version via `python --version`: ...\n- SAP Cloud SDK for Python version: ...\n- Framework version (if applicable, e.g., Flask, FastAPI): ...\n\n\u003cdetails\u003e\u003csummary\u003eInstalled packages via \u003ccode\u003epip list\u003c/code\u003e or \u003ccode\u003euv pip list\u003c/code\u003e\u003c/summary\u003e\n\n```\nPackage list here\n```\n\u003c/details\u003e\n\n\n### Code Examples\n\n```python\n# Your code here\n```\n\n\n### Stack Trace\n\n_No response_\n\n### Log File\n\n\u003cdetails\u003e\u003csummary\u003eLog file\u003c/summary\u003e\n...\n\u003c/details\u003e\n\n\n### Affected Development Phase\n\nGetting Started\n\n### Impact\n\nNo Impact\n\n### Timeline\n\n_No response_","author":{"url":"https://github.com/51acorsi","@type":"Person","name":"51acorsi"},"datePublished":"2026-06-26T20:57:55.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":2},"url":"https://github.com/190/cloud-sdk-python/issues/190"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:663464cd-1eb3-0b00-8f42-b5378cac308c |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | CC86:2395E2:257344:3394A8:6A5062C7 |
| html-safe-nonce | c8e3c309855ca6c049f66d143fb7c593c5a5534c21e6daef151edd9773871b3f |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDQzg2OjIzOTVFMjoyNTczNDQ6MzM5NEE4OjZBNTA2MkM3IiwidmlzaXRvcl9pZCI6IjU1NjI0NTIzOTA2NzY4MTY1ODMiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 3612e203c8b8960e126843861b8be006afe179093285f7de7907f6648c6365e0 |
| hovercard-subject-tag | issue:4755100371 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/SAP/cloud-sdk-python/190/issue_layout |
| twitter:image | https://opengraph.githubassets.com/4a172dd1b064a34c66a2bbd68b32e8585f69e9fd426899190ddcbf7d9a7cee4b/SAP/cloud-sdk-python/issues/190 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/4a172dd1b064a34c66a2bbd68b32e8585f69e9fd426899190ddcbf7d9a7cee4b/SAP/cloud-sdk-python/issues/190 |
| og:image:alt | Describe the Bug Bug Description mcp_tool_to_langchain in src/sap_cloud_sdk/agentgateway/converters.py builds the Pydantic args schema with every field typed as str (or str | None), regardless of t... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | 51acorsi |
| hostname | github.com |
| expected-hostname | github.com |
| None | d6dc8294eb500fa36bbc57472d61fe87c522f9c3c1d64f70f4926f66a66a7efb |
| turbo-cache-control | no-preview |
| go-import | github.com/SAP/cloud-sdk-python git https://github.com/SAP/cloud-sdk-python.git |
| octolytics-dimension-user_id | 2531208 |
| octolytics-dimension-user_login | SAP |
| octolytics-dimension-repository_id | 1187276298 |
| octolytics-dimension-repository_nwo | SAP/cloud-sdk-python |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1187276298 |
| octolytics-dimension-repository_network_root_nwo | SAP/cloud-sdk-python |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 7ac0ad2f2c7e4b9056617355fd9e33e22b0c8df9 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width