Repository navigation
Return images and files from MCP results as media blocks - #331
Merged
Merged
Conversation
The MCP server sent every result as one JSON text block. An image a script returned reached the model as base64 text it cannot see, and counted against the 1 MiB result limit. call and execute now move each MCP image, audio or blob resource block in a result, at any depth, into its own content block. The JSON keeps the block without its bytes and with contentIndex, the block's index in content. A block the result repeats is sent once. base64url, unpadded and line-wrapped data become standard base64. Text resources are readable as JSON and stay in it. A result carries up to 1 MiB of JSON plus 5 MiB of media. Service results in execute may be up to 6 MiB, so a script can return a file it reads. The execute description tells agents how to return images and files.
The JSON keeps every field of a lifted block except its bytes, and the emitted block keeps MCP annotations and _meta. The service integration test reads a 2 MiB file from a service and returns it as an image.
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ✅ Deployment successful! View logs |
widefleet-docs | 61834a7 | Nov 23 2026, 12:46 PM |
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
The MCP server sends every
callandexecuteresult as one JSON text block. An image a script returns reaches the model as base64 text it cannot see, and it counts against the 1 MiB result limit.Change
Media blocks in a result become MCP content blocks.
callandexecutefind MCPimage,audioand blobresourceblocks in the result, at any depth.contentIndex, the block's index incontent.Limits.
executemay be up to 6 MiB, so a script can return a file it reads.The
executedescription tells agents how to return images and files.Tests
pnpm checkandRUN_SERVICE_TESTS=1forapp-services-runtime.test.ts.The docs follow in #332.


Confidence Score: 5/5
The PR appears safe to merge; no new actionable issues were found.Summary
Returns images, audio, and files as MCP content blocks while keeping JSON references to them.
All four supplied previous threads are addressed: extra fields remain in JSON, large service responses have coverage, different metadata stays separate, and matching metadata shares one block. None of those threads supplied a Comment number.
Diagram
%%{init: {'theme': 'neutral'}}%% flowchart LR A[Service call or script result] --> B[Find media blocks] B --> C[Compare blocks including metadata] C --> D[JSON with contentIndex references] C --> E[Unique media blocks] D --> F[Check JSON limit] E --> G[Check media limit] F --> H[MCP content array] G --> HReviews (4) · Last reviewed commit: "Compare media blocks independent of key ..." · Reviewed by Greptile