cxxmcp 1.3.0
C++ MCP SDK
Loading...
Searching...
No Matches
mcp::transport::StreamableHttpServerTransport Class Referencefinal

Native transport-contract server for Streamable HTTP. More...

#include <http_transport.hpp>

Inheritance diagram for mcp::transport::StreamableHttpServerTransport:
mcp::transport::Transport< Role >

Public Member Functions

 StreamableHttpServerTransport (StreamableHttpServerTransportOptions options)
 
 StreamableHttpServerTransport (const StreamableHttpServerTransport &)=delete
 
StreamableHttpServerTransport & operator= (const StreamableHttpServerTransport &)=delete
 
std::string_view name () const noexcept override
 Human-readable transport name for diagnostics.
 
protocol::Json diagnostics () const override
 Structured implementation diagnostics.
 
core::Result< core::Unit > send (TxMessage message) override
 Sends one JSON-RPC message to the peer.
 
core::Result< core::Unit > send_to_session (std::string_view session_id, TxMessage message)
 Sends a message using the HTTP session that produced a request.
 
core::Result< std::optional< RxMessage > > receive () override
 Receives the next JSON-RPC message from the peer.
 
core::Result< std::optional< RxMessage > > receive_response (const protocol::RequestId &id) override
 Waits for the client response to one reverse (server-initiated) request without competing with receive().
 
std::optional< StreamableHttpServerMessageContext > last_received_context () const
 
void publish_subscription_notification (std::string_view method, protocol::Json params) override
 Forwards a notification to active subscriptions/listen streams.
 
core::Result< core::Unit > close () override
 Closes the transport and unblocks receive() where possible.
 
void wait_until_ready () override
 Blocks until the transport is ready to process messages.
 

Additional Inherited Members

- Public Types inherited from mcp::transport::Transport< Role >
using TxMessage = typename MessageTraits< Role >::TxMessage
 
using RxMessage = typename MessageTraits< Role >::RxMessage
 

Detailed Description

Native transport-contract server for Streamable HTTP.

receive() owns a background legacy HTTP server loop and returns inbound client requests and notifications. Sending a response completes a client request previously returned by receive(); sending a request or notification delivers it to the active HTTP session through the established server HTTP transport. Concurrent receive() calls are not supported.

Member Function Documentation

◆ close()

core::Result< core::Unit > mcp::transport::StreamableHttpServerTransport::close ( )
overridevirtual

Closes the transport and unblocks receive() where possible.

Implements mcp::transport::Transport< Role >.

◆ diagnostics()

protocol::Json mcp::transport::StreamableHttpServerTransport::diagnostics ( ) const
overridevirtual

Structured implementation diagnostics.

The default keeps the core contract narrow. Transports with useful state may return keys such as "name", "closed", "inflight", or backend-specific counters. Diagnostics are not part of the wire protocol.

Reimplemented from mcp::transport::Transport< Role >.

◆ name()

std::string_view mcp::transport::StreamableHttpServerTransport::name ( ) const
overridevirtualnoexcept

Human-readable transport name for diagnostics.

Implements mcp::transport::Transport< Role >.

◆ publish_subscription_notification()

void mcp::transport::StreamableHttpServerTransport::publish_subscription_notification ( std::string_view  method,
protocol::Json  params 
)
overridevirtual

Forwards a notification to active subscriptions/listen streams.

Reimplemented from mcp::transport::Transport< Role >.

◆ receive()

core::Result< std::optional< RxMessage > > mcp::transport::StreamableHttpServerTransport::receive ( )
overridevirtual

Receives the next JSON-RPC message from the peer.

receive() is the sequential inbound side. A successful std::nullopt return is an orderly end-of-stream signal, not a parse or transport error.

Implements mcp::transport::Transport< Role >.

◆ receive_response()

core::Result< std::optional< RxMessage > > mcp::transport::StreamableHttpServerTransport::receive_response ( const protocol::RequestId &  id)
overridevirtual

Waits for the client response to one reverse (server-initiated) request without competing with receive().

Reimplemented from mcp::transport::Transport< Role >.

◆ send()

core::Result< core::Unit > mcp::transport::StreamableHttpServerTransport::send ( TxMessage  message)
overridevirtual

Sends one JSON-RPC message to the peer.

Concurrency safety is implementation-specific and must be documented by the concrete transport.

Implements mcp::transport::Transport< Role >.

◆ wait_until_ready()

void mcp::transport::StreamableHttpServerTransport::wait_until_ready ( )
overridevirtual

Blocks until the transport is ready to process messages.

The default is a no-op. Transports that need asynchronous startup (e.g. binding a socket) override this to block until the underlying resource is available.

Reimplemented from mcp::transport::Transport< Role >.


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