Skip to content

feat: Unix Domain Socket transport #717

@joshrotenberg

Description

@joshrotenberg

Summary

Add Unix Domain Socket (UDS) transport support, allowing MCP servers to listen on a Unix socket instead of TCP. This is useful for local-only server deployments where network exposure is unnecessary and IPC performance matters.

Motivation

  • rmcp has UDS client support in progress
  • turbomcp lists UDS as a supported transport
  • UDS avoids TCP overhead for local communication (no port allocation, no loopback)
  • Common pattern for containerized/sidecar deployments

Implementation

The existing transport architecture makes this straightforward. Both HttpTransport and WebSocketTransport follow the same pattern: bind a listener, build an axum Router, call axum::serve(listener, router). axum's serve() accepts any type implementing the Listener trait, and tokio::net::UnixListener satisfies this.

Approach

  1. New module: crates/tower-mcp/src/transport/unix.rs
  2. UnixSocketTransport struct parallel to HttpTransport/WebSocketTransport
  3. Feature flag: unix (depends on http feature for shared axum machinery)
  4. Reuses session management, SSE notifications, and middleware from HTTP transport
  5. .layer() support inherited from the same pattern

Scope

  • Unix-only (Linux, macOS, BSD) -- #[cfg(unix)] gated
  • No Windows Named Pipes support initially
  • Streamable HTTP over UDS (same protocol, different listener)
  • Example: examples/unix_socket_server.rs

Estimated Effort

3-5 days including tests, docs, and example.

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions