cxxmcp 1.1.6
C++ MCP SDK
Loading...
Searching...
No Matches
mcp::client::StdioTransport Class Referencefinal

Client transport backed by std::istream and std::ostream. More...

#include <stdio_transport.hpp>

Inheritance diagram for mcp::client::StdioTransport:
mcp::client::Transport

Public Member Functions

 StdioTransport ()
 Creates a stdio transport using standard input and output streams.
 
 StdioTransport (std::istream &input, std::ostream &output)
 Creates a stdio transport using caller-owned streams.
 
core::Result< protocol::JsonRpcResponsesend (const protocol::JsonRpcRequest &request) override
 Sends one JSON-RPC request over the output stream and waits for a response.
 
core::Result< core::Unitsend_notification (const protocol::JsonRpcNotification &notification) override
 Sends one JSON-RPC notification over the output stream.
 
core::Result< core::Unitstart (TransportRequestHandler request_handler, TransportNotificationHandler notification_handler={}) override
 Starts receive-side dispatch for stream input.
 
- Public Member Functions inherited from mcp::client::Transport
virtual void stop () noexcept
 Requests transport shutdown.
 

Detailed Description

Client transport backed by std::istream and std::ostream.

This transport is useful for tests, embedded integrations, or process environments where the streams are supplied by the caller instead of launching a child process.

send() is a single synchronous request/response exchange. The concrete stdio layer does not maintain an in-flight request registry, so duplicate in-flight request-id validation belongs to Peer/request-handle or role-generic transport adapters that add asynchronous correlation.

Constructor & Destructor Documentation

◆ StdioTransport()

mcp::client::StdioTransport::StdioTransport ( std::istream &  input,
std::ostream &  output 
)

Creates a stdio transport using caller-owned streams.

Parameters
inputStream read by the transport. The caller must keep it alive.
outputStream written by the transport. The caller must keep it alive.

Member Function Documentation

◆ send()

core::Result< protocol::JsonRpcResponse > mcp::client::StdioTransport::send ( const protocol::JsonRpcRequest request)
overridevirtual

Sends one JSON-RPC request over the output stream and waits for a response.

Implements mcp::client::Transport.

◆ send_notification()

core::Result< core::Unit > mcp::client::StdioTransport::send_notification ( const protocol::JsonRpcNotification notification)
overridevirtual

Sends one JSON-RPC notification over the output stream.

Reimplemented from mcp::client::Transport.

◆ start()

core::Result< core::Unit > mcp::client::StdioTransport::start ( TransportRequestHandler  request_handler,
TransportNotificationHandler  notification_handler = {} 
)
overridevirtual

Starts receive-side dispatch for stream input.

Parameters
request_handlerHandler for inbound requests read from the stream.
notification_handlerHandler for inbound notifications read from the stream.

Reimplemented from mcp::client::Transport.


The documentation for this class was generated from the following file: