Files
Strata/docs/MCP_IMAGES.md
T
Niko1221 6339bb0947 MCP: a model that reads pictures gets the pictures its tools return, by default (#2343)
mcp.image_results (7c9b6f3a2, PR #2473) passes an MCP tool's image
blocks to the picture reader, but it was off unless the run config said
true, so a tool that takes a screenshot or reads an image handed the
model only "[image (...): not shown to the model]". The owner's rule is
that every picture-capable model reads pictures by default (coordinator
11-16).

Not set in the config, it now follows the loaded model: on when it has a
picture reader, off when it has none (serve.mcp.resolve_image_results,
called in serve/server.py's start-up right after the Service and its
reader exist). "image_results": false keeps it off and true keeps it on,
as before. The limits are unchanged: at most 4 images per result, 24 MB
of base64 each, PNG / JPEG / WebP with the header checked, cached beside
the config. docs/MCP_IMAGES.md says the new default in plain words.

From PR #2343's request (ds): its other parts are not taken (lifting
pictures out of a tool's text; the reader's working-folder repair).

Test: serve/test_mcp_image_default.py (the module does not import on the
base: no resolve_image_results), 5 pass: on with a reader and no
setting (3 images reach the model), off without a reader, an explicit
false respected, the start-up order; test_mcp_media's omitted-switch case
now expects "not set" (it failed on the base's DEFAULTS); serve.test_mcp
passes (55 in all).
2026-11-16 18:56:53 +01:00

3.2 KiB

MCP raster images in the web chat

This is on by default when the loaded model can read pictures, and off when it cannot. To turn it off, add "mcp": {"image_results": false} to the run configuration (beside the other MCP settings); true turns it on. The value must be a JSON boolean (true or false); strings and numbers are rejected. When it is off, the model gets the tool's text only, and the stream events are the same as before.

MCP image results are cached by SHA-256 next to the run configuration, in <config-stem>.tool-media/. The web chat receives small same-origin references instead of embedding base64 in chat history. PNG, JPEG and WebP are supported; SVG and arbitrary file/resource URIs are not rendered. Each call displays at most four images, each with at most 24 million base64 characters (about 18 MB decoded). If the cache cannot be written, the chat retains the text result and logs the cache error.

GET /tool-media/<sha256>.<extension> uses the existing server API authentication, validates the basename, and serves only cached raster files. The web client fetches images with its existing authorization headers, displays them outside collapsed tool details, and provides a blob download link. The cache persists across server restarts; if its files are removed, older image references are replaced with an image-omitted text note when preparing later turns. Disabling the feature or removing MCP configuration does the same, while preserving the tool text and allowing the conversation to continue. Malformed references are still rejected. A global disk-retention policy is not implemented yet.

When the server has a vision encoder, tool images enter its existing image preparation path. Subsequent browser turns send strata-tool-media:<basename> references; the authenticated server resolves these only inside its cache. With no vision encoder, images remain visible to the user and the model receives the existing text-only fallback. This adds image transport, not a vision model.

Search and image generation are supplied by configured MCP servers. Strata does not bundle a paid search provider or a ComfyUI installation. Machine-specific adapters and lifecycle hooks are not included in this change.

Validation without a GPU

python -m unittest serve.test_mcp serve.test_mcp_media
node --check serve/web/app.js
git diff --check

The transport tests use an existing mock engine and scripted tool response. They verify authenticated binary delivery, invalid media rejection, path traversal refusal, streaming metadata, forwarding to vision preparation and subsequent-turn cache resolution. They do not establish visual understanding or generation quality.

Browser layout checks

Use a configured image MCP fixture and the mock engine; no GPU is needed for the transport or layout check. Include a long tool name and long text result, and check a running call while Stop is visible. At viewport widths 320, 390, 640, 768 and 1280 pixels, the document must not be wider than the viewport and the preview must fit its chat bubble. Also expand tool details, reload the page, and check that the preview and download link return. A missing cache may remove the picture but must not prevent the next text turn.