23 releases (15 stable)
Uses new Rust 2024
| new 3.0.14 | Apr 15, 2026 |
|---|---|
| 3.0.13 | Apr 14, 2026 |
| 3.0.10 | Mar 27, 2026 |
| 3.0.0-exp.2 | Jan 13, 2026 |
| 3.0.0-beta.5 | Feb 24, 2026 |
#6 in #stdio-transport
300 downloads per month
Used in 5 crates
(via turbomcp-transport)
1MB
19K
SLoC
turbomcp-stdio
Standard I/O transport implementation for the TurboMCP Model Context Protocol SDK.
Overview
This crate provides the StdioTransport implementation for MCP communication over stdin/stdout, which is the standard way MCP servers communicate with clients. It supports JSON-RPC over newline-delimited JSON.
MCP Specification Compliance
This implementation follows the MCP stdio transport requirements used by TurboMCP v3 (2025-11-25):
- 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
- 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
Usage
use turbomcp_stdio::{StdioTransport, Transport};
#[tokio::main]
async fn main() {
let transport = StdioTransport::new();
transport.connect().await.unwrap();
// Send and receive messages...
}
Features
- Zero-copy message handling with
Bytes - Lock-free atomic metrics for high performance
- Background reader task with bounded channel for backpressure
- Configurable message size limits
Architecture
The transport follows the hybrid mutex pattern for optimal async performance:
std::sync::Mutexfor state/config (short-lived locks, never cross.await)AtomicMetricsfor lock-free counter updatestokio::sync::Mutexfor I/O streams (necessary for async I/O)
License
MIT
Dependencies
~17–26MB
~368K SLoC