Repository navigation
Description
Component
Codex desktop app / MCP server lifecycle
What happened?
I noticed that the Codex app appears to start separate MCP server instances for different conversations, even when they are the same MCP servers with the same configuration.
Over time, these processes accumulate and duplicate each other.
On my home PC, I recently saw 14 instances each of four MCP servers, around 56 processes total.
I also checked my MacBook and saw a similar pattern:
- multiple
serenaMCP server processes; - multiple
context7wrapper/server processes; - multiple
node_replprocesses; - multiple
codex app-server --listen stdio://processes.
The processes appeared to accumulate in batches as I worked with different sessions/conversations.
Expected behavior
If several conversations use the same MCP servers with the same configuration, Codex should ideally reuse a shared MCP runtime/server instance, or clean up inactive instances when the conversation that owns them is no longer active.
At minimum, old inactive MCP server processes should not accumulate indefinitely during long-running app usage.
Actual behavior
Repeated MCP server instances can remain running at the same time.
This creates extra memory/process overhead. It is not always immediately critical, but after long-running work it can become significant.
Why this matters
Many Codex users configure multiple MCP servers. If every active or previously opened conversation starts its own duplicate set, the number of background processes can grow quickly.
For example, 14 copies of 4 MCP servers becomes 56 processes. Even if each process is modest, the combined memory/process overhead adds up and can make the app feel heavier over time.
Possible direction
Potential approaches:
- shared MCP runtime across conversations when the server command/configuration is identical;
- reference-counted MCP process lifecycle;
- more aggressive cleanup of MCP servers attached to inactive/closed conversations;
- diagnostics in the app showing which MCP processes are running and which conversation owns them.
Related issues / discussion
Related broader discussion:
#22987
Related large-session performance issue:
#22991
Environment
Observed on:
- Windows home PC, where I saw around 56 MCP-related processes in one case;
- macOS MacBook, where I saw repeated
serena,context7,node_repl, andcodex app-server --listen stdio://processes.
I can provide exact OS/app versions and process-list snippets if helpful.
Activity
github-actions commentedon May 16, 2026
Potential duplicates detected. Please review them and close your issue if it is a duplicate.
Powered by Codex Action
Deniskoyyy commentedon May 16, 2026
Adding a small Windows tray screenshot related to the MCP duplication symptom.
Related Community thread:
https://community.openai.com/t/feedback-from-a-remote-codex-helper-prototype-long-session-performance-durable-queue-and-mcp-process-reuse/1381062
In this screenshot, several Serena instances are visible at the same time. This matches the duplicated MCP/server process accumulation pattern I described above.
This screenshot is only a visual symptom, not a full process-list proof. I can follow up with Task Manager / Activity Monitor or process-list output if useful.
TyceHerrman commentedon Oct 19, 2026
Additional macOS evidence from Desktop 26.1013.40934, bundled CLI 0.163.0-alpha.10.2.
During a slowdown on October 19, a process capture showed 128 Node-related tool workers under the main Codex backend: 50 Node REPL workers, 38
server.mjsworkers, 20 CUA REPL launchers, and 20 Codex Security MCP workers.Their summed physical footprint was approximately 3.6 GiB, although summed RSS was only about 206 MiB. Physical footprint was measured with
proc_pid_rusage; these totals are not system-wide unique resident RAM.This supports the repeated tool-runtime accumulation described here, but I have not established that every worker belonged to an inactive chat or should already have exited.
this may be be related to #26773's orphaned nested Codex backends but unclear if they have the same cause
biuro-ctrl commentedon Nov 19, 2026
Additional Linux Desktop observation, Codex App 0.170.0 (read-only, no cleanup attempted)
This matches the process duplication pattern described here, but I cannot yet prove orphaned or terminally settled MCP owners. Sharing bounded evidence for app-server lifecycle maintainers:
/proc/<pid>/smaps_rollupPSS, rather than inflated sum of RSS) of all 190 GUI child processes was about 1.99 GiB; Python MCP sets themselves were about 1.55 GiB PSS. The biggest Electron renderer had ~1.8 GiB PSS.thread_id → writer/claims/pending effects → PID.thread/loaded/listwith 0 loaded threads. This is not the GUI app-server that owns the 190 children, so the zero cannot be used as authorization to reap any GUI MCP.Request: please provide a supported, non-destructive per-GUI-app-server diagnostic for MCP client residency/ownership and pending work, and documented graceful disposal only after the owning thread is definitively terminal and settled, or safe shared MCP reuse/reference-counting. Please do not recommend blind
pkillby parent PID/name/age: active threads may still depend on these children. The objective is to distinguish expected per-live-thread copies from a leak without breaking resumable agent sessions.No session IDs, private thread titles/messages, command secrets, file contents or user locations were disclosed. No Codex process was killed, restarted or reconfigured for this audit.
Exact API inspection: thread-scoped status exists, but not an owner→PID lifecycle receipt
The installed Codex app-server 0.170.0 generated protocol (
ClientRequest.json, 109 methods) exposesmcpServerStatus/list, with optionalthreadId,serverName,detailand bounded pagination. Its status result exposesruntimeStatus(e.g.notStarted,starting,connected,failed) and tool/server metadata, but does not expose child PID, process start identity, writer/lease ownership or pending-effect settlement.thread/loaded/listreturns loaded thread IDs only for the App Server instance receiving the call. Thus the managed daemon's empty list cannot establish whether MCP children owned by a separate desktop stdio App Server are safe to dispose.Reviewing public upstream
codex-rs/app-server/src/request_processors/mcp_processor.rs,list_mcp_server_statuswiththreadIdcallsload_thread(thread_id), then can perform config/snapshot discovery. I did not invoke it on the active GUI/session because it may change runtime residency and would still not return a PID→claim/fence receipt. See implementation: https://github.com/openai/codex/blob/main/codex-rs/app-server/src/request_processors/mcp_processor.rs .Refined maintainer request: provide a genuinely passive
(appServerId,threadId,turnId,helperName,PID+startTime,resourceRefCount,writerPendingEffects,settledState)map for the exact GUI App Server, plus a supportedgracefulDispose(CLOSED_SETTLED)operation with idempotent receipt/readback. Do not suggest pollingmcpServerStatus/liston live dormant threads as a process-owner diagnostic without confirming it is side-effect free. No live processes or sessions were touched.R23 follow-up: 266/266 MCP stdio pipes remain connected; count grew with additional worker activity
New passive Linux
/procreadback on the same running GUI App Server observed 330 direct child processes, up from 190 at earlier samplings, including 266 Python stdio MCP helpers = 7 distinct helper types ×38 copies. A single 8-second sample window was stable at 330. Aggregate PSS of all 330 child processes ~6.73 GiB; this is not proof of a memory leak, as new workflow/worker cohorts were present and no long-term trend was established.For each of the 266/266 Python helpers, I matched its current standard input, output and error
pipe:[inode]to an open file descriptor in the GUI App Server with the opposite read/write mode, and cross-checked the child PID,/proc/statprocess-start ticks and PPID. All three pipe-peer checks passed for 266/266 at the snapshot. Thus these are connected IPC subprocesses, not simply detached orphan processes; still not proof of active session ownership orCLOSED_SETTLED.Grouping each parent/cwd's seven helper types by nth observed process start gave 38 possible sets, but only 37 sets were temporally plausible within a 3-second window; one grouping was ambiguous and explicitly excluded from the plausible count. This is a heuristic, not a
threadIdmap. A new optional read-only WFOS diagnostic PR #298 records only aggregate pipe-peer checks and plausible/ambiguous cohort counts, without storing FD inode IDs, thread IDs, private content or env values. Local exact tests 8/8 PASS; its CI/merge status is separate from Codex App.Requested vendor-safe next step unchanged: expose per-GUI-App-Server
threadId→MCP child PID+birth identity→shared refcount→claims/pending effects→CLOSED_SETTLED, with a native idempotent graceful-dispose receipt and before/after resource readback. No process was stopped or restarted.