TextContent Class Reference

#include <Pt/Mcp/ContentType.h>

Formats tool results as MCP text 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 the result using TextFormatter (compact YAML-like) and embeds it in a text content block.

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.