docs/cli-client-mode.md
MCPProxy CLI commands automatically detect if a daemon is running and use "client mode" to communicate via Unix sockets (macOS/Linux) or named pipes (Windows). This eliminates database locking issues and provides faster execution.
MCPPROXY_TRAY_ENDPOINT environment variable~/.mcpproxy/mcpproxy.sock (Unix) or \\.\pipe\mcpproxy-<username> (Windows)When a daemon is running:
When no daemon is running:
mcpproxy code execExecute JavaScript code:
# Client mode if daemon running
mcpproxy code exec --code="({ result: input.value * 2 })" --input='{"value": 21}'
# Explicitly use standalone mode
MCPPROXY_TRAY_ENDPOINT="" mcpproxy code exec --code="..." --input='{...}'
mcpproxy call toolCall upstream tools:
# Client mode if daemon running
mcpproxy call tool --tool-name=github:get_user --json-args='{"username":"octocat"}'
mcpproxy tools listList available tools:
# Client mode if daemon running
mcpproxy tools list --server=github
Disable socket detection:
export MCPPROXY_TRAY_ENDPOINT=""
mcpproxy code exec --code="..." --input='{...}'
Use non-default socket location:
export MCPPROXY_TRAY_ENDPOINT="unix:///tmp/custom.sock"
mcpproxy code exec --code="..." --input='{...}'
Check logs for mode detection:
mcpproxy code exec --code="..." --log-level=debug
Look for:
Detected running daemon, using client mode via socketNo daemon detected, using standalone mode┌─────────────────────────────────────────┐
│ CLI Command │
│ (mcpproxy code exec --code="...") │
└──────────────┬──────────────────────────┘
│
┌──────▼──────┐
│ Detect Mode │
└──────┬──────┘
│
┌───────┴───────┐
│ │
┌──▼───┐ ┌───▼────┐
│Socket│ │No Socket│
│Exists│ │ │
└──┬───┘ └───┬────┘
│ │
┌──────▼──────┐ ┌───▼────────────┐
│Client Mode │ │Standalone Mode │
│ │ │ │
│• Socket conn│ │• Open database │
│• HTTP API │ │• Open index │
│• No API key │ │• Open upstreams│
│• Fast │ │• Execute local │
└─────────────┘ └────────────────┘
Socket/pipe connections are secured by:
0600 - owner-only)This is more secure than API keys because the OS guarantees the client and server belong to the same user.
The internal/socket/ package provides:
DetectSocketPath(dataDir string) string - Detects socket endpointIsSocketAvailable(endpoint string) bool - Checks socket existenceCreateDialer(endpoint string) - Creates platform-specific dialerCLI commands use these REST API endpoints when in client mode:
POST /api/v1/code/exec - Code executionPOST /mcp - Tool calls via MCP protocolGET /api/v1/status - Health checksWhen socket connection fails, CLI commands automatically fall back to standalone mode with a warning in debug logs.
Client Mode (Daemon Running):
Standalone Mode (No Daemon):
For repeated operations, client mode is 10-50x faster due to zero initialization overhead.