fix(mcp): materialize ResourceLink/EmbeddedResource/Audio blocks instead of dropping them (salvage #64061) - #64556
Merged
Merged
Conversation
…ead of dropping them MCP tool results with non-image binary resources (PDFs, archives, office docs) were silently dropped: the success path only handled TextContent and ImageContent, so a PDF-returning MCP tool appeared to return metadata only. - EmbeddedResource blob contents are decoded (50MB cap), materialized into the Hermes document cache via cache_document_from_bytes (sanitized filename, traversal-safe), and surfaced as a local-path marker the agent can read with file/terminal tools. - EmbeddedResource text contents are inlined directly. - ResourceLink blocks preserve the URI and point the agent at the server's read_resource tool; no arbitrary network fetch outside the MCP session. - AudioContent blocks are cached via cache_audio_from_bytes as MEDIA: tags. - read_resource blob contents are materialized the same way instead of returning '[binary data, N bytes]'. - Unsupported blocks are logged instead of silently discarded. - Existing ImageContent MEDIA: behavior unchanged. Reported by an enterprise customer; reproduced against an HTTP MCP server returning application/pdf resources.
…e text in isError path Follow-ups on top of #64061's salvage: - ResourceLink markers now point at mcp__<server>__read_resource (the actual registered tool name via mcp_prefixed_tool_name) instead of a nonexistent <server>_read_resource the agent could hallucinate-call. - The isError path now surfaces EmbeddedResource .resource.text blocks instead of dropping them, so error payloads carried in resources no longer collapse to a bare 'MCP tool returned an error'. (Same-class fix flagged in #64061 and independently addressed in #63576 by @alauer.) - 3 new error-path tests + updated ResourceLink wire-name assertion.
This was referenced Jul 14, 2026
Closed
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.
Summary
MCP tool results carrying
ResourceLink,EmbeddedResource, orAudioContentblocks are now materialized instead of silently dropped — a PDF-returning MCP tool no longer appears to return metadata only.Salvage of #64061 by @victor-kyriazakos (cherry-picked onto current main, authorship preserved), plus two follow-up fixes on top.
Changes
Cherry-picked from #64061 (@victor-kyriazakos):
tools/mcp_tool.py: new_render_mcp_resource_block()— embedded blob resources are decoded (50 MB cap, enforced on b64 length before decode) and written to the document cache via existingcache_document_from_bytes(); text resources inline;ResourceLinkblocks keep URI/name/MIME with a pointer to the server's read_resource tool (no network fetch);AudioContentcached viacache_audio_from_bytes()as aMEDIA:tag; unrecognized shapes logged instead of dropped.read_resourcehandler: blob contents materialized instead of"[binary data, N bytes]".Follow-ups (ours):
mcp__<server>__read_resource(viamcp_prefixed_tool_name()) instead of a nonexistent<server>_read_resourcethe agent could hallucinate-call.isErrorpath now surfacesEmbeddedResourcetext instead of dropping it — error payloads carried in resources no longer collapse to a bare "MCP tool returned an error". (Same-class gap flagged in fix(mcp): materialize ResourceLink/EmbeddedResource/Audio blocks instead of dropping them #64061's follow-ups and independently fixed in fix(mcp): handle EmbeddedResource tool results #63576 by @alauer — credited.)Validation
tests/tools -k mcp(full MCP suite)mcp__slack__read_resourcenameDuplicate cluster
Same underlying bug reported/fixed in #29962 (@haha0815, earliest), #31356 (@Tranquil-Flow), #38463 (@janrenz), #50999 (@kingofkillers91), #63576 (@alauer). This PR is the most complete implementation — the only one that materializes binary payloads and covers ResourceLink + Audio with size caps and hostile-input tests. The others will be closed with credit.
Infographic