Skip to main content

Module read_image

Module read_image 

Source
Expand description

Bounded native-image delivery for multimodal MCP clients.

Small valid images pass through unchanged. Large images are decoded with explicit resource limits, resized, and encoded as a bounded JPEG before they enter JSON/base64. A live session also remembers recent content fingerprints so an accidental repeated call does not resend the same multi-megabyte image.

Structs§

ReadImageMetadata
Safe metadata returned alongside native image content.

Enums§

ReadImageDelivery
Detailed server-facing outcome. Direct library callers retain the historical (mime_type, base64_data) wrapper below.

Constants§

MAX_DELIVERED_BYTES
Maximum binary image payload before base64 expansion. This turns the 17 MiB production outlier into a response of at most ~2.7 MiB of base64.
MAX_DELIVERED_DIMENSION
Multimodal models downsample large inputs anyway; bounding the long edge preserves useful screenshot detail without shipping wallpaper-sized files.
SUPPORTED_MIME_TYPES
Supported MCP image MIME types.

Functions§

handle_tool_call
Backwards-compatible text-free library API. Direct callers explicitly get an image every time; MCP callers use handle_tool_call_detailed so repeat deliveries can be compacted safely.
handle_tool_call_detailed
Server-facing image delivery with content-based, per-session deduplication.