15namespace mcp::transport {
40 using TxMessage =
typename MessageTraits<Role>::TxMessage;
41 using RxMessage =
typename MessageTraits<Role>::RxMessage;
46 virtual std::string_view
name() const noexcept = 0;
54 return protocol::Json::object();
87 return mcp::core::unexpected(
88 core::Error{
static_cast<int>(protocol::ErrorCode::MethodNotFound),
89 "transport does not route reverse responses directly",
115using ClientTransport = Transport<RoleClient>;
116using ServerTransport = Transport<RoleServer>;
Minimal message-level transport contract shared by MCP roles.
Definition transport.hpp:38
virtual core::Result< std::optional< RxMessage > > receive()=0
Receives the next JSON-RPC message from the peer.
virtual core::Result< std::optional< RxMessage > > receive_response(const protocol::RequestId &id)
Waits for the response to one specific outbound request.
Definition transport.hpp:84
virtual std::string_view name() const noexcept=0
Human-readable transport name for diagnostics.
virtual void wait_until_ready()
Blocks until the transport is ready to process messages.
Definition transport.hpp:112
virtual core::Result< core::Unit > send(TxMessage message)=0
Sends one JSON-RPC message to the peer.
virtual void publish_subscription_notification(std::string_view method, protocol::Json params)
Publishes a notification to active subscription listen streams.
Definition transport.hpp:98
virtual core::Result< core::Unit > close()=0
Closes the transport and unblocks receive() where possible.
virtual protocol::Json diagnostics() const
Structured implementation diagnostics.
Definition transport.hpp:53
Shared JSON, JSON-RPC, error, cancellation, and progress model types.
nlohmann::json Json
JSON value type used by all protocol DTOs.
Definition types.hpp:28
std::variant< JsonRpcRequest, JsonRpcResponse, JsonRpcNotification > JsonRpcMessage
Variant over the JSON-RPC message shapes accepted by MCP transports.
Definition types.hpp:148
std::variant< std::int64_t, std::string > RequestId
JSON-RPC request or response identifier.
Definition types.hpp:56
Shared result and error primitives used by the public cxxmcp SDK.
tl::expected< T, Error > Result
Alias for the SDK result type.
Definition result.hpp:64
Role markers shared by peer, service, and transport SDK boundaries.
Structured error returned by fallible SDK operations.
Definition result.hpp:35
Message types exchanged by a role-generic transport.
Definition transport.hpp:19