docs/socket-communication.md
MCPProxy uses platform-specific local IPC for secure, low-latency communication between the tray application and core server.
0700 (user-only access) or server refuses to start (exit code 5)0600 (user read/write only)internal/httpapi/server.go checks connection source via context<data-dir>/mcpproxy.sock (default: ~/.mcpproxy/mcpproxy.sock)\\.\pipe\mcpproxy-<username> (or hashed for custom data-dir)--tray-endpoint flag or MCPPROXY_TRAY_ENDPOINT environment variableinternal/server/listener.go - Listener manager and abstraction layerinternal/server/listener_unix.go - Unix socket implementation (macOS/Linux)internal/server/listener_darwin.go - macOS-specific peer credential verificationinternal/server/listener_linux.go - Linux-specific peer credential verificationinternal/server/listener_windows.go - Windows named pipe implementationinternal/server/listener_mux.go - Multiplexing listener combining TCP + socket/pipecmd/mcpproxy-tray/internal/api/dialer.go - Tray client socket dialer with auto-detectioncmd/mcpproxy-tray/internal/api/dialer_unix.go - Unix socket dialer (macOS/Linux)cmd/mcpproxy-tray/internal/api/dialer_windows.go - Named pipe dialer (Windows)cmd/mcpproxy-tray/internal/api/client.go - HTTP client with socket transport (lines 100-118, 318-377)The tray application uses a unified HTTP client that routes all traffic through the socket:
http.Transport with socket-based DialContext functionGET /api/v1/info, POST /api/v1/servers/{name}/enable) use socket transport/events endpoint also uses socket transportevent: status messages with listen_addr field for tray UI updateslisten_addr exclusively from SSE status events (no local fallbacks)Socket/pipe communication is enabled by default. You can disable it using:
# Disable socket communication (clients will use TCP + API key)
./mcpproxy serve --enable-socket=false
# Explicitly enable (default behavior)
./mcpproxy serve --enable-socket=true
{
"listen": "127.0.0.1:8080",
"enable_socket": false,
"mcpServers": [...]
}
If you're running the core server via the tray application (e.g., automatically at startup), and want to disable socket communication:
~/.mcpproxy/mcp_config.json"enable_socket": falseWhen socket communication is disabled, the tray application will fall back to TCP connections using the auto-generated API key.
# Default: Socket auto-created in data directory
./mcpproxy serve
# Disable socket, use TCP only
./mcpproxy serve --enable-socket=false
# Custom socket path
./mcpproxy serve --tray-endpoint=unix:///tmp/custom.sock
# Windows named pipe
mcpproxy.exe serve --tray-endpoint=npipe:////./pipe/mycustompipe
# Verify socket creation
ls -la ~/.mcpproxy/mcpproxy.sock
# Should show: srw------- (socket, user-only permissions)
# Tray automatically connects via socket (no API key needed)
./mcpproxy-tray
internal/server/listener_test.go (13 tests covering TCP, Unix socket, permissions, multiplexing)cmd/mcpproxy-tray/internal/api/dialer_test.go (14 tests covering dialers, auto-detection, URL parsing)internal/server/socket_e2e_test.go (3 scenarios: socket without API key, TCP with/without API key, concurrent requests)