15 Profiles, One Gateway: Every MCP Server Got Started 15 Times

You run one gateway for a dozen profiles: one writes code, one researches, one runs cron, a few are wired to different chat platforms. It works well — until the desktop app starts reporting request timed out after 30s: session.resume, the log keeps saying Gateway event loop missed 3 consecutive liveness probes … exiting with code 75, and curl /health takes half a minute. You blame the network, restart, and a few hours later it happens again.
One user measured this properly, and the answer is not the network: 400 threads in one gateway process, with the event loop spending 69% of its time waiting for Python’s GIL.
The symptoms, laid out
On a macOS host running 15 profiles behind the default multiplexed gateway (one process serving every profile), they sampled the process with sample <pid> for 6–8 seconds and counted take_gil frames per thread:
| Metric | Steady state (before) | Steady state (after mitigation) | During startup |
|---|---|---|---|
| Gateway threads | 399–401 | 400 | 152 |
Event-loop thread waiting in take_gil |
69% | 76% | 84% |
Event-loop thread idle in kevent |
0% | 2% | 15% |
Same period: the liveness watchdog exited with code 75 eight times in about ten hours; ws write slow (loop stalled >10.0s) was logged 224 times; desktop session.resume hit its 30-second timeout; one GET /health got no response for 30 seconds while the loop was stalled.
Note the “76% after”. The mitigation cut the trigger rate; it did not change the structure — the loop is still competing for the GIL.
The real culprit: MCP servers started once per profile
The thread breakdown says a lot: 90 mcp-stderr threads, 44–45 AnyIO workers, 30 tokio-rt-worker, and 15 hosted-room-driver-supervisor threads (one per profile).
MCP is the important part. A stdio MCP server is a child process, started by the agent that uses it. In a multiplexed gateway each profile is an independent runtime: it reads its own config.yaml and connects to its own MCP servers. If 15 profiles list the same stdio MCP servers, you get 15 child processes per server — not one shared connection.
One of the servers in that setup (peekaboo mcp) watches app launch and quit notifications and used roughly half a core per copy. Fifteen copies is about 7.5 cores — while the gateway itself only wants about 1.7.
Disabling it (enabled: false) moved /health from a 0.77-second median to 0.26 seconds and stopped the loop stalled lines. The GIL was not the disease; it was the symptom of fifteen vacuum cleaners running in the hallway.
Why one GIL stalls every profile
Python threads share a single global interpreter lock. A multiplexed gateway runs all profiles in one process, so the event-loop thread takes turns with hundreds of worker threads for that lock.
Normally this is fine: workers spend most of their time waiting on IO, and the lock sits free. But when 15 MCP child processes each have stderr readers and 45 AnyIO workers are active, the lock changes hands constantly — and whenever the current holder gets descheduled by the OS, every thread in the process waits, including the one that answers health checks, forwards messages and handles session.resume.
The watchdog then does exactly what it was built to do: three consecutive probe timeouts (default 30-second interval, 10-second timeout) and it exits with code 75 so the supervisor restarts the gateway. That is where the “random restarts” come from — not a crash, a deliberate restart.
How to check whether this is you
1. Compare the MCP lists per profile. Each profile has its own config under ~/.hermes/profiles/<name>/config.yaml. The CLI is quicker (HERMES_PROFILE selects the profile; hermes profile list gives you the names):
HERMES_PROFILE=<name> hermes mcp list
Run it for each profile and compare the mcp_servers names. The same stdio server showing up in several profiles means several copies of the process.
2. Count the threads. Find the gateway PID (hermes gateway status reports it), then list threads by name (macOS ps -M, Linux ps -L):
ps -L <pid> | awk '{print $NF}' | sort | uniq -c | sort -rn | head
The number of mcp-stderr threads is roughly the number of live stdio MCP connections. Fifteen profiles with three servers each is 45.
3. Look at the gateway’s own view. hermes gateway status --deep shows more state; if the log repeats loop stalled or exiting with code 75, stop guessing about network flakiness.
How to take the load off
Disable duplicated MCP servers per profile. Setting enabled: false on an mcp_servers entry makes Hermes skip it entirely — it does not even attempt a connection. The docs also note that a running gateway watches config.yaml: within about a minute of setting enabled: false (or removing the entry) that server’s connection is torn down, with no restart and no /reload-mcp needed.
Only give a profile the servers it needs. A profile that handles email rarely needs browser control. Aligning the tool surface with the profile saves resources and shrinks the attack surface.
Give the watchdog room, but do not disable it. Defaults are a 30-second probe interval, a 10-second timeout and three strikes. For occasional restart churn, raising gateway.loop_watchdog_max_strikes from 3 to 6 is the cheap stopgap:
gateway:
loop_watchdog_max_strikes: 6
That is a bandage, not a cure. Turning the watchdog off entirely (gateway.loop_watchdog: false) is worse: you remove the only recovery path for a genuinely stuck loop.
Profile count is itself a cost. Fifteen profiles means fifteen sets of resident scheduling, connections and watchers. Merging the rarely used ones — or starting them on demand — usually beats any parameter tuning.
Where things stand
The issue is still open. The reporter’s mitigations are “remove the duplicated MCP servers and tune the watchdog”, not a root fix. Community members also proposed launching the gateway via launchd as ProcessType=Interactive (the default is daemon, which lands it at priority 20 so any foreground app outranks it) and splitting the process-wide session.resume lock per profile. Those are proposals, not merged changes. The fix may change shape; the cost model — multiplexing plus one stdio MCP child per profile — will not.
People run many profiles for isolation: different platforms, projects, permissions. Isolation is right. Just price it honestly, especially for stdio servers you copied into every profile “for convenience”.
Related: gateway commands, MCP commands, loop watchdog tuning, and running multiple profiles.