Skip to main content

Crate turbomcp_unix

Crate turbomcp_unix 

Source
Expand description

§TurboMCP Unix Domain Socket Transport

Unix domain socket transport implementation for the TurboMCP SDK.

This crate provides inter-process communication over Unix domain sockets with:

  • Server Mode: Accept multiple client connections with automatic handling
  • Client Mode: Connect to a Unix socket server
  • Bidirectional Communication: Full-duplex message exchange
  • Backpressure Handling: Bounded channels prevent memory exhaustion
  • Graceful Shutdown: Clean task termination and socket cleanup
  • Message Framing: Uses LinesCodec for reliable newline-delimited JSON

§Quick Start

§Server Mode

use turbomcp_unix::{UnixTransport, UnixTransportBuilder};
use turbomcp_transport_traits::Transport;
use std::path::PathBuf;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let transport = UnixTransportBuilder::new_server()
        .socket_path("/tmp/my-mcp.sock")
        .permissions(0o600)
        .build();

    transport.connect().await?; // Starts listening
    Ok(())
}

§Client Mode

use turbomcp_unix::{UnixTransport, UnixTransportBuilder};
use turbomcp_transport_traits::Transport;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let transport = UnixTransportBuilder::new_client()
        .socket_path("/tmp/my-mcp.sock")
        .build();

    transport.connect().await?;
    Ok(())
}

§v3.0 Modular Architecture

This crate is part of TurboMCP v3.0’s modular transport architecture:

  • Foundation: turbomcp-transport-traits provides core abstractions
  • Individual Transports: Each transport (stdio, http, websocket, tcp, unix) is a separate crate
  • Backward Compatibility: turbomcp-transport re-exports all transports

Structs§

AtomicMetrics
A lock-free, atomic structure for high-performance metrics updates.
TransportCapabilities
Describes the capabilities of a transport implementation.
TransportMessage
A wrapper for a message being sent or received over a transport.
TransportMetrics
A serializable snapshot of a transport’s performance metrics.
UnixConfig
Unix socket transport configuration
UnixTransport
Unix domain socket transport implementation with integrated security
UnixTransportBuilder
Unix socket transport builder

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.

Type Aliases§

TransportResult
A specialized Result type for transport operations.