Skip to content

/clear  does not terminate previous stdio MCP server child processes (unlike  /mcp reload ) #4697

Description

@robgurr

Description

When reloading MCP servers with /mcp reload, the CLI correctly terminates the existing stdio MCP server child process before starting a new one. However, running /clear (start fresh session) spawns a new stdio MCP server process without terminating the previous session's MCP server process, leaking orphaned processes over time.

Steps to reproduce

  1. Start a session with a stdio-based MCP server configured (e.g. a custom *.exe MCP server).
  2. Confirm the server process is running (e.g. via Task Manager / Get-Process).
  3. Run /clear.
  4. Observe: a new instance of the MCP server process starts, but the previous one is still running.
  5. Repeat /clear multiple times — orphaned process count grows unbounded.
  6. Contrast with /mcp reload, which correctly stops the old process before starting the new one.

Expected behavior

/clear should terminate/clean up MCP server child processes from the previous session (or reuse them) before/while starting the new session's servers, matching the behavior of /mcp reload.

Actual behavior

Old MCP stdio server processes are left running indefinitely after /clear, accumulating over repeated use (observed 22+ orphaned exe instances in one session).

Environment

  • Copilot CLI version: 1.0.82
  • OS: Windows
  • MCP server type: stdio-based custom MCP server

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:mcpMCP server configuration, discovery, connectivity, OAuth, policy, and registryarea:sessionsSession management, resume, history, session picker, and session state

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions