fix(mcp): extract EmbeddedResource content blocks from tool results - #50999
Closed
kingofkillers91 wants to merge 1 commit into
Closed
kingofkillers91 wants to merge 1 commit into
kingofkillers91 wants to merge 1 commit into
Conversation
MCP servers (e.g. GitHub MCP v1.4.0 get_file_contents) return file content as type="resource" blocks with the payload in .resource.text, not as type="text" blocks. Hermes was silently dropping these, producing empty results like "successfully downloaded text file" with no actual content. Patch all three extraction points in tools/mcp_tool.py: 1. Main tool result loop (~line 3194) — extract .resource.text before falling through to image handling 2. Error text extraction (~line 3174) — same treatment for error blocks 3. _extract_tool_result_text() (~line 909) — handle resource blocks in tool result content items Fixes NousResearch#30601 Signed-off-by: kingofkillers91
Contributor
|
Duplicate of #31356 — same MCP |
Collaborator
|
This is now fixed on main via PR #64556 (salvaged from #64061, which materializes binary blobs to the document cache and covers ResourceLink/Audio in addition to embedded resource text). Your fix addressed the same underlying bug — thanks for the contribution, and sorry we couldn't take this one; five PRs ended up targeting the same dropped-resource-block issue. |
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 servers that return
type="resource"content blocks (EmbeddedResourcein the MCP SDK) have their results silently dropped by Hermes' MCP client. The client only extracts text fromTextContentandImageContentblocks, ignoringEmbeddedResourceblocks entirely.Affected tools: GitHub MCP
get_file_contents(v1.4.0+), Playwright MCP, filesystem servers, and any MCP server that embeds file content as resource blocks.Symptom:
get_file_contentsreturns"successfully downloaded text file (SHA: ...)"— the metadata text block — but the actual file content in theresourceblock is dropped. The agent sees an empty result.Root Cause
tools/mcp_tool.pyextracts content from tool results in three places, all usinghasattr(block, "text")only:result.content, extracts.textand image blocks, drops everything else_extract_tool_result_text()(~line 909) — extracts text fromToolResultContentblocks, same gapThe MCP spec defines
EmbeddedResourcewithtype="resource"where the payload lives at.resource.text(or.resource.blobfor binary). These blocks have no top-level.textattribute.Fix
Patch all three extraction points to also check for
hasattr(block, "resource")and extract.resource.text:Verification
Before patch:
After patch (tested with GitHub MCP v1.4.0):
Content from the
resourceblock is now included alongside the metadata text.Related
EmbeddedResourceContent Blocks from MCP Tool Results #26972 (closed without merge)EmbeddedResourceContent Blocks from MCP Tool Results #26972