codex - 💡(How to fix) Fix Codex desktop leaks orphaned MCP helper processes under launchd [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openai/codex#21008Fetched 2026-05-05 05:54:36
View on GitHub
Comments
1
Participants
2
Timeline
5
Reactions
0
Timeline (top)
labeled ×4commented ×1

Codex Desktop appears to repeatedly leak MCP helper processes. Over time, they become re-parented to launchd (PPID 1) and continue consuming CPU/RAM after the Codex session/tool invocation that created them is gone.

This has happened repeatedly on my machine. In the latest cleanup, I found and removed 501 stale MCP-related processes.

Root Cause

There were also two STAT=Z defunct processes, but they were not the material resource problem because both had 0% CPU and 0 RSS.

Code Example

target_count=501
total count=501 cpu=190.3 rss_mb=4013.5
php count=252 cpu=190.3 rss_mb=1660.3
node count=249 cpu=0.0 rss_mb=2353.2

---

remaining_target_count=0
total count=0 cpu=0.0 rss_mb=0.0

---

ps -axo pid,ppid,stat,%cpu,%mem,rss,etime,comm,args \
  | awk 'NR>1 && $2==1 && /mcp-server-trello|herd-mcp\.phar|chrome-devtools-mcp|playwright-mcp|watchdog\/main\.js/'

---

ps -axo pid,ppid,stat,%cpu,%mem,rss,etime,comm,args > /tmp/codex_ps_before_cleanup.txt
awk 'NR>1 && $2==1 && /mcp-server-trello|herd-mcp\.phar|chrome-devtools-mcp|playwright-mcp|watchdog\/main\.js/ { print $1 }' /tmp/codex_ps_before_cleanup.txt > /tmp/codex_stale_mcp_pids.txt
xargs kill < /tmp/codex_stale_mcp_pids.txt
RAW_BUFFERClick to expand / collapse

Summary

Codex Desktop appears to repeatedly leak MCP helper processes. Over time, they become re-parented to launchd (PPID 1) and continue consuming CPU/RAM after the Codex session/tool invocation that created them is gone.

This has happened repeatedly on my machine. In the latest cleanup, I found and removed 501 stale MCP-related processes.

Environment

  • App: Codex Desktop
  • Codex app version: 26.429.30905 (CFBundleVersion 2345)
  • Bundle id: com.openai.codex
  • macOS: 26.3.1 (a) build 25D771280a
  • Architecture: arm64

What I observed

A host-level process snapshot showed hundreds of stale MCP helpers with PPID 1, mostly:

  • php /Applications/Herd.app/Contents/Resources/herd-mcp.phar
  • node /private/tmp/bunx-501-@delorenj/mcp-server-trello@latest/node_modules/.bin/mcp-server-trello

Before cleanup:

target_count=501
total count=501 cpu=190.3 rss_mb=4013.5
php count=252 cpu=190.3 rss_mb=1660.3
node count=249 cpu=0.0 rss_mb=2353.2

After killing only MCP-related processes with PPID 1:

remaining_target_count=0
total count=0 cpu=0.0 rss_mb=0.0

There were also two STAT=Z defunct processes, but they were not the material resource problem because both had 0% CPU and 0 RSS.

Why this looks like a Codex leak

The live Codex app had active helpers under the current Codex process tree, which I left alone. The stale processes were specifically the MCP helpers re-parented to launchd with PPID 1, which suggests their original parent exited without terminating/reaping them.

This matches a recurring pattern I have seen where many Codex/MCP helper processes accumulate across sessions/tool invocations.

Expected behavior

When a Codex session, tool server, or MCP client process exits, Codex should terminate/reap any MCP helper process it spawned, or otherwise ensure those child processes do not become long-lived orphaned PPID 1 processes.

Actual behavior

MCP helper processes can accumulate under launchd and persist for hours/days, consuming significant CPU and RAM.

Detection command used

ps -axo pid,ppid,stat,%cpu,%mem,rss,etime,comm,args \
  | awk 'NR>1 && $2==1 && /mcp-server-trello|herd-mcp\.phar|chrome-devtools-mcp|playwright-mcp|watchdog\/main\.js/'

Cleanup command used

ps -axo pid,ppid,stat,%cpu,%mem,rss,etime,comm,args > /tmp/codex_ps_before_cleanup.txt
awk 'NR>1 && $2==1 && /mcp-server-trello|herd-mcp\.phar|chrome-devtools-mcp|playwright-mcp|watchdog\/main\.js/ { print $1 }' /tmp/codex_ps_before_cleanup.txt > /tmp/codex_stale_mcp_pids.txt
xargs kill < /tmp/codex_stale_mcp_pids.txt

I intentionally scoped cleanup to MCP-related commands with PPID 1 so live Codex-attached helper processes were not killed.

extent analysis

TL;DR

The most likely fix is to modify the Codex Desktop application to properly terminate and reap its MCP helper processes when the parent process exits.

Guidance

  • Investigate the Codex Desktop application's process management code to ensure it correctly handles the termination of MCP helper processes.
  • Verify that the application is using the correct system calls to wait for and reap child processes, such as waitpid or wait.
  • Consider implementing a mechanism to periodically clean up orphaned MCP helper processes, such as a cron job or a background task.
  • Review the application's logging and monitoring to detect and alert on cases where MCP helper processes are not being properly terminated.

Example

No code snippet is provided as the issue does not contain sufficient information about the application's codebase.

Notes

The provided information suggests that the issue is specific to the Codex Desktop application and its handling of MCP helper processes. The detection and cleanup commands provided can be used to identify and terminate orphaned processes, but a more permanent fix will require modifications to the application itself.

Recommendation

Apply a workaround by implementing a periodic cleanup mechanism to terminate orphaned MCP helper processes, as the root cause of the issue appears to be related to the application's process management.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

When a Codex session, tool server, or MCP client process exits, Codex should terminate/reap any MCP helper process it spawned, or otherwise ensure those child processes do not become long-lived orphaned PPID 1 processes.

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

codex - 💡(How to fix) Fix Codex desktop leaks orphaned MCP helper processes under launchd [1 comments, 2 participants]