Skip to main content

Crate turbomcp_stdio

Crate turbomcp_stdio 

Source
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 LinesCodec for proper message framing
  • No embedded newlines: Validates messages don’t contain \n or \r characters
  • UTF-8 encoding: All messages are UTF-8 encoded (enforced by std::str::from_utf8)
  • stderr for logging: Uses tracing crate 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§

StdioTransport
Standard I/O transport implementation
StdioTransportFactory
Factory for creating stdio transport instances
TransportCapabilities
Describes the capabilities of a transport implementation.
TransportConfig
Configuration for a transport instance.
TransportMessage
A wrapper for a message being sent or received over a transport.
TransportMetrics
A serializable snapshot of a transport’s performance metrics.

Enums§

TransportError
Represents errors that can occur during transport operations.
TransportState
Represents the current state of a transport connection.
TransportType
Enumerates the types of transports supported by the system.

Traits§

Transport
The core trait for all transport implementations.
TransportFactory
A factory for creating instances of a specific transport type.

Type Aliases§

TransportResult
A specialized Result type for transport operations.