Skip to content

Document images and files in MCP results - #332

Draft
tnkuehne wants to merge 2 commits into
mainfrom
docs/mcp-media-blocks
Draft

tnkuehne wants to merge 2 commits into
mainfrom
docs/mcp-media-blocks

Conversation

@tnkuehne

@tnkuehne tnkuehne commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Change

  • The MCP guide shows how an execute script returns an image or a file as an MCP block, and states the new limits: 1 MiB of JSON plus 5 MiB of images and files.
  • The Google Drive template explains that execute returns file content up to 5 MiB as MCP blocks.

Publication

Implementation: #331. This stays in draft until a hosted release includes #331, because the template description is published from main right away.

RetriggerView in GreptileConfidence Score: 5/5

The documentation changes appear safe to merge.

Summary

Documents how execute returns images and files as MCP blocks.

  • MCP guides show how execute returns images and files.

Reviews (3) · Last reviewed commit: "Read Drive content from the call's data ..." · Reviewed by Greptile

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
widefleet-docs fffe8c0 Nov 23 2026, 12:59 PM

@jonathanlaib
jonathanlaib added this pull request to stack #334 November 23, 2026 12:51
@jonathanlaib
jonathanlaib marked this pull request as ready for review November 23, 2026 12:52
@jonathanlaib
jonathanlaib removed this pull request from stack #334 November 23, 2026 12:53
Comment thread apps/docs/docs/guides/mcp.md Resolved
Comment thread templates/google-drive/template.md Resolved
tnkuehne added a commit that referenced this pull request Nov 23, 2026
## Problem

The MCP server sends every `call` and `execute` result 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.**
- `call` and `execute` find MCP `image`, `audio` and blob `resource`
blocks in the result, at any depth.
- Each one is sent as its own content block. The JSON keeps the block
without its bytes, plus `contentIndex`, the block's index in `content`.
- A block that 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. Values that are
not valid blocks stay JSON unchanged.

**Limits.**
- A result carries up to 1 MiB of JSON plus 5 MiB of media.
- Service results inside `execute` may be up to 6 MiB, so a script can
return a file it reads.
- Service input stays limited to 1 MiB.

**The `execute` description tells agents how to return images and
files.**

## Tests

- Unit tests cover lifting at any depth, deduplication, base64
normalization, text resources and invalid blocks staying JSON, and both
limits.
- The service integration test runs a script that returns a 2 MiB image
in workerd and celld, and checks the text block and the image block.
- Ran `pnpm check` and `RUN_SERVICE_TESTS=1` for
`app-services-runtime.test.ts`.

The docs follow in #332.







<!-- greptile_comment -->

<!-- greptile_summary -->

<h2><a
href="https://app.greptile.com/api/retrigger?id=116546427&amp;sig=16047278466d5056c276664c8825466abe79970391796e04da3df882d27d7bc4"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://greptile-static-assets.s3.amazonaws.com/badges/RetriggerDark.svg?v=2"><source
media="(prefers-color-scheme: light)"
srcset="https://greptile-static-assets.s3.amazonaws.com/badges/Retrigger.svg?v=2"><img
alt="Retrigger"
src="https://greptile-static-assets.s3.amazonaws.com/badges/Retrigger.svg?v=2"
align="right"></picture></a><a
href="https://app.greptile.com/-/switch-tenant?tenant=mendra&amp;next=%2Fwidefleet%2Fwidefleet%2Fpull%2F331&amp;utm_source=greptile_review&amp;utm_medium=github&amp;utm_campaign=view_in_greptile"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://greptile-static-assets.s3.amazonaws.com/badges/ViewInGreptileDark.svg?v=2"><source
media="(prefers-color-scheme: light)"
srcset="https://greptile-static-assets.s3.amazonaws.com/badges/ViewInGreptile.svg?v=2"><img
alt="View in Greptile"
src="https://greptile-static-assets.s3.amazonaws.com/badges/ViewInGreptile.svg?v=2"
align="right"></picture></a>Confidence Score: 5/5</h2>

<!-- greptile-impact-verdict --> The PR appears safe to merge; no new
actionable issues were found.

<details open><summary><h3>Summary</h3></summary>

Returns images, audio, and files as MCP content blocks while keeping
JSON references to them.
- MCP results send images, audio, and files as media blocks.

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.
</details>

<details open><summary><h3>Diagram</h3></summary>

```mermaid
%%{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 --> H
```
</details>

<!-- greptile_confidence_score:5 -->

<sub>Reviews (4) · Last reviewed commit: ["Compare media blocks
independent of key
..."](61834a7)
· [Reviewed by
Greptile](https://www.greptile.com/?utm_source=greptile_review&utm_medium=github&utm_campaign=review_public&utm_content=widefleet/widefleet)</sub>

<!-- /greptile_comment -->
Base automatically changed from feat/mcp-media-blocks to main November 23, 2026 12:58
@tnkuehne
tnkuehne force-pushed the docs/mcp-media-blocks branch from 8841da0 to fffe8c0 Compare November 23, 2026 12:58
@tnkuehne
tnkuehne marked this pull request as draft November 23, 2026 12:58
@jonathanlaib jonathanlaib added the documentation Improvements or additions to documentation label Nov 23, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants