Topic clusters

Claude Code left MCP servers running: how to find and stop them

Each AI coding session can start its own copy of every MCP server, and some keep running after the session ends. This guide shows how to list them, tell orphans from live ones, and stop only the right processes.

An MCP server is a helper program an AI tool starts to reach a file system, a database, a browser or an API. Many run locally, as ordinary processes on your Mac. A coding tool such as Claude Code, Cursor or Codex may start its own copy of every configured server for each session, so five open sessions with six servers each is thirty processes. When a session ends cleanly they exit. When a terminal is closed abruptly or an app crashes, some keep running with nothing talking to them.

Each leftover server is small, often 30 to 100 MB, but they pile up over days. This guide finds them without printing anything sensitive, which matters because MCP servers are often started with database addresses and API keys on their command line.

A warning before you list processes

The usual advice is ps aux | grep mcp. Do not paste that output into a chat, an issue or a screenshot. MCP servers are commonly launched with connection strings and tokens as arguments, and ps prints them in full. The commands below print process names, sizes and ages only. If you need the full command for one process, read it on your own screen and do not share it.

Step 1: Count what is running

This counts processes whose command mentions MCP, grouped by the program that runs them. It prints only the program name.

If the count is far larger than the number of sessions you have open, you have leftovers. In our own snapshot of a working developer Mac, the count was well over fifty.

Count MCP-related processes by program name (no arguments printed)
ps -axo command= | grep -i -E "mcp-server|mcp-remote|[/ _-]mcp[/ _.-]" | grep -v grep | awk '{n=split($1,s,"/"); print s[n]}' | sort | uniq -c | sort -rn

Most entries will be node or npm, because most MCP servers are Node programs. npm lines are usually a wrapper around the real node process, so they are counted twice.

Step 2: Tell orphans from servers in use

A server that is still wanted has a living parent: the AI tool that started it. When that parent exits, macOS reassigns the process to launchd, which has process ID 1. A Node process whose parent is 1 and which has been running for hours is an orphan.

Not every orphan is junk. A server you started yourself with a launcher script also has parent 1. Use the age and the project it was started in to decide.

Node processes with no parent (parent 1): pid, memory in KB, age
ps -axo pid=,ppid=,rss=,etime=,comm= | awk '$2==1 && $5 ~ /node$/'
Which project folder a process was started in (replace 1234 with the pid)
lsof -a -p 1234 -d cwd | tail -1

The last column is the working folder. A folder for a project you closed yesterday is a good sign the server is a leftover.

Step 3: Stop only what you have identified

Ask a process to quit, rather than forcing it. A plain kill sends a termination request that lets the program clean up. Reach for kill -9 only if it ignores the request, and never run killall node, which also stops your dev servers and your editor's language servers.

Ask one process to quit (replace 1234 with the pid you identified)
kill 1234

Run the Step 2 command again afterwards to confirm it is gone. If an AI session is still using it, the tool starts a new copy on demand, so stopping a live server costs a short delay and nothing else.

Stopping the pile-up at the source

Quit AI sessions you are not using, instead of leaving terminals open overnight. Remove MCP servers from your tool's configuration that you do not use every day; each configured server is started again for every session. Prefer closing a session with its own exit command over closing the terminal window, because a clean exit lets the tool stop its servers.

If you want to see how this plays out in practice, our memory snapshot counted the MCP-related processes on a real developer Mac, and the free check script reports the same count for yours.

When to let an app do it

Sentinely finds MCP servers whose editor or terminal has closed, groups them by what started them, shows what it will stop, and re-checks that each process is still the one it found before it acts. For duplicates, the newest copy of each server keeps running. It redacts command lines on your Mac, so secrets are never shown or stored. The check, warnings and your first fix are free.

Questions

Does Claude Code leave MCP servers running after I quit?

Usually it stops them when the session ends cleanly. If the terminal is closed abruptly, the machine sleeps mid-session or the app crashes, some servers keep running with no parent. They appear as Node processes whose parent process ID is 1.

How do I list MCP servers running on my Mac?

Count them with ps -axo command= | grep -i mcp-server, but do not share the output: command lines can contain database passwords and API keys. The commands in this guide print only process names, sizes and ages.

Is it safe to kill an MCP server process?

Yes, if you ask it to quit with a plain kill and you have identified the right process. An AI tool that still wants the server starts it again on demand. Do not use killall node, which also stops dev servers and language servers.

How much memory do leftover MCP servers use?

Each is typically tens of megabytes, so a handful is negligible. The cost shows up when dozens accumulate over several days, or when a leftover server has itself grown. Check memory pressure before spending time on it.