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

Client transport that exchanges MCP JSON-RPC messages over HTTP. More...

#include <http_transport.hpp>

Inheritance diagram for mcp::client::HttpTransport:
mcp::client::Transport

Public Member Functions

 HttpTransport (HttpTransportOptions options)
 Creates an HTTP transport from endpoint options.
 
core::Result< protocol::JsonRpcResponsesend (const protocol::JsonRpcRequest &request) override
 Sends one JSON-RPC request to the HTTP endpoint.
 
core::Result< core::Unitsend_notification (const protocol::JsonRpcNotification &notification) override
 Sends a JSON-RPC notification to the HTTP endpoint.
 
core::Result< core::Unitstart (TransportRequestHandler request_handler, TransportNotificationHandler notification_handler={}) override
 Starts receive-side handling for server-initiated messages.
 
void stop () noexcept override
 Stops background receive activity and releases transport resources.
 
void set_negotiated_protocol_version (std::string version)
 Updates the negotiated protocol version for subsequent requests.
 

Detailed Description

Client transport that exchanges MCP JSON-RPC messages over HTTP.

The transport implements Client::Transport and can be used directly with Client(std::unique_ptr<Transport>) or indirectly through Client factory helpers.

Constructor & Destructor Documentation

◆ HttpTransport()

mcp::client::HttpTransport::HttpTransport ( HttpTransportOptions  options)
explicit

Creates an HTTP transport from endpoint options.

Parameters
optionsHost, port, path, headers, and timeout configuration.

Member Function Documentation

◆ send()

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

Sends one JSON-RPC request to the HTTP endpoint.

Implements mcp::client::Transport.

◆ send_notification()

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

Sends a JSON-RPC notification to the HTTP endpoint.

Reimplemented from mcp::client::Transport.

◆ set_negotiated_protocol_version()

void mcp::client::HttpTransport::set_negotiated_protocol_version ( std::string  version)

Updates the negotiated protocol version for subsequent requests.

Called after version negotiation to ensure headers reflect the agreed version.

◆ start()

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

Starts receive-side handling for server-initiated messages.

Parameters
request_handlerHandler for inbound server requests.
notification_handlerHandler for inbound server notifications.

Reimplemented from mcp::client::Transport.

◆ stop()

void mcp::client::HttpTransport::stop ( )
overridevirtualnoexcept

Stops background receive activity and releases transport resources.

Reimplemented from mcp::client::Transport.


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