ContentType Class Referenceabstract

#include <Pt/Mcp/ContentType.h>

Strategy that formats a tool result as MCP content. More...

Inherited by ImageContent, and TextContent.

Public Member Functions

virtual ~ContentType ()
 Destroys the content type.
virtual ContentFormattergetFormatter () const =0
 Creates a new ContentFormatter for a result.
virtual void releaseFormatter (ContentFormatter *formatter) const =0
 Releases a formatter previously obtained from getFormatter().

Detailed Description

ContentType chooses how a decomposer result becomes an MCP content block. getFormatter() creates the ContentFormatter used to write that block. The caller drives beginContent(), the decomposer begin/advance protocol, then finishContent(), and releases the formatter with releaseFormatter() whether the format completed or was abandoned.

Implementations used as process-wide singletons, including textContent() and imageContent(), may run on many responders at once. getFormatter() must be stateless on the content type: it may read immutable members set at construction and must not cache a formatter, stream, or scratch buffer as a mutable member. All per-request state belongs on the ContentFormatter.

Member Function Documentation

◆ getFormatter()

virtual ContentFormatter * getFormatter ( ) const
pure virtual

The caller owns the returned formatter and must release it with releaseFormatter(). The output stream is passed later to ContentFormatter::beginContent().

Implemented in ImageContent, and TextContent.

◆ releaseFormatter()

virtual void releaseFormatter ( ContentFormatter * formatter) const
pure virtual

Deletes formatter. The caller must not use it afterward. Call ContentFormatter::finishContent() first to complete the content block normally.

Implemented in ImageContent, and TextContent.