Find and kill orphaned MCP servers on a Mac
An MCP server is a helper process that Claude Code, Cursor or Codex starts for each session. When the session ends cleanly, the server exits too. When the session crashes, the terminal is closed, or the app is force-quit, the server can keep running with nothing using it. These are orphans. They hold memory, and some spin the CPU.
What PPID 1 means
Every process has a parent process ID (PPID). When a parent exits, macOS hands its children to launchd, which is always process 1. So an MCP server whose PPID is 1 lost the session that started it.
List them
This prints MCP processes whose parent is PID 1, with memory in MB and how long they have been running. It only lists; it kills nothing:
ps -axo pid,ppid,rss,etime,command | awk '$2==1 && tolower($0) ~ /mcp/ && !/awk/ {printf "%s %d MB %s %s\n", $1, $3/1024, $4, $5}'
The columns are PID, memory, running time (days-hours:minutes:seconds), and the program that runs it (often node or npx). To see which server it is, run ps -o command= -p PID on one PID: the full command line names it.
To see the whole picture, including servers that still have a parent:
ps -axo pid,ppid,etime,command | awk 'tolower($0) ~ /mcp/ && !/awk/'
Stop them
Stop one at a time, or a short list you have read:
kill 12345 12346
This sends SIGTERM, which asks the process to shut down cleanly. Wait ten seconds and list again. Only if one is still there:
kill -9 12345
If you know a particular server is the problem, you can stop its orphans by name. Look first, then kill, and only those with PPID 1:
ps -axo pid,ppid,command | awk '$2==1 && /mcp-server-cloudflare/ && !/awk/ {print $1}'
kill $(ps -axo pid,ppid,command | awk '$2==1 && /mcp-server-cloudflare/ && !/awk/ {print $1}')
Replace mcp-server-cloudflare with the name you saw. If the list is empty, the second command prints a usage message and does nothing.
The risks
- Not everything with PPID 1 is dead. Login items, background services, and anything you started with
nohupor as a launchd job also have PPID 1 on purpose. A scheduledclaude -pjob or an MCP server you run as a service is not an orphan. Killing it stops that work. Read the command line and the running time before you kill. - Plain
pkill -f mcpis too broad. It matches every process with "mcp" anywhere in its command line, including the servers of the session you are using right now. A live session loses its tools until you restart it. - Don't kill by program name.
pkill nodeends everything running on Node, not only MCP servers. - This check misses one kind of leftover. A server whose parent is an agent that is itself orphaned still has a parent that is not PID 1. To check a parent, run
ps -o pid,ppid,etime,command -p PARENT_PID. If that parent's own PPID is 1 and you have no window for it, it is abandoned too. - SIGKILL skips cleanup. A server that was writing a file or holding a lock can leave it half done. Use plain
killfirst. - Servers that wrap a browser or database. Stopping the server may leave the browser or database it launched running. Check the list again afterwards.
Orphans come back whenever sessions end badly, so this is a recurring chore, not a one-time fix.
Let the Mac do it
The free Mac YOLO Safeguards menu bar app finds MCP servers and helpers that outlived their session and stops them when you click. It ends processes, so read what it can end before you click.
Pro Guard, $29 once, checks once a minute while the app is open, and acts without a click when memory runs short. Full refund within 30 days.
There are also free open-source command line tools that do this. Here is an honest comparison.