My Mac kept freezing while I ran coding agents
It has 24 GB of RAM. Swap sat at 38.7 GB out of 39.9
Nothing heavy was open. Just a few agent sessions, or so I thought
TL;DR
- Each agent session starts its own copy of every MCP server in its global config
- Desktop agent apps keep old sessions alive for days, and their MCP servers stay up with them
- My Mac had 94 sessions holding 555 MCP server processes
- Moving servers into project configs and closing old sessions fixes most of it
-
prismor discover mcp --prune --stopended 373 copies in 6 seconds and gave me back 21 GB of swap
1. What was running
My cleanup script flagged 287 processes. Most were two lines repeated about a hundred times each:
npm exec get-an-expert-agent@latest
npm exec @microsoft/clarity-mcp-server
Both are MCP servers. I had started neither by hand
So I walked each process up to its parent and counted:
- 94 agent sessions still alive, holding 3.9 GB
- 105 copies of colab-mcp at 1.5 GB
- 178 processes for get-an-expert at 508 MB
- 178 processes for clarity at 492 MB
- 94 copies of termmirror at 252 MB
That makes 555 MCP server processes, about a third of everything running on my machine
Those memory numbers sit on the low side. Most of these processes had idled for days, so macOS had pushed them into swap. And ps leaves swap out
2. My first guess was wrong
I blamed npx. It wraps each server in npm exec, and I assumed that wrapper swallowed the shutdown signal and left orphans behind
So I tested it. My script started a stand-in session and launched a server over stdio. Then it killed that session with SIGKILL to fake a crash
[direct] session owns 2 processes:
npm exec get-an-expert-agent@latest
node .../get-an-expert-agent
[direct] 5s after the session is killed: 0 still running
Both exited. Once a session dies, its server's stdin closes and any stdio server shuts down
Then I checked parents. All 555 servers had a live agent process above them. Those sessions were open and idle
3. Real cause
Three things stack up
One copy per session. Each stdio MCP server runs as a child of whichever session launched it. Ten sessions means ten copies of every server
Global config. I had four servers in the top-level mcpServers of ~/.claude.json. So every session in every project started all four. Most of those sessions made zero calls to Clarity or Colab
Sessions that stay open. Claude's desktop app keeps each sidebar session running, MCP children included. 78 of my 94 sessions were over a day old, and my oldest had run for 156 hours
And npx doubles the bill. Each npx server is two processes, and its wrapper eats about as much memory as the server itself
Check: count MCP processes by parent
ps -axo pid,ppid,etime,command | grep -E 'npm exec|mcp' | grep -v grep | awk '{print $2}' | sort | uniq -c | sort -rn | head
Red flag: those parent PIDs repeat over and over, and each one belongs to an agent
4. Fixes that work today
- Move servers out of global config and into each project's .mcp.json. Biggest win by far
- Close sessions once they're done. /exit in the CLI, or close them in the desktop app
- Install npx servers once with
npm i -g <package>and point config at that binary. Half as many processes
5. What I added to Prismor
Prismor already sees each tool call my agents make, so it knows which MCP servers get used. I built three things on top of that
See it. prismor discover mcp now lists each server with its running copies, their memory and how many sessions called it in the last 7 days
On my Mac one screen showed it all. Three servers ran about 90 copies each, with zero calls all week. Prismor flags those
Clean it up.
prismor discover mcp --prune --stop
- --prune saves a backup, then drops flagged servers from global config. New sessions stop starting them
- --stop ends copies running right now. Open sessions keep going and lose those servers' tools, which costs nothing when nobody calls them
Both commands show their plan and ask before acting
Stop idle servers I keep.
Some servers I do call now and then. Prismor's MCP gateway can stop those after a quiet period (--idle-timeout). Agents still see their tools, and my next call starts the server again in about a quarter of a second
I leave it off for servers that hold state between calls, like one keeping a browser open
6. Does it work?
I tested each fix in an isolated rig: 10 stand-in sessions with 4 real MCP servers each, 3 of them never called
- Baseline: 40 processes, 1,484 MB
- After --prune: 10 processes, 401 MB (−73%)
- After --stop: 10 processes, 401 MB, with all sessions still running
- Gateway with idle stop: 10 processes, 145 MB (−90%)
Then I ran it on my own Mac. 373 copies ended in 6 seconds
Swap dropped from 38.3 GB to 17.2 GB, and every open session kept running
Limits
- Usage counts cover Claude Code today. Other agents show copies and memory without usage
- ps leaves out swapped memory, so on a busy machine real savings run higher than what Prismor reports
Try it
pip install prismor
prismor discover mcp
Prismor is open source: https://github.com/PrismorSec/prismor






Top comments (15)
The parent-PID count is a great diagnostic, and I like that you actually tested the npx-orphan theory instead of assuming it. That's the explanation everyone reaches for first.
One small addition to the fixes: if a project config still needs an npx server, pin the version (package@1.2.3 instead of @latest). With @latest, each new session can check the registry on startup, which adds launch latency and can quietly leave different sessions on different versions. A global install solves both, but pinning is the lighter change when the .mcp.json is shared with a team.
Curious whether the 7-day call counts surprised you. Did any server that lived in a project config also turn out to be unused?
Good point on pinning. For a shared .mcp.json that's the lighter fix, and I'll add it to the list. The 7-day counts did surprise me: rarely-used servers were still starting in every session, 369 copies and about 2.4 GB on my machine. Per-project usage is the next thing I want to measure.
369 copies is wild. For the per-project numbers, logging the working directory on each tool call and counting by server per project over a week should show pretty fast which ones can move out of the global config.
That's a clean way to get the per-project split. Right now the 7-day counts are per server across sessions, so logging cwd per call would be the missing piece for moving servers into project configs with confidence. I'll try it on a week of real usage.
Sounds like a good plan. A week of real usage should make the split pretty obvious. Would be curious which servers end up project-only once you have the numbers.
Will share the split once the week is up. My bet is most of them turn out project-only, and the global list ends up a lot shorter than the install history suggests.
Makes sense. Install history overcounts since every tutorial adds a server once and nobody removes it. Curious whether the project-only ones cluster by repo type too. Looking forward to the numbers.
Good call on the repo-type clustering, I will slice it that way when I post the numbers. My guess is tool-heavy repos (data work, infra) keep more project-only servers than plain web apps, but the week will say for sure.
Makes sense, tool-heavy repos probably carry more one-off servers. Looking forward to the numbers, especially if any global ones turn out idle everywhere.
Global servers idle everywhere would be most interesting slice. Those are safest candidates to drop from default configs. Will watch for numbers.
Agreed, the ones that sit idle globally are the easy wins to drop from default configs. Looking forward to the numbers.
Same here. Global idle ones look like low-hanging fruit for default config cleanup. Will share numbers once slice is done.
Sounds good, curious what the slice shows. Even a rough before/after on idle process count and RAM would help others hitting the same freezes.
Fair ask. Idle process count and RAM before and after pruning would be the useful numbers.
Exactly those two. Thanks for the back-and-forth on this one.