cxxmcp 1.1.6
C++ MCP SDK
Loading...
Searching...
No Matches
mcp::client::Transport Class Referenceabstract

Abstract client transport used by Client to exchange JSON-RPC messages. More...

#include <client.hpp>

Inheritance diagram for mcp::client::Transport:
mcp::client::ContractTransportAdapter mcp::client::HttpTransport mcp::client::ProcessStdioTransport mcp::client::StdioTransport

Public Member Functions

virtual core::Result< protocol::JsonRpcResponsesend (const protocol::JsonRpcRequest &request)=0
 Sends a JSON-RPC request and waits for the corresponding response.
 
virtual core::Result< core::Unitsend_notification (const protocol::JsonRpcNotification &notification)
 Sends a JSON-RPC notification without waiting for a response.
 
virtual core::Result< core::Unitstart (TransportRequestHandler request_handler, TransportNotificationHandler notification_handler={})
 Starts receiving inbound messages for transports that need an active loop.
 
virtual void stop () noexcept
 Requests transport shutdown.
 

Detailed Description

Abstract client transport used by Client to exchange JSON-RPC messages.

Implementations own the wire protocol details. Client calls send() for outbound requests and may call start() lazily before the first operation so transports can register inbound request and notification callbacks.

Member Function Documentation

◆ send()

virtual core::Result< protocol::JsonRpcResponse > mcp::client::Transport::send ( const protocol::JsonRpcRequest request)
pure virtual

Sends a JSON-RPC request and waits for the corresponding response.

Parameters
requestFully formed JSON-RPC request.
Returns
Response returned by the peer, or a transport/protocol error.

Implemented in mcp::client::HttpTransport, mcp::client::ProcessStdioTransport, mcp::client::StdioTransport, and mcp::client::ContractTransportAdapter.

◆ send_notification()

virtual core::Result< core::Unit > mcp::client::Transport::send_notification ( const protocol::JsonRpcNotification notification)
virtual

Sends a JSON-RPC notification without waiting for a response.

Parameters
notificationFully formed JSON-RPC notification.
Returns
Unit on success, or a transport/protocol error.

Reimplemented in mcp::client::HttpTransport, mcp::client::ProcessStdioTransport, mcp::client::StdioTransport, and mcp::client::ContractTransportAdapter.

◆ start()

virtual core::Result< core::Unit > mcp::client::Transport::start ( TransportRequestHandler  request_handler,
TransportNotificationHandler  notification_handler = {} 
)
inlinevirtual

Starts receiving inbound messages for transports that need an active loop.

Parameters
request_handlerCallback used for server-to-client JSON-RPC requests.
notification_handlerCallback used for server-to-client notifications.
Returns
Unit on success, or a startup error.
Note
The default implementation is a no-op for request/response-only transports.

Reimplemented in mcp::client::HttpTransport, mcp::client::ProcessStdioTransport, mcp::client::StdioTransport, and mcp::client::ContractTransportAdapter.

◆ stop()

virtual void mcp::client::Transport::stop ( )
inlinevirtualnoexcept

Requests transport shutdown.

stop() is best-effort and must not throw. Request/response-only transports can keep the default no-op implementation.

Reimplemented in mcp::client::HttpTransport, mcp::client::ProcessStdioTransport, and mcp::client::ContractTransportAdapter.


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