GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Local MCP disconnect leaves descendant processes running · Issue #46253 · anomalyco/opencode

Local MCP disconnect leaves descendant processes running #46253

New issue
Copy link
New issue
Copy link
Closed as not planned
Closed as not planned
Local MCP disconnect leaves descendant processes running#46253
Copy link
Assignees
rekram1-node
Labels
pending closetriaging

Description

@YidiDev
YidiDev
opened on Aug 30, 2026
Issue body actions

Description

A local stdio MCP can spawn a wrapper process tree (npm exec, uvx, shell wrappers). Explicit disconnect and dynamic replacement call client.close(), which terminates the direct transport process but leaves its descendants running.

Full instance teardown already enumerates and terminates descendants, so cleanup behavior differs by lifecycle path. I reproduced this with a real stdio MCP fixture: before the fix, the parent exits and the child remains alive past the assertion deadline.

Expected: every MCP client ownership exit terminates the same full local process tree.

Related but distinct from #46035: that report currently shows complete MCP sets with live launchers, while this issue covers descendants left after teardown is invoked. Also related to the memory tracking thread #20695.

Plugins

None

OpenCode version

Current dev at dc4449df0d

Steps to reproduce

  1. Configure a local stdio MCP whose launcher spawns a long-lived child process.
  2. Connect it, then call MCP disconnect or replace the server under the same name.
  3. Observe that the launcher exits while the child process remains alive.

Screenshot and/or share link

N/A; covered by a deterministic PID-based regression test.

Operating System

Linux x64

Terminal

N/A (automated integration test)

Activity

  1. github-actions
    assigned
    rekram1-node
    on Aug 30, 2026
  2. PVLPM commented on Sep 20, 2026

    @PVLPM
    PVLPM
    on Sep 20, 2026
    More actions

    Same behaviour on Windows with a real-world stdio MCP setup, and the surviving descendants are the whole problem.

    Config: local MCP entries launched as ["npx","-y","@magicuidesign/mcp@latest"] etc. After some hours on OpenCode Desktop 2.0.11 / Windows 11, Get-CimInstance Win32_Process -Filter "Name='cmd.exe'" returned 81 live processes, all rooted at the single opencode-cli.exe serve --service instance. The launcher chain per server is:

    opencode-cli.exe serve --service
    └─ cmd.exe /d /s /c "npx -y <pkg> [args]"      ← outer wrapper
       └─ node.exe .../npm/bin/npx-cli.js
          └─ cmd.exe /d /s /c <pkg-bin> [args]     ← inner wrapper
             └─ the MCP server process
    

    client.close() terminates the direct transport child, but the outer cmd.exe /d /s /c "npx ..." and the package's own cmd.exe both stay alive, so the wrapper tree outlives the disconnect exactly as you describe. Grouping the 81 by direct parent confirms it: 45 are children of opencode-cli.exe, 34 are children of npx-cli.js nodes — i.e. both layers are orphaned, not just the innermost one.

    On Linux this is invisible; on Windows each surviving cmd.exe is a console process that keeps a window on screen. So as a user-visible symptom this is not a brief flash but dozens of persistent cmd.exe windows accumulating over a session. Reproduced on 2.0.11, and earlier on 2.0.10.

    It would help a lot if teardown enumerated and killed the whole tree on every ownership exit path (disconnect, replace, instance disposal), not only on full-instance teardown.

  3. opencodejr commented on Oct 28, 2026

    @opencodejr
    opencodejrBot
    on Oct 28, 2026
    Contributor
    More actions

    Thanks for the detailed report and the PID-based test!

    Commit dc4449df0d comes from before the v2 codebase was promoted to dev. At that commit dev was still OpenCode v1 (packages/opencode, 1.18.x), and the MCP lifecycle you describe is in v1's packages/opencode/src/mcp/index.ts. v1 now only gets fixes for critical bugs (data loss, security problems, crashes or breakage with no workaround). Leftover MCP child processes are a real leak, but you can kill them or restart OpenCode, so this is unlikely to be fixed in v1.

    v2 (@opencode/cli, 2.x) handles this differently. Its stdio MCP transport (packages/core/src/mcp/stdio.ts) starts each server in its own process group and terminates the whole group whenever the transport closes, so disconnecting or replacing a server should also stop wrapper descendants like npm exec or uvx children. I'd recommend upgrading to v2.

    If you still see descendants left behind on a current v2 release, or you think this is critical in v1, please reply here with the version and steps and we'll take another look.

  4. opencodejr
    added
    pending close
    triaging
    on Oct 28, 2026
  5. opencodejr
    closed this as not plannedon Oct 29, 2026
  6. opencodejr commented on Oct 29, 2026

    @opencodejr
    opencodejrBot
    on Oct 29, 2026
    Contributor
    More actions

    Closing this as not planned. As mentioned above, this report is about the v1 MCP code (packages/opencode, 1.18.x). v1 only gets fixes for critical bugs, and leftover MCP child processes can be worked around by killing them or restarting OpenCode. In v2 (@opencode/cli, 2.x), the stdio MCP transport stops the server's whole process group whenever it closes, which should cover disconnect and replacement.

    Thanks again for the thorough report and test. If you can reproduce descendants left behind on a current v2 release, please open a new issue with the version and steps.

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

Metadata

Metadata

Assignees

  • @rekram1-node
    rekram1-node

Labels

pending closetriaging

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.