AI & Agent Dev Bug Sandbox logo
AI & Agent Dev Bug Sandbox
Back to Radar

ResourceLink Converted To URL File Block Breaks Bedrock Converse And Custom MCP URIs

A single ResourceLink in a MCP tool result causes LangChain-AWS Bedrock to raise ValueError and terminate the agent run because langchain-mcp-adapters incorrectly maps resource links to URL-sourced file blocks, which Bedrock does not support and which often use non-dereferenceable custom URI schemes.

highConfidence 90%LangChainAffected V<=0.3.1Fixed V0.3.2

Origin Analysis

The function `_convert_mcp_content_to_lc_block` in `langchain_mcp_adapters/tools.py` maps an MCP `ResourceLink` to a file or image content block with a `url` source. This assumes the URI is a web-fetchable URL and that downstream providers support URL-sourced content. However, MCP resource URIs are often custom schemes (e.g., `demo://resource/dynamic/blob/1`) that are not dereferenceable by model providers, and Bedrock Converse only supports inline base64 document data, not URL sources.
Run the following code without an MCP server or AWS credentials: ```python from langchain_core.messages import ToolMessage from mcp.types import ResourceLink from langchain_mcp_adapters.tools import _convert_mcp_content_to_lc_block from langchain_aws.chat_models.bedrock_converse import _messages_to_bedrock link = ResourceLink( type="resource_link", uri="demo://resource/dynamic/blob/1", name="Resource 1", mimeType="text/plain", ) block = _convert_mcp_content_to_lc_block(link) print("converted block:", block) msg = ToolMessage(content=[block], tool_call_id="call_1") _messages_to_bedrock([msg]) # raises ValueError: File data only supported through in-line base64 format. ```

Fixing Code Block

Edge Case Audit

This fix changes the content type from file/image to text for ResourceLink, which may reduce the model's ability to directly process image resources if the URI happened to be a valid, fetchable web URL and the provider supported URL sources. If downstream code expects file/image blocks from ResourceLink, it may break. Rollback: keep the previous mapping as an optional branch (e.g., controlled by an environment variable) until all downstream integrations are verified. The change is a pure function with no shared state, so it is safe under concurrency; however, if the function is monkey-patched elsewhere, ensure thread safety.

Ecosystem Topology