fix(mcp): preserve image content blocks - #21046
Closed
danielz1z wants to merge 1 commit into
Closed
Conversation
Collaborator
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.
What does this PR do?
Preserves MCP
ImageContentblocks returned fromtools/callresults instead of silently dropping them.Hermes already preserved text content and
structuredContent, but MCP servers that return images (for example design/reference tools) could send valid image blocks that never reached the agent. This change materializes image blocks under$HERMES_HOME/cache/mcp/<server>/and includes JSON-safe metadata in the tool result, while keeping the existing text-first result shape unchanged.Related Issue
N/A — found while testing an MCP server that returns screen-search metadata plus image content.
Type of Change
Changes Made
tools/mcp_tool.pydata+mimeType.$HERMES_HOME/cache/mcp/<server>/.content_blocksarray with imagemimeType, localpath, andsize_bytesmetadata.resultandstructuredContentbehavior for text-only and structured responses.tests/tools/test_mcp_structured_content.pyHow to Test
content_blocksis missing.scripts/run_tests.sh tests/tools/test_mcp_structured_content.py tests/tools/test_mcp_tool.pyscripts/run_tests.sh tests/tools/test_mcp_*.pyChecklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/ -qand all tests passDocumentation & Housekeeping
docs/, docstrings) — or N/Acli-config.yaml.exampleif I added/changed config keys — or N/ACONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows — or N/AScreenshots / Logs
Regression test fails on main before the fix:
Validation after the fix:
The one warning is pre-existing in
tests/tools/test_mcp_probe.py::TestProbeMcpServerTools::test_skips_disabled_servers(coroutine ... was never awaited) and is unrelated to this change.