|
cxxmcp 1.1.6
C++ MCP SDK
|
WebSocket-based MCP server transport. More...
#include <websocket_transport.hpp>
Public Member Functions | |
| WebSocketServerTransport (WebSocketServerTransportOptions options) | |
| Constructs a server transport with the given options. | |
| ~WebSocketServerTransport () override | |
| Stops the HTTP server and closes all WebSocket connections. | |
| WebSocketServerTransport (const WebSocketServerTransport &)=delete | |
| WebSocketServerTransport & | operator= (const WebSocketServerTransport &)=delete |
| std::string_view | name () const noexcept override |
| Returns "websocket-server". | |
| protocol::Json | diagnostics () const override |
| Returns structured diagnostics including connection count and stats. | |
| core::Result< core::Unit > | send (TxMessage message) override |
| Sends a JSON-RPC message to the appropriate connected client. | |
| core::Result< std::optional< RxMessage > > | receive () override |
| Blocks until the next inbound JSON-RPC message from any client. | |
| core::Result< core::Unit > | close () override |
| Closes the transport, all connections, and unblocks receive(). | |
| void | wait_until_ready () override |
| Blocks until the server socket is bound and listening. | |
Additional Inherited Members | |
Public Types inherited from mcp::transport::Transport< Role > | |
| using | TxMessage = typename MessageTraits< Role >::TxMessage |
| using | RxMessage = typename MessageTraits< Role >::RxMessage |
WebSocket-based MCP server transport.
Accepts WebSocket connections on a configurable path and provides a full-duplex JSON-RCP channel for each connected client. Responses are automatically routed to the connection that sent the corresponding request.
Thread safety: send() is safe to call from multiple threads. receive() is sequential. close() is safe to call from any thread.
|
explicit |
Constructs a server transport with the given options.
| options | Listen address and WebSocket configuration. |
|
overridevirtual |
Closes the transport, all connections, and unblocks receive().
Implements mcp::transport::Transport< Role >.
|
overridevirtual |
Returns structured diagnostics including connection count and stats.
Reimplemented from mcp::transport::Transport< Role >.
|
overridevirtualnoexcept |
Returns "websocket-server".
Implements mcp::transport::Transport< Role >.
|
overridevirtual |
Blocks until the next inbound JSON-RPC message from any client.
Returns std::nullopt when the transport is closed.
Implements mcp::transport::Transport< Role >.
|
overridevirtual |
Sends a JSON-RPC message to the appropriate connected client.
Responses are routed to the connection that sent the original request. Notifications are sent to the most recently active connection.
Implements mcp::transport::Transport< Role >.
|
overridevirtual |
Blocks until the server socket is bound and listening.
Reimplemented from mcp::transport::Transport< Role >.