fix(mcp): handle EmbeddedResource content blocks in tool results - #3655
Closed
zicochaos wants to merge 1 commit into
Closed
fix(mcp): handle EmbeddedResource content blocks in tool results#3655zicochaos wants to merge 1 commit into
zicochaos wants to merge 1 commit into
Conversation
MCP tools may return content blocks with type 'resource' (EmbeddedResource) in addition to type 'text' (TextContent). The _make_tool_handler only extracted TextContent blocks, silently dropping EmbeddedResource content and returning empty strings. This affects any MCP server that returns documents as EmbeddedResource (e.g. qmd's get/multi_get tools which return markdown documents with URI metadata). The fix extracts text from both block.text (TextContent) and block.resource.text (EmbeddedResource), with a placeholder for binary resources (blob).
10 tasks
This was referenced May 22, 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.
Problem
MCP tools may return content blocks with
type: 'resource'(EmbeddedResource) in addition totype: 'text'(TextContent). The_make_tool_handlerintools/mcp_tool.pyonly extracts TextContent blocks (block.text), silently dropping EmbeddedResource content and returning empty strings to the agent.Impact
Any MCP server that returns documents as EmbeddedResource is affected. For example, qmd's
getandmulti_gettools return markdown documents as EmbeddedResource with URI metadata — these return empty results through Hermes despite the MCP server responding correctly.The bug is in the content extraction loop at line ~1070:
EmbeddedResource blocks have
block.resource.text, notblock.text, so they're silently skipped.Fix
Extract text from both content block types:
block.textfor TextContent (existing behavior)block.resource.textfor EmbeddedResource (new)block.resource.blob)Minimal change — 10 lines added, no new dependencies.