Skip to main content
Glama
MCP private image preview

MCP private image preview

by BlueBorey

MCP private image preview

Render native MCP image results inside a compatible MCP Apps host without publishing a media URL. This is a small Python FastMCP adapter and a self-contained HTML viewer. The data-producing tool stays useful for clients that only forward images to vision models.

What it solves

A tool can successfully return an ImageContent block even when a user never sees the picture. This repository adds an MCP Apps resource binding, and the viewer renders the actual raster data delivered by the host. This is distinct from model vision: a text-only model cannot be made multimodal just by attaching an iframe.

  • Standard image/jpeg, image/png, image/webp, and image/gif data (SVG is intentionally rejected).

  • No public media URL, external web asset, image fetch, or network call from the viewer.

  • Explicit initialization handshake; a picture is counted as loaded only after its image load event, with decode failure reported.

  • Purely synthetic local test fixtures with no account information or private photos.

  • Python MCP SDK 1.19.0 compatibility adapter. Its high-level resource MIME validation rejects MIME parameters, so the adapter uses a narrowly typed resource subclass instead of globally patching SDK validation.

Related MCP server: Image Context Runtime

Run the fixture

Tested with Python 3.12, mcp==1.19.0, pydantic==2.11.7, Pillow 11–12, and Node.js. With uv:

uv run --python 3.12 --with 'mcp==1.19.0' --with 'pydantic==2.11.7' --with 'pillow>=11,<13' python server_fixture.py --transport streamable-http --port 19099

The demo listens only on 127.0.0.1:19099; connect a local client at http://127.0.0.1:19099/mcp. It can also run over stdio by omitting the transport flag. The fixture needs no credentials and must not be used as a public service.

In the target AI client, invoke visual_fixture and ask it to independently identify the shapes, colors and four-character text in both images. Do not supply expected answers or allow source inspection. A client with only text inference may still retrieve the JPEGs and route them to a separate authorized visual model. Record that route accurately. The format_fixture tool exercises all four raster formats.

Integrate with an existing FastMCP service

Place server_adapter.py and photo_preview.html together next to your existing server module. Register the resource once. Use the versioned URI and attach the metadata only to tools intended for display:

from mcp.server.fastmcp import FastMCP, Image
from server_adapter import RESOURCE_URI, register_photo_preview_ui

mcp = FastMCP('Image service')
register_photo_preview_ui(mcp)

@mcp.tool(meta={"ui": {"resourceUri": RESOURCE_URI},
                "openai/outputTemplate": RESOURCE_URI})
def preview():
    jpeg_bytes = read_authorized_private_image()  # Your existing access-controlled source
    return [Image(data=jpeg_bytes, format='jpeg')]

The register_photo_tool_with_ui helper is another way to bind an existing handler. It preserves unstructured native image blocks. A resource URI is a version/cache key; change it when changing the UI. For ChatGPT custom-server connections, refresh tools and start a new conversation explicitly bound to the plugin after metadata changes. See OpenAI MCP App UI guidance and the MCP Apps specification.

Compatibility evidence

Observed in local tests, not a guarantee for all installations:

Client or path

Evidence

ChatGPT Web

Earlier JPEG-only version: real private image tool returned two JPEGs, and both rendered in the chat's native app iframe after connection refresh and a new chat.

Antigravity desktop

Native tool vision: two JPEGs and, with version 2, four distinct JPEG/PNG/WebP/GIF fixtures were independently identified with every shape, color and code correct. The shared compatibility Skill was loaded. Private remote OAuth connection still requires authorization.

DeepSeek Harness

Standard SDK received two valid JPEGs. Its current text-only lead needed a vision-capable submodel, which successfully read both images. Initial native connector hot reload not verified.

WorkBuddy

Standard SDK received two valid JPEGs, and its visual tool independently identified their shapes and text. Local file preview was observed. The native MCP tool was not mounted in the running conversation despite configuration.

Qwen Code

Native MCP tool returned both JPEGs. A separate host vision model transcribed the visuals correctly; the lead model was text-only.

Hermes

Local server connection and tool discovery succeeded. Inference provider not configured during test.

A mobile assistant

Local HTTP connection rejected because HTTPS was required; authenticated remote connection then failed at authentication. No model vision result.

Gemini Web

One account connected the custom server over OAuth and invoked photo search. In Task mode the model reported it could not see its tool's photo content; the same model accurately described the same preview when uploaded as a normal attachment. The attachment route is a separate test, not native MCP image support. Embedded UI rendering was not established. Results may vary by model and host version.

Version 2's four-format support has passed a local protocol/decode test, an MCP tool-to-model blind visual test in Antigravity, and a mocked host UI lifecycle test; only version 1 JPEG rendering has been verified on the actual ChatGPT host so far. Client support for raw image results and UI can vary by model, provider, SDK and version.

For a real private service, OAuth is a separate requirement from the image protocol. A connection that returns 401 has not granted the client access. Use supported authentication rather than opening the media route to the public or reusing another client's token. A local test fixture establishes compatibility but cannot establish authorization for cloud user data.

When authentication fails after a password or configuration change, trace the public URL through its tunnel, front end, and authentication process. Confirm the process actually serving that URL has loaded the new configuration; a healthy but different service instance does not prove it has. Complete the authorization-code and PKCE flow for each client using its supported mechanism. Avoid logging passwords, authorization codes, tokens, or private media.

An image block can decode successfully and still contain a black or otherwise uninformative picture. Compare it with the source when possible before declaring a retrieval bug: a black image can be genuine content. Conversely, HTTP success and valid JPEG bytes alone do not prove that a model identified the picture.

Verify locally

uv run --python 3.12 --with 'mcp==1.19.0' --with 'pydantic==2.11.7' python verify_contract.py
node verify_host_simulation.mjs
# Run the server fixture in a different terminal first
uv run --python 3.12 --with 'mcp==1.19.0' --with 'pydantic==2.11.7' --with 'pillow>=11,<13' python verify_fixture_live.py --port 19099

Security and limits

This is a renderer/adapter, not an authentication server or a Google Photos retrieval implementation. Keep your data source, credentials, and authorization policy separate. The local scaffold is intentionally unauthenticated because it only creates synthetic images and binds to loopback. Never expose actual private photos through an unauthenticated fixture or proxy. Preview sizes and retention depend on the host and authorized image source.

To reuse the cross-client testing workflow in an agent, install the portable mcp-image-preview Skill in that agent's supported skill directory.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • F
      license
      Not graded
      quality
      A
      maintenance
      Enables Codex to run image generation and inspection as durable, idempotent local jobs that return only bounded text handoffs, hashes, relative references, and Job IDs while keeping provider media bytes behind the MCP boundary. This keeps image-heavy workflows context-bounded, restart-safe, and resumable across multiple concurrent Codex tasks.
      -
    • A
      license
      Not graded
      quality
      A
      maintenance
      Enables Codex to run context-bounded image generation and inspection as durable local jobs, returning bounded text handoffs, hashes, relative references, and Job IDs while keeping provider-returned media bytes outside the MCP boundary.
      MIT