#json-rpc #stdio-transport #mcp #stdio #transport

turbomcp-stdio

Standard I/O transport implementation for TurboMCP - newline-delimited JSON over stdin/stdout

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

Download history 3/week @ 2026-01-21 10/week @ 2026-01-28 4/week @ 2026-02-04 19/week @ 2026-02-18 3/week @ 2026-02-25 102/week @ 2026-03-04 74/week @ 2026-03-11 57/week @ 2026-03-18 53/week @ 2026-03-25 65/week @ 2026-04-01 107/week @ 2026-04-08

300 downloads per month
Used in 5 crates (via turbomcp-transport)

MIT license

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 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
  • 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

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::Mutex for state/config (short-lived locks, never cross .await)
  • AtomicMetrics for lock-free counter updates
  • tokio::sync::Mutex for I/O streams (necessary for async I/O)

License

MIT

Dependencies

~17–26MB
~368K SLoC