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

Adapts a transport::ClientTransport to the existing client::Transport API. More...

#include <transport_adapter.hpp>

Inheritance diagram for mcp::client::ContractTransportAdapter:
mcp::client::Transport

Public Member Functions

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

Detailed Description

Adapts a transport::ClientTransport to the existing client::Transport API.

This lets the established Client compatibility API and ClientPeer run over the role-generic transport contract. Inbound notifications and requests received while waiting for the matching response are dispatched through handlers installed with start(). This compatibility adapter expects send() calls to be serialized by the caller.

Member Function Documentation

◆ send()

core::Result< protocol::JsonRpcResponse > mcp::client::ContractTransportAdapter::send ( const protocol::JsonRpcRequest request)
inlineoverridevirtual

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.

Implements mcp::client::Transport.

◆ send_notification()

core::Result< core::Unit > mcp::client::ContractTransportAdapter::send_notification ( const protocol::JsonRpcNotification notification)
inlineoverridevirtual

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 from mcp::client::Transport.

◆ start()

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

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 from mcp::client::Transport.

◆ stop()

void mcp::client::ContractTransportAdapter::stop ( )
inlineoverridevirtualnoexcept

Requests transport shutdown.

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

Reimplemented from mcp::client::Transport.


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