René's URL Explorer Experiment


Title: agentgateway.call_mcp_tool flattens CallToolResult to str, dropping structuredContent and other MCP fields · Issue #214 · SAP/cloud-sdk-python · GitHub

Open Graph Title: agentgateway.call_mcp_tool flattens CallToolResult to str, dropping structuredContent and other MCP fields · Issue #214 · SAP/cloud-sdk-python

X Title: agentgateway.call_mcp_tool flattens CallToolResult to str, dropping structuredContent and other MCP fields · Issue #214 · SAP/cloud-sdk-python

Description: Describe the Bug sap_cloud_sdk.agentgateway.AgentGatewayClient.call_mcp_tool is typed -> str and both internal flow paths (_customer.py::call_mcp_tool_customer and _lob.py::call_mcp_tool_lob) discard almost everything on the returned MCP...

Open Graph Description: Describe the Bug sap_cloud_sdk.agentgateway.AgentGatewayClient.call_mcp_tool is typed -> str and both internal flow paths (_customer.py::call_mcp_tool_customer and _lob.py::call_mcp_tool_lob) disca...

X Description: Describe the Bug sap_cloud_sdk.agentgateway.AgentGatewayClient.call_mcp_tool is typed -> str and both internal flow paths (_customer.py::call_mcp_tool_customer and _lob.py::call_mcp_tool_lob) di...

Opengraph URL: https://github.com/SAP/cloud-sdk-python/issues/214

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"agentgateway.call_mcp_tool flattens CallToolResult to str, dropping structuredContent and other MCP fields","articleBody":"### Describe the Bug\n\n`sap_cloud_sdk.agentgateway.AgentGatewayClient.call_mcp_tool` is typed `-\u003e str` and both internal flow paths (`_customer.py::call_mcp_tool_customer` and `_lob.py::call_mcp_tool_lob`) discard almost everything on the returned MCP `CallToolResult` before crossing the SDK boundary:\n\n```python\n# src/sap_cloud_sdk/agentgateway/_customer.py (main branch, lines 571-576)\n# Same shape in _lob.py at lines 480-484.\nresult = await session.call_tool(tool.name, kwargs)\nif not result.content:\n    logger.warning(\"Tool '%s' returned empty content\", tool.name)\n    return \"\"\nfirst = result.content[0]\nreturn str(getattr(first, \"text\", \"\"))\n```\n\nDropped fields:\n\n- `structuredContent` — the MCP-native channel for schema-typed structured tool output. Servers set this alongside `content` so consumers can distinguish human-readable text from typed data.\n- `content[1:]` — every content block after the first (multi-block responses lose everything but block 0).\n- `isError` — success and error results are both returned as `str`, indistinguishable at the type level.\n- `_meta` — arbitrary MCP metadata.\n\nThe reference converter `converters.py::mcp_tool_to_langchain` builds a LangChain `StructuredTool` whose coroutine returns this flattened `str` directly to LangChain, so downstream consumers using the reference converter also lose these fields.\n\n**Why it matters:** `langchain_mcp_adapters` (a sibling library in the LangChain ecosystem) preserves `structuredContent` on the LangChain side by wrapping it into `MCPToolArtifact` on `ToolMessage.artifact` via `response_format=\"content_and_artifact\"`. Consumers that go through `sap_cloud_sdk.agentgateway` for its auth / mTLS / destination-resolution / tenant-routing plumbing pay for it by losing the structured channel. Concrete downstream impacts:\n\n- Agents emitting structured tool payloads as A2A `Part(root=DataPart(...))` cannot recover `structuredContent` from a `str` return. The workaround is to `json.loads` the returned string, which only succeeds when the MCP server happens to duplicate its structured payload into `content[0].text`.\n- Any MCP tool that returns multiple `content` blocks (text + image, or multiple text blocks) is truncated to block 0.\n- Callers cannot check `isError` at the type level — success and error results have the same return type.\n\n### Steps to Reproduce\n\n1. Configure an MCP server that returns a `CallToolResult` with both `content` (text) and `structuredContent` (dict) populated. This is the standard MCP shape for schema-typed tool output.\n2. Invoke via `agent_gateway_client.call_mcp_tool(tool, ...)`.\n3. Observe that the return value is `str` — the first content block's `text`. `structuredContent`, `content[1:]`, `isError`, and `_meta` are unrecoverable from the return.\n\n### Expected Behavior\n\n`call_mcp_tool` (or an equivalent method exposed by the SDK) allows consumers to access the full `CallToolResult`, preserving `content`, `structuredContent`, `isError`, and `_meta`. This lets consumers implement the same `content_and_artifact` split that `langchain_mcp_adapters` provides for the direct-MCP path.\n\nTwo possible shapes for the fix (maintainers know the compatibility surface best):\n\n**Option A — additive, non-breaking.** Add a new method returning the raw `CallToolResult`, keep the existing `call_mcp_tool` unchanged:\n\n```python\nasync def call_mcp_tool_raw(\n    self,\n    tool: MCPTool,\n    user_token: str | Callable[[], str] | None = None,\n    app_tid: str | None = None,\n    **kwargs,\n) -\u003e mcp.types.CallToolResult:\n    ...\n```\n\nUpdate `converters.py::mcp_tool_to_langchain` (or ship a second reference converter) to call `call_mcp_tool_raw` and build a `StructuredTool` with `response_format=\"content_and_artifact\"`, matching the `langchain_mcp_adapters` shape.\n\n**Option B — breaking, cleaner long-term.** Change `call_mcp_tool` to return `CallToolResult`; update the reference converter accordingly. Requires a major version bump and a migration note.\n\nOption A seems preferable given `call_mcp_tool` is a documented public API with a stable signature and existing consumers would need to migrate.\n\n### Used Versions\n\n- Python version: `3.14.3` (bug is Python-version-independent — logic is in the SDK)\n- SAP Cloud SDK for Python version: `0.29.1` observed. Verified the same flattening logic is still on `main` at time of filing: [`agw_client.py:485`](https://github.com/SAP/cloud-sdk-python/blob/main/src/sap_cloud_sdk/agentgateway/agw_client.py#L485) declares `-\u003e str`, and [`_customer.py:571-576`](https://github.com/SAP/cloud-sdk-python/blob/main/src/sap_cloud_sdk/agentgateway/_customer.py#L571) / [`_lob.py:480-484`](https://github.com/SAP/cloud-sdk-python/blob/main/src/sap_cloud_sdk/agentgateway/_lob.py#L480) contain the flatten-to-`content[0].text` code.\n- Framework version: `langchain-mcp-adapters==0.2.2` (for cross-reference with the sibling library's `_convert_call_tool_result` behavior)\n\n### Code Examples\n\n```python\n# Consumer-side workaround currently in use — reconstructs a partial\n# CallToolResult by parsing the flattened string. Works when the MCP\n# server duplicates its payload into content[0].text; loses information\n# when it doesn't.\nraw_string = await agw_client.call_mcp_tool(tool, ...)\ntry:\n    parsed = json.loads(raw_string)\n    structured = parsed if isinstance(parsed, dict) else None\nexcept json.JSONDecodeError:\n    structured = None\n\nresult = CallToolResult(\n    content=[TextContent(type=\"text\", text=raw_string)],\n    structuredContent=structured,\n    isError=False,   # Cannot actually determine — SDK dropped it\n)\n```\n\n### Affected Development Phase\n\nDevelopment\n\n### Impact\n\nImpaired\n\n### Related\n\n- MCP protocol spec on `CallToolResult` / `structuredContent`: https://modelcontextprotocol.io/specification/\n- `langchain_mcp_adapters._convert_call_tool_result` — how the sibling library preserves the split: https://github.com/langchain-ai/langchain-mcp-adapters/blob/main/langchain_mcp_adapters/tools.py\n","author":{"url":"https://github.com/patrickmlr","@type":"Person","name":"patrickmlr"},"datePublished":"2026-07-08T10:01:21.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/214/cloud-sdk-python/issues/214"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:a4ed3234-5523-a428-aadf-e6d519b5ed3e
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-id854E:16CCCC:40CC0B7:5BE56BC:6A4FB58A
html-safe-nonce58fc204f50cfa0587669a5a9ef91b876f8b5d6b1e1452629a5e1087b7a5a593a
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4NTRFOjE2Q0NDQzo0MENDMEI3OjVCRTU2QkM6NkE0RkI1OEEiLCJ2aXNpdG9yX2lkIjoiODk1Mzg4MDI5OTg1NjQ0Mjc2MiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac3f813ac01dbbefaa4961ee9dcb8ecb0d15da2c601b9e58766a54f0234d60af1b
hovercard-subject-tagissue:4836394173
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/SAP/cloud-sdk-python/214/issue_layout
twitter:imagehttps://opengraph.githubassets.com/004a4f68b7a355af468a4f8e14ab9c2986fc5095b0dc8a7d4794608ee879d468/SAP/cloud-sdk-python/issues/214
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/004a4f68b7a355af468a4f8e14ab9c2986fc5095b0dc8a7d4794608ee879d468/SAP/cloud-sdk-python/issues/214
og:image:altDescribe the Bug sap_cloud_sdk.agentgateway.AgentGatewayClient.call_mcp_tool is typed -> str and both internal flow paths (_customer.py::call_mcp_tool_customer and _lob.py::call_mcp_tool_lob) disca...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamepatrickmlr
hostnamegithub.com
expected-hostnamegithub.com
Noneb92d11c0aa4a77d54ef4af1078b6a15fb5a70a215b30c4ecf28889d5a8e656d9
turbo-cache-controlno-preview
go-importgithub.com/SAP/cloud-sdk-python git https://github.com/SAP/cloud-sdk-python.git
octolytics-dimension-user_id2531208
octolytics-dimension-user_loginSAP
octolytics-dimension-repository_id1187276298
octolytics-dimension-repository_nwoSAP/cloud-sdk-python
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id1187276298
octolytics-dimension-repository_network_root_nwoSAP/cloud-sdk-python
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release4b249b445842943ed31549e027f57a8ade9881ed
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/SAP/cloud-sdk-python/issues/214#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FSAP%2Fcloud-sdk-python%2Fissues%2F214
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub Copilot appDirect agents from issue to mergehttps://github.com/features/ai/github-app
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
View all resourceshttps://github.com/resources
GitHub SponsorsFund open source developershttps://github.com/open-source/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/open-source/accelerator
GitHub Starshttps://stars.github.com
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FSAP%2Fcloud-sdk-python%2Fissues%2F214
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=SAP%2Fcloud-sdk-python
Reloadhttps://github.com/SAP/cloud-sdk-python/issues/214
Reloadhttps://github.com/SAP/cloud-sdk-python/issues/214
Reloadhttps://github.com/SAP/cloud-sdk-python/issues/214
Please reload this pagehttps://github.com/SAP/cloud-sdk-python/issues/214
SAP https://github.com/SAP
cloud-sdk-pythonhttps://github.com/SAP/cloud-sdk-python
Notifications https://github.com/login?return_to=%2FSAP%2Fcloud-sdk-python
Fork 33 https://github.com/login?return_to=%2FSAP%2Fcloud-sdk-python
Star 18 https://github.com/login?return_to=%2FSAP%2Fcloud-sdk-python
Code https://github.com/SAP/cloud-sdk-python
Issues 6 https://github.com/SAP/cloud-sdk-python/issues
Pull requests 15 https://github.com/SAP/cloud-sdk-python/pulls
Actions https://github.com/SAP/cloud-sdk-python/actions
Projects https://github.com/SAP/cloud-sdk-python/projects
Security and quality 0 https://github.com/SAP/cloud-sdk-python/security
Insights https://github.com/SAP/cloud-sdk-python/pulse
Code https://github.com/SAP/cloud-sdk-python
Issues https://github.com/SAP/cloud-sdk-python/issues
Pull requests https://github.com/SAP/cloud-sdk-python/pulls
Actions https://github.com/SAP/cloud-sdk-python/actions
Projects https://github.com/SAP/cloud-sdk-python/projects
Security and quality https://github.com/SAP/cloud-sdk-python/security
Insights https://github.com/SAP/cloud-sdk-python/pulse
agentgateway.call_mcp_tool flattens CallToolResult to str, dropping structuredContent and other MCP fieldshttps://github.com/SAP/cloud-sdk-python/issues/214#top
https://github.com/patrickmlr
patrickmlrhttps://github.com/patrickmlr
on Jul 8, 2026https://github.com/SAP/cloud-sdk-python/issues/214#issue-4836394173
agw_client.py:485https://github.com/SAP/cloud-sdk-python/blob/main/src/sap_cloud_sdk/agentgateway/agw_client.py#L485
_customer.py:571-576https://github.com/SAP/cloud-sdk-python/blob/main/src/sap_cloud_sdk/agentgateway/_customer.py#L571
_lob.py:480-484https://github.com/SAP/cloud-sdk-python/blob/main/src/sap_cloud_sdk/agentgateway/_lob.py#L480
https://modelcontextprotocol.io/specification/https://modelcontextprotocol.io/specification/
https://github.com/langchain-ai/langchain-mcp-adapters/blob/main/langchain_mcp_adapters/tools.pyhttps://github.com/langchain-ai/langchain-mcp-adapters/blob/main/langchain_mcp_adapters/tools.py
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.