22#include <unordered_map>
29namespace mcp::transport {
38 std::string
host =
"127.0.0.1";
47 std::unordered_map<std::string, std::string>
headers;
129 std::string_view
name() const noexcept override;
140 core::Result<core::Unit>
send(TxMessage message) override;
145 core::Result<std::optional<RxMessage>>
receive() override;
148 core::Result<core::Unit>
close() override;
152 std::unique_ptr<Impl> impl_;
188 std::string_view
name() const noexcept override;
198 core::Result<core::Unit>
send(TxMessage message) override;
203 core::Result<std::optional<RxMessage>>
receive() override;
206 core::Result<core::Unit>
close() override;
213 std::unique_ptr<Impl> impl_;
Minimal message-level transport contract shared by MCP roles.
Definition transport.hpp:38
virtual void wait_until_ready()
Blocks until the transport is ready to process messages.
Definition transport.hpp:77
WebSocket-based MCP client transport.
Definition websocket_transport.hpp:116
protocol::Json diagnostics() const override
Returns structured diagnostics including connection state and stats.
~WebSocketClientTransport() override
Stops the reader thread and closes the WebSocket connection.
core::Result< core::Unit > send(TxMessage message) override
Sends a JSON-RPC message over the WebSocket connection.
std::string_view name() const noexcept override
Returns "websocket-client".
WebSocketClientTransport(WebSocketClientTransportOptions options)
Constructs a client transport with the given options.
core::Result< core::Unit > close() override
Closes the transport and unblocks any blocked receive().
core::Result< std::optional< RxMessage > > receive() override
Blocks until the next inbound JSON-RPC message is available.
WebSocket-based MCP server transport.
Definition websocket_transport.hpp:175
~WebSocketServerTransport() override
Stops the HTTP server and closes all WebSocket connections.
WebSocketServerTransport(WebSocketServerTransportOptions options)
Constructs a server transport with the given options.
std::string_view name() const noexcept override
Returns "websocket-server".
Shared JSON, JSON-RPC, error, cancellation, and progress model types.
Shared result and error primitives used by the public cxxmcp SDK.
Role markers shared by peer, service, and transport SDK boundaries.
Configuration for the WebSocket client transport.
Definition websocket_transport.hpp:32
std::chrono::milliseconds reconnect_initial_delay
Initial backoff delay before the first reconnect attempt.
Definition websocket_transport.hpp:62
int port
Remote port (used when uri is empty).
Definition websocket_transport.hpp:41
double reconnect_backoff_multiplier
Backoff multiplier applied after each failed attempt.
Definition websocket_transport.hpp:68
std::optional< std::string > auth_header
Optional Authorization header value (e.g. "Bearer <token>").
Definition websocket_transport.hpp:50
int max_missed_pongs
Maximum missed pongs before considering the connection dead.
Definition websocket_transport.hpp:74
std::string path
WebSocket path (used when uri is empty).
Definition websocket_transport.hpp:44
time_t ping_interval_sec
WebSocket ping interval in seconds (0 = disabled).
Definition websocket_transport.hpp:71
std::unordered_map< std::string, std::string > headers
Extra HTTP headers sent during the WebSocket upgrade handshake.
Definition websocket_transport.hpp:47
std::string host
Remote host (used when uri is empty).
Definition websocket_transport.hpp:38
int max_reconnect_attempts
Maximum consecutive reconnection attempts. 0 = unlimited.
Definition websocket_transport.hpp:59
std::chrono::milliseconds reconnect_max_delay
Maximum backoff delay (cap for exponential growth).
Definition websocket_transport.hpp:65
std::string uri
Full ws:// or wss:// URI for the MCP endpoint.
Definition websocket_transport.hpp:35
std::chrono::milliseconds timeout
Per-operation timeout for the WebSocket connection.
Definition websocket_transport.hpp:53
bool auto_reconnect
Enable automatic reconnection on disconnect.
Definition websocket_transport.hpp:56
Configuration for the WebSocket server transport.
Definition websocket_transport.hpp:78
std::string path
WebSocket endpoint path pattern (e.g. "/mcp").
Definition websocket_transport.hpp:86
int max_missed_pongs
Maximum missed pongs before dropping a client.
Definition websocket_transport.hpp:95
std::string listen_host
Interface address to bind.
Definition websocket_transport.hpp:80
std::size_t max_connections
Maximum concurrent WebSocket connections. 0 = unlimited.
Definition websocket_transport.hpp:89
time_t ping_interval_sec
WebSocket ping interval in seconds (0 = disabled).
Definition websocket_transport.hpp:92
int listen_port
TCP port to listen on.
Definition websocket_transport.hpp:83
Role-generic MCP transport contract for SDK peer/service layers.