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

ResourceLink/EmbeddedResource Metadata Loss In MCP To LangChain Conversion

The conversion function only retains uri and mimeType, discarding name, description, size and other metadata from MCP ResourceLink and EmbeddedResource, causing information loss for downstream tools.

highConfidence 75%LangChain

Origin Analysis

In langchain_mcp_adapters/tools.py, _convert_mcp_content_to_lc_block() does not extract and map all fields from MCP ResourceLink/EmbeddedResource objects to corresponding LangChain content block fields, only using uri and mimeType.
1. Create an MCP tool that returns ResourceLink content with a name field 2. Convert the tool to LangChain format using convert_mcp_tool_to_langchain_tool() 3. Call the tool and inspect the returned content blocks 4. Observe that the name field is missing from the LangChain content block

Fixing Code Block

Edge Case Audit

Attaching 'name' to image blocks as a dynamic attribute is not officially supported and may be lost during serialization or validation. Other metadata (description, size, etc.) are still not preserved and may require extending the LangChain content block schemas or using custom blocks for full fidelity. Rollback: revert to original code to avoid potential serialization issues, but note that original code discards all metadata except uri and mimeType.

Ecosystem Topology