Skip to content

Stdio MCP child processes are not cleaned up and accumulate indefinitely #16895

Description

@Dovlan1990

What issue are you seeing?

Codex appears to leak stdio-based MCP child processes over time, especially when using @playwright/mcp.

In long-lived sessions, resumed sessions, VS Code app-server sessions, or flows involving subagents, new MCP child processes keep getting spawned, but old ones are not terminated. Over time this leads to dozens or hundreds of stale processes and multiple GB of RAM usage.

This looks like a lifecycle / process-reaping bug in Codex rather than an issue in the MCP server itself.

What steps can reproduce the bug?

I cannot give a perfect deterministic reproduction yet, but this reproduces reliably over normal use:

  1. Configure a stdio MCP server such as @playwright/mcp
  2. Start Codex in CLI or via the VS Code extension
  3. Use MCP-backed tools repeatedly over time
  4. Resume sessions and/or use subagents
  5. Inspect processes with ps

What is the expected behavior?

  • MCP child processes should be reused where possible, or
  • terminated reliably when their owning session / subagent / app-server no longer needs them
  • idle MCP servers should not live forever
  • ending a session should clean up the entire MCP subprocess tree

Additional information

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    agentIssues related to the core agent loopbugSomething isn't workingmcpIssues related to the use of model context protocol (MCP) servers

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions