feat(transport): add Unix domain socket client for streamable HTTP#749
Open
wpfleger96 wants to merge 2 commits intomodelcontextprotocol:mainfrom
Open
feat(transport): add Unix domain socket client for streamable HTTP#749wpfleger96 wants to merge 2 commits intomodelcontextprotocol:mainfrom
wpfleger96 wants to merge 2 commits intomodelcontextprotocol:mainfrom
Conversation
MCP hosts in Kubernetes environments with Envoy sidecars need to route HTTP through Unix domain sockets because DNS-based URIs only resolve via the proxy. Adds UnixSocketHttpClient implementing StreamableHttpClient using hyper over tokio::net::UnixStream, gated behind the transport-streamable-http-client-unix-socket feature. Also extracts RESERVED_HEADERS, extract_scope_from_header, and validate_custom_header into common/http_header.rs to share header validation logic between the reqwest and unix socket implementations.
- Document one-connection-per-request behavior on UnixSocketHttpClient - Reject empty socket paths and bare '@' in constructor with assert - Add explicit dep:http to unix-socket feature for self-documenting deps - Document MCP-Protocol-Version exception on RESERVED_HEADERS constant - Fix test catch-all to echo request id instead of hardcoding 1 - Remove leftover sleep(100ms) in test_unix_socket_custom_headers - Add blank line before macro comment in Cargo.toml
wpfleger96
added a commit
to block/goose
that referenced
this pull request
Mar 13, 2026
Replace goose local UnixSocketHttpClient with the upstream implementation from rmcp transport-streamable-http-client-unix-socket feature (modelcontextprotocol/rust-sdk#749). Deletes ~420 lines of local transport code and delegates to rmcp for the Unix socket client, socket path resolution, Host header derivation, and custom header validation. Temporarily points rmcp at the wpfleger96/rust-sdk fork for testing. Will switch back to crates.io once the upstream PR is merged and released.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
UnixSocketHttpClient, a newStreamableHttpClientimplementation that routes MCP HTTP traffic through a Unix domain socket usinghyper+tokio::net::UnixStream, gated behind thetransport-streamable-http-client-unix-socketfeature.MCP hosts running in Kubernetes environments with Envoy sidecars can't use TCP/DNS because outbound traffic must go through the sidecar proxy, which exposes an abstract Unix socket (e.g.,
@egress.sock). This unblocks any rmcp-based MCP host from connecting through a service mesh sidecar by setting the socket path at transport construction time. The goose equivalent lives in block/goose#7631 and will be replaced with this once merged.UnixSocketHttpClientwithnew(socket_path, uri)constructor andfrom_unix_socket/from_unix_socket_with_configconvenience constructors onStreamableHttpClientTransport@name→\0name) viaspawn_blocking+std::os::unix::netsincetokio::net::UnixStreamlacksconnect_addr; filesystem sockets work on all Unix targetsRESERVED_HEADERS,validate_custom_header, andextract_scope_from_headerfromreqwest/streamable_http_client.rsintocommon/http_header.rsso both HTTP client implementations share a single source of truth for header policyUnixListenerand exercise handshake, custom header forwarding, and the convenience constructor