StdioService Class Reference

#include <Pt/Mcp/StdioService.h>

MCP protocol service over stdio. More...

Public Member Functions

 StdioService (Remoting::ServiceDefinition &serviceDef, const ToolDeclaration &decl)
 Construct with a service definition and tool declaration.
 
 ~StdioService ()
 Destructor.
 
std::string readMessage (std::istream &is)
 Read a Content-Length framed message from the stream. More...
 
void writeMessage (std::ostream &os, const std::string &json)
 Write a Content-Length framed message to the stream.
 
std::string dispatch (const std::string &json)
 Dispatch an MCP request and return the response JSON. More...
 

Detailed Description

Handles the full MCP protocol lifecycle: initialize, tools/list, and tools/call. Reads/writes Content-Length framed messages.

Member Function Documentation

◆ readMessage()

std::string readMessage ( std::istream &  is)

Returns the JSON body, or an empty string on EOF.

◆ dispatch()

std::string dispatch ( const std::string &  json)

Routes to initialize, tools/list, or tools/call handlers. Returns an empty string for notifications (no id).