Daemon Mode
Daemon mode keeps MCP servers alive between calls. Instead of spawning a new process for every command, mcpx connects to a running server via unix socket.
When to Use It
Use daemon mode for servers that:
- Have slow startup (LSP initialization, loading indexes)
- Are called frequently in a session
- Maintain state between calls
Don't bother for servers that start instantly and are called rarely.
Enabling Daemon Mode
Set daemon: true in your server config:
yaml
servers:
serena:
command: uvx
args: [...]
daemon: truemcpx automatically starts the daemon on first use and connects via socket on subsequent calls.
How It Works
- First call to
mcpx serena <tool>: spawns a detached daemon process - Daemon starts the MCP server, performs the handshake, listens on a unix socket
mcpxconnects to the socket, sends the request, gets the response- CLI exits. Daemon stays alive.
- Next call: connects to existing socket — zero startup cost
mcpx CLI ──► unix socket ──► daemon process ──► MCP server subprocess
(stays alive) (stays alive)Socket Location
/tmp/mcpx-<server>-<uid>.sock # unix socket (mode 0600)
/tmp/mcpx-<server>-<uid>.pid # PID file
/tmp/mcpx-<server>-<uid>.log # daemon logManaging Daemons
Check status
bash
mcpx daemon status
# serena running /tmp/mcpx-serena-501.sockStop a daemon
bash
mcpx daemon stop serena
# Stopped daemon for serenaStop all daemons
bash
mcpx daemon stop-allHealth check
bash
mcpx ping serena
# serena: ok (21 tools, 47ms)Idle Timeout
Daemons shut down after 30 minutes of inactivity by default. Every request resets the timer.
Crash Recovery
If the MCP server subprocess crashes while the daemon is running:
- The daemon detects the transport death (stdout pipe closes)
- Active connections receive an error response
- The daemon shuts down and cleans up its socket and PID file
- The next
mcpxcall starts a fresh daemon automatically
This prevents "zombie daemons" — processes that accept connections but fail every request.
Logs
Daemon logs are written to /tmp/mcpx-<server>-<uid>.log:
bash
cat /tmp/mcpx-serena-$(id -u).logdaemon: serena listening on /tmp/mcpx-serena-501.sock (pid 12345, idle timeout 30m0s)
daemon: serena idle for 30m0s, shutting down
daemon: serena exitedTroubleshooting
See Daemon Issues for common problems.