Expand description
§TurboMCP STDIO Transport
Standard I/O transport implementation for the TurboMCP Model Context Protocol SDK. This transport uses stdin/stdout for communication, which is the standard way MCP servers communicate with clients.
§MCP Specification Compliance
This implementation is fully compliant with the MCP stdio transport specification:
- Newline-delimited JSON: Uses
LinesCodecfor proper message framing - No embedded newlines: Validates messages don’t contain
\nor\rcharacters - UTF-8 encoding: All messages are UTF-8 encoded (enforced by
std::str::from_utf8) - stderr for logging: Uses
tracingcrate which outputs to stderr by default - Bidirectional communication: Supports both client→server and server→client messages
- Valid JSON only: Validates all messages are well-formed JSON before sending
Per MCP spec: “Messages are delimited by newlines, and MUST NOT contain embedded newlines.”
§Usage
ⓘ
use turbomcp_stdio::StdioTransport;
use turbomcp_transport_traits::Transport;
#[tokio::main]
async fn main() {
let transport = StdioTransport::new();
transport.connect().await.unwrap();
// Send and receive messages...
}Structs§
- Stdio
Transport - Standard I/O transport implementation
- Stdio
Transport Factory - Factory for creating stdio transport instances
- Transport
Capabilities - Describes the capabilities of a transport implementation.
- Transport
Config - Configuration for a transport instance.
- Transport
Message - A wrapper for a message being sent or received over a transport.
- Transport
Metrics - A serializable snapshot of a transport’s performance metrics.
Enums§
- Transport
Error - Represents errors that can occur during transport operations.
- Transport
State - Represents the current state of a transport connection.
- Transport
Type - Enumerates the types of transports supported by the system.
Traits§
- Transport
- The core trait for all transport implementations.
- Transport
Factory - A factory for creating instances of a specific transport type.
Type Aliases§
- Transport
Result - A specialized
Resulttype for transport operations.