ImageContent Class Reference

#include <Pt/Mcp/ContentType.h>

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

Inherits ContentType.

Public Member Functions

ContentFormattergetFormatter () const override
 Creates a new ContentFormatter for a result. More...
 
void releaseFormatter (ContentFormatter *formatter) const override
 Releases a ContentFormatter previously obtained from getFormatter(). More...
 

Detailed Description

Serializes a decomposed binary result (the tool's return value must decompose to a single Binary node) as a base64-encoded MCP "image" content block. The binary bytes are base64-encoded incrementally as they are decomposed, without buffering the whole image in memory.

Member Function Documentation

◆ getFormatter()

ContentFormatter* getFormatter ( ) const
overridevirtual

The caller owns the returned ContentFormatter and must release it via releaseFormatter() once done with it, whether the format completed normally or was abandoned. The output stream is not known yet; it is passed to ContentFormatter::beginFormat().

Implements ContentType.

◆ releaseFormatter()

void releaseFormatter ( ContentFormatter formatter) const
overridevirtual

Deletes formatter; the caller must not use it afterward. Does not write anything - call formatter->finishFormat() first to complete the content block normally.

Implements ContentType.