ImageContent Class Reference

#include <Pt/Mcp/ContentType.h>

Formats tool results as MCP image content. More...

Inherits ContentType.

Public Member Functions

 ImageContent (const std::string &mimeType="image/png")
 Creates an image content type with MIME type mimeType.
ContentFormattergetFormatter () const override
 Creates a new formatter for an image content block.
void releaseFormatter (ContentFormatter *formatter) const override
 Releases a formatter previously obtained from getFormatter().

Detailed Description

ImageContent serializes a decomposed binary result as a base64-encoded MCP image content block. The tool's return value must decompose to a single Binary node. The bytes are encoded as they are decomposed, without buffering the whole image. The MIME type is set at construction and defaults to image/png.

imageContent() is the process-wide instance with that default MIME type. A different MIME type needs a caller-owned ImageContent that outlives the tool.