MCP server process leak

Where does the bug appear (feature/product)?

Cursor IDE

Describe the Bug

Cursor does not clean up MCP server child processes when the extension host restarts or a window closes. Over multiple days, dozens of orphaned node and npm exec processes accumulate and leak ~3-5 GB of memory.

Each MCP config entry spawns 2 processes (npm exec wrapper + node server). With 3 entries, that is 6 processes per session. After 3 days: 30+ orphans, ~3-5 GB RSS total.

Steps to Reproduce

  1. Configure MCP servers in .cursor/mcp.json
  2. Use Cursor normally over 2-3 days (open/close windows, restart the IDE)
  3. Run ps aux | grep mongodb-mcp-server and observe processes from previous sessions still alive

Expected Behavior

When the extension host dies or a window closes, all MCP child processes (including npm exec grandchildren) should receive SIGTERM.

Operating System

MacOS

Version Information

IDE 2.4.31

Does this stop you from using Cursor

No - Cursor works, but with this issue

Probably related Exiting the cursor will not kill the mcp process

2 Likes

Hey, thanks for the report. This is a known issue. MCP child processes don’t get cleaned up when you close the window or restart the extension host.

Related reports:

The team is aware. There’s no ETA yet, but your report helps us prioritize, especially the numbers on process buildup and memory impact.

For now, a few workarounds:

  1. Periodically kill orphaned processes manually: pkill -f mongodb-mcp-server (or your server’s process name).
  2. Some MCP server authors added stdin POLLHUP handling. When Cursor exits, stdin closes and the server shuts down on its own. There’s a gist with this approach if you want to apply it to custom servers.

Not ideal, but it should help keep memory usage under control until we fix this properly.

1 Like