5#ifndef PT_MCP_CONTENTTYPE_H
6#define PT_MCP_CONTENTTYPE_H
9#include <Pt/Formatter.h>
77 void write(
const char* s, std::size_t n);
193 std::string _mimeType;
Writer for one MCP content block around a Formatter.
Definition ContentType.h:36
void finishContent(std::ostream &os)
Flushes buffered output and writes the closing bytes to os.
void write(const char *s, std::size_t n)
Writes n raw bytes from s to the output stream.
Pt::Formatter & beginContent(std::ostream &os)
Writes the opening bytes of the content block to os.
virtual void onFinishContent()=0
Writes the closing bytes of the concrete content block.
virtual ~ContentFormatter()
Destroys the formatter.
virtual Pt::Formatter & onBeginFormat()=0
Returns the Formatter the decomposed result is drained into.
std::ostream & output() const
Returns the output stream passed to beginContent().
Definition ContentType.h:81
virtual void onBeginContent()=0
Writes the opening bytes of the concrete content block.
ContentFormatter()
Creates an idle content formatter.
Strategy that formats a tool result as MCP content.
Definition ContentType.h:107
virtual void releaseFormatter(ContentFormatter *formatter) const =0
Releases a formatter previously obtained from getFormatter().
virtual ContentFormatter * getFormatter() const =0
Creates a new ContentFormatter for a result.
virtual ~ContentType()
Destroys the content type.
Formats tool results as MCP image content.
Definition ContentType.h:178
ImageContent(const std::string &mimeType="image/png")
Creates an image content type with MIME type mimeType.
void releaseFormatter(ContentFormatter *formatter) const override
Releases a formatter previously obtained from getFormatter().
ContentFormatter * getFormatter() const override
Creates a new formatter for an image content block.
Formats tool results as MCP text content.
Definition ContentType.h:141
void releaseFormatter(ContentFormatter *formatter) const override
Releases a formatter previously obtained from getFormatter().
TextContent()
Creates a text content type.
ContentFormatter * getFormatter() const override
Creates a new formatter for a text content block.
PT_MCP_API const ImageContent & imageContent()
Returns the process-wide PNG image content type.
PT_MCP_API const TextContent & textContent()
Returns the process-wide text content type.
Model Context Protocol (MCP) services.
Core module.
Definition Allocator.h:33