Skip to content

Spawns multiple MCP servers with wrong cwd and doesn’t clean them up #7281

@ginishuh

Description

@ginishuh

What version of Codex is running?

ChatGPT VS Code extension openai.chatgpt v0.4.46 inside VS Code (Remote: WSL).

What subscription do you have?

ChatGPT Pro (personal subscription)

Which model were you using?

GPT-5.1 Codex (gpt-5.1-codex-high) via the Codex / ChatGPT VS Code extension.

What platform is your computer?

Windows 11 host with WSL2 (Ubuntu 22.04), using VS Code Remote: WSL.

What issue are you seeing?

The Codex / ChatGPT VS Code extension starts multiple MCP server processes (e.g. serena start-mcp-server) inside WSL2 with the wrong working directory (sometimes pointing at the Windows VS Code install path under /mnt/c/... instead of the WSL workspace), and these MCP servers are not cleaned up when chats/workspaces are closed. Over time they accumulate and consume significant memory.

What steps can reproduce the bug?

What steps can reproduce the bug?

In WSL2, create/open a workspace, e.g. /home//proj.

Open this folder in VS Code via Remote: WSL.

Install and enable the openai.chatgpt extension.

In that workspace, start a Codex/ChatGPT session that uses an MCP server (e.g. Serena via uvx ... serena start-mcp-server) by asking it to analyze or edit code.

Let the session run for a while, optionally open another chat or another VS Code window on a different WSL workspace and use Codex/ChatGPT there as well.

In WSL2, run:

ps aux | grep 'serena start-mcp-server' | grep -v grep

For several MCP server PIDs, inspect their cwd via:

ls -ld /proc//cwd

Observe that some processes use the Windows VS Code install directory under /mnt/c/... as cwd, others use the WSL workspace, and that none of these processes are cleaned up when chats are closed.

What is the expected behavior?

MCP servers started by the extension should use the current WSL workspace root as cwd, not the Windows VS Code install directory under /mnt/c/....

MCP servers should be reused per workspace where possible, instead of starting multiple independent instances for the same project.

MCP servers that are no longer needed should be cleaned up when the associated chat session or workspace is closed, so they do not accumulate and consume memory over time.

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingextensionIssues related to the VS Code extensionmcpIssues related to the use of model context protocol (MCP) serverswindows-osIssues related to Codex on Windows systems

    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