|
cxxmcp 1.1.6
C++ MCP SDK
|
Message-level stdio transport for either MCP role. More...
#include <stdio_transport.hpp>
Public Types | |
| using | TxMessage = typename Transport< Role >::TxMessage |
| using | RxMessage = typename Transport< Role >::RxMessage |
Public Types inherited from mcp::transport::Transport< Role > | |
| using | TxMessage = typename MessageTraits< Role >::TxMessage |
| using | RxMessage = typename MessageTraits< Role >::RxMessage |
Public Member Functions | |
| StdioTransport (std::istream &input, std::ostream &output) | |
| 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< std::optional< RxMessage > > | receive () override |
| Receives the next JSON-RPC message from the peer. | |
| core::Result< core::Unit > | close () override |
| Closes the transport and unblocks receive() where possible. | |
Public Member Functions inherited from mcp::transport::Transport< Role > | |
| virtual void | wait_until_ready () |
| Blocks until the transport is ready to process messages. | |
Message-level stdio transport for either MCP role.
Messages are encoded as one JSON-RPC document per line. receive() reads the next line and parses it as a JsonRpcMessage; EOF is reported as std::nullopt. send() is serialized with an internal mutex. receive() is sequential and must not be called concurrently. close() marks the transport closed; it makes later receive() calls return std::nullopt and later send() calls fail, but it cannot interrupt a platform stream read already blocked inside std::getline().
This message-level transport intentionally does not correlate requests and responses. Duplicate in-flight request-id checks are implemented by the peer/request engine or by transports that own an asynchronous pending map.
|
inlineoverridevirtual |
Closes the transport and unblocks receive() where possible.
Implements mcp::transport::Transport< Role >.
|
inlineoverridevirtual |
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 >.
|
inlineoverridevirtualnoexcept |
Human-readable transport name for diagnostics.
Implements mcp::transport::Transport< Role >.
|
inlineoverridevirtual |
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 >.
|
inlineoverridevirtual |
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 >.