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
- New module:
crates/tower-mcp/src/transport/unix.rs
UnixSocketTransport struct parallel to HttpTransport/WebSocketTransport
- Feature flag:
unix (depends on http feature for shared axum machinery)
- Reuses session management, SSE notifications, and middleware from HTTP transport
.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
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
Implementation
The existing transport architecture makes this straightforward. Both
HttpTransportandWebSocketTransportfollow the same pattern: bind a listener, build an axum Router, callaxum::serve(listener, router). axum'sserve()accepts any type implementing theListenertrait, andtokio::net::UnixListenersatisfies this.Approach
crates/tower-mcp/src/transport/unix.rsUnixSocketTransportstruct parallel toHttpTransport/WebSocketTransportunix(depends onhttpfeature for shared axum machinery).layer()support inherited from the same patternScope
#[cfg(unix)]gatedexamples/unix_socket_server.rsEstimated Effort
3-5 days including tests, docs, and example.
References