Stop spawning an MCP server per agent session (and what it won't fix)
Ten parallel Claude sessions. Ten copies of the same MCP server. Ten processes, ten sockets to the same upstream, ten holders of the same lock — because that is what stdio means. I moved every server to one shared daemon per machine bound to 127.0.0.1 , and the fleet stopped fighting itself. TL;DR: an MCP server registered as stdio is spawned per client session. Register it as an HTTP/SSE URL…
A single MCP server shared across all agent sessions can reduce memory usage, sockets, and locks, but it does not save tokens. The shared server is bound to 127.0.0.1 and accessible via an HTTP/SSE URL. A watchdog should not be used, as restarting the daemon would cause all live sessions to fail. The measuring script python scripts/mcp_diet_measure.py reveals the actual impact.
Three bugs in the measurement tool were fixed before release. Shared infrastructure should use a self-healing script that acts on a single probe, not a naive watchdog. This approach is suitable for machines with single or multiple agent sessions, but not for servers with per-session state. The autostart and watchdog should be maintained for resilience. The recipe is MIT licensed and agnostic to integration, available at tonydzi / mcp-daemon-diet.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.