Skip to content

fix(mcp): handle EmbeddedResource content blocks in tool results - #3655

Closed
zicochaos wants to merge 1 commit into
NousResearch:mainfrom
zicochaos:fix/mcp-embedded-resource-content
Closed

fix(mcp): handle EmbeddedResource content blocks in tool results#3655
zicochaos wants to merge 1 commit into
NousResearch:mainfrom
zicochaos:fix/mcp-embedded-resource-content

Conversation

@zicochaos

Copy link
Copy Markdown
Contributor

Problem

MCP tools may return content blocks with type: 'resource' (EmbeddedResource) in addition to type: 'text' (TextContent). The _make_tool_handler in tools/mcp_tool.py only 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 get and multi_get tools 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:

for block in (result.content or []):
    if hasattr(block, "text"):
        parts.append(block.text)

EmbeddedResource blocks have block.resource.text, not block.text, so they're silently skipped.

Fix

Extract text from both content block types:

  • block.text for TextContent (existing behavior)
  • block.resource.text for EmbeddedResource (new)
  • Placeholder for binary resources (block.resource.blob)

Minimal change — 10 lines added, no new dependencies.

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).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant