fix: stdio MCP child process leak causing unbounded memory growth
What version of the Codex App are you using (From “About Codex” dialog)?
26.416.11627
What subscription do you have?
Plus
What platform is your computer?
Linux 6.19.10-300.fc44.x86_64 x86_64 unknown
What issue are you seeing?
Long-running Codex sessions using stdio MCP servers leak child processes.
Observed behavior:
stdio MCP servers are repeatedly spawned during normal usage
previous MCP child processes are not cleaned up
process count continuously increases over time
no automatic cleanup occurs
restarting/killing Codex reaps the processes
This behavior is consistent with previously reported MCP lifecycle leaks in Codex (CLI, Desktop, and extensions), where stdio MCP processes accumulate instead of being reaped.
What steps can reproduce the bug?
Configure one or more stdio MCP servers (e.g. Playwright, Git MCP, etc.)
Start Codex Desktop
Open and switch between chats repeatedly
Monitor process count:
watch -n 2 -t 'date +"%T"; pgrep -fc "mcp|playwright|chrome-devtools|codex"'
Observe:
process count increases continuously
no decrease occurs over time
What is the expected behavior?
stdio MCP child processes should be cleaned up after session/tool lifecycle ends
process count should remain bounded
memory usage should remain stable
Actual behavior
MCP child processes accumulate indefinitely
process count increases with continued usage
no cleanup occurs until Codex is terminated
Additional information
Evidence
Process tree shows multiple duplicated MCP server processes under the same Codex app-server
Repeated instances of:
@playwright/mcp
git-mcp-server
shadcn mcp
context7 MCP
next-devtools MCP
Video evidence attached:
Shows real-time process count increasing while opening chats
Timestamp included
Sensitive content redacted
This appears related to existing MCP lifecycle issues where processes are spawned but not reaped
Behavior matches prior reports of unbounded MCP process growth and memory usage
Known issue affecting codex-cli 0.120.0 and related builds ()
Code credit:
commit 498aac674cc2bf29f12185b1344e89b006f4a64d (@RedesignedRobot)
Co-authored with @codex
https://github.com/user-attachments/assets/956fb226-9bad-4414-8027-e9b3fd60827a
5 Comments
Potential duplicates detected. Please review them and close your issue if it is a duplicate.
Powered by Codex Action
This is not a duplicate, this is a dedicated issue for the patch
I can confirm a very similar pattern on Windows with the VS Code Codex extension/app-server.
Environment:
codex.exe app-server@modelcontextprotocol/server-filesystem,xcodebuildmcpObserved behavior:
codex.exe app-server.xcodebuildmcpeach reached 2-3 parallel root processes.xcodebuildmcproot also appeared.Example process roots under the same
codex.exe app-server:uvx.exe 25344,uvx.exe 25788, lateruvx.exe 28980cmd.exe 24664,cmd.exe 25724,cmd.exe 28972xcodebuildmcp:cmd.exe 24868,cmd.exe 25756,cmd.exe 28964After explicitly stopping the younger full process branches, the state returned to one root per stdio MCP:
uvx.exe 25344cmd.exe 24664xcodebuildmcp:cmd.exe 24868This matches the issue description: stdio MCP child processes appear to accumulate under the app-server lifecycle instead of being consistently reaped. The local workaround was full-branch cleanup plus re-check, but the durable fix likely belongs in the Codex app-server / stdio MCP lifecycle handling.
If any developers are seeing this, please build this new change and test if it fixes it. My platform isn't supported. Thanks.
Windows reproduction with @lottiefiles/creator-mcp 0.1.3
I reproduced a closely related stdio MCP lifecycle failure in Codex Desktop on Windows.
Environment:
Reproduction:
npx -y @lottiefiles/creator-mcp@latest
Observed:
Expected:
This looks related to the existing stdio MCP process lifecycle defect, but adds a native Windows reproduction where duplicated server chains also prevent a stateful browser-bridge MCP from completing a write operation.