Skip to content

fix: stdio MCP child process leak causing unbounded memory growth #19469

@luohoa97

Description

@luohoa97

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 498aac6 (@RedesignedRobot)
Co-authored with @codex

bug.mp4

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingmcpIssues related to the use of model context protocol (MCP) servers

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions