MCP servers started for Codex subagents remain running after the subagent completes and close_agent succeeds
What version of Codex CLI is running?
codex --v0.122.0
What subscription do you have?
pro
Which model were you using?
_No response_
What platform is your computer?
macOS
What terminal emulator and version are you using (if applicable)?
_No response_
What issue are you seeing?
In Codex multi-agent mode, MCP server processes started for a subagent appear to remain alive after the subagent has completed and close_agent has successfully returned.
Observed behavior:
A subagent is spawned and initializes configured MCP servers, such as chrome-devtools-mcp, @playwright/mcp, tavily-mcp, etc.
The subagent finishes its task.
close_agent is called and returns a completed status.
The MCP server processes started around the subagent launch time are still running in the background.
These processes remain children of the parent Codex process rather than being cleaned up with the closed subagent.
This causes MCP processes to accumulate when multiple subagents are spawned concurrently. Over time, this can lead to unnecessary memory and process usage, browser/tooling contention, and confusing background state until the parent Codex process exits or the MCP processes are manually terminated.
What steps can reproduce the bug?
After a subagent is closed, its associated MCP servers and related configured resources should not remain as background residual processes.
What is the expected behavior?
When a subagent completes and is closed, any MCP servers or related resources that were started specifically for that subagent should be terminated or released, unless they are still actively shared by another live thread.
Additional information
_No response_
This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗