Skip to content

Windows: MCP worker survives exit when launched through a wrapper #4972

Description

@svens

Describe the bug

Problem: Exiting the session terminates the MCP launch wrapper but leaves its descendant worker running.

Affected launch chain:

cmd.exe /c run-server.cmd
`- dotnet run --no-build --project ExampleMcpServer.csproj
   `- ExampleMcpServer.exe                                                                                                                                                                                                                                                  

Affected version

GitHub Copilot CLI 1.0.88.

Steps to reproduce the behavior

  1. Configure a local stdio MCP server to launch through a .cmd wrapper running dotnet run.
  2. Start Copilot and wait for the server to initialize.
  3. Exit the session.
  4. Observe that the wrapper terminates but the MCP worker remains alive.

Expected behavior

Terminate the complete session-owned MCP process tree, allowing a bounded graceful shutdown.

Additional context

Suggested fix (copilot generated): Own the process tree using a Windows Job Object with JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE. Assign the initial process before it spawns descendants. Cover normal exit, supervisor crashes, and shutdown during startup or an active request.

Activity

  1. added theissue type on Sep 26, 2026
  2. kvnloo commented on Sep 27, 2026

    @kvnloo

    The Windows Job Object suggestion looks right, but I would make the cross-platform ownership contract explicit:

    every locally spawned MCP process tree belongs to one supervisor scope and must be gone after that scope closes.

    Windows: Job Object with JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE.
    Unix: process group/session ownership with graceful signal followed by bounded kill.

    Regression cases worth covering:

    • direct child;
    • .cmd/shell wrapper with grandchild;
    • supervisor crash;
    • exit during MCP startup;
    • exit during active request;
    • child that ignores graceful shutdown.

    The test should assert on the descendant worker PID, not only the wrapper PID.

  3. svens commented on Sep 28, 2026

    @svens
    Author
    • child that ignores graceful shutdown.

    This might be considered as feature: on 1st run start background worker that serves multiple parallel and/or consecutive sessions.
    But of course, in scope of this issue, it can be deferred or completely ignored until somebody asks for such feature.

  4. Tak2121 commented on Sep 28, 2026

    @Tak2121
  5. added
    area:mcpMCP server configuration, discovery, connectivity, OAuth, policy, and registry
    area:platform-windowsWindows-specific: PowerShell, cmd, Git Bash, WSL, Windows Terminal
    and removed on Oct 4, 2026
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

    area:mcpMCP server configuration, discovery, connectivity, OAuth, policy, and registryarea:platform-windowsWindows-specific: PowerShell, cmd, Git Bash, WSL, Windows Terminal

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions