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 stdio MCP servers leak processes on disconnect / replace / rollback · Issue #26714 · anomalyco/opencode

Local stdio MCP servers leak processes on disconnect / replace / rollback #26714

New issue
Copy link
New issue
Copy link
Closed as not planned
Closed as not planned
Local stdio MCP servers leak processes on disconnect / replace / rollback#26714
Copy link
Assignees
rekram1-node

Description

@yangshuai0711
yangshuai0711
opened on May 10, 2026
Issue body actions

Description

When a local stdio MCP server is disconnected, replaced (via a second MCP.add() with the same name), or rolled back after tool discovery (defs()) failure, the spawned process tree is not terminated. Only client.close() is called, which stops the SDK transport but leaves the child process and its descendants running as orphans.

The existing cleanup code (added in #15516) only covers the instance disposal path, and even there it only kills descendant PIDs — not the transport's own root PID.

Over multiple sessions these orphaned processes accumulate, consuming memory and potentially holding ports.

OpenCode version

1.3.13 (dev branch, commit d112da0)

Steps to reproduce

  1. Configure a local stdio MCP server in opencode.json (e.g. "type": "local", "command": ["node", "server.js"])
  2. Disconnect the server via MCP.disconnect() — or trigger a replace by calling MCP.add() twice with the same name
  3. Check running processes: the MCP server process is still alive with PPID changed to 1

Operating System

macOS (Apple Silicon)

Terminal

Ghostty

Additional context

This is related to #15808 and #8257 but covers a distinct gap:

vs #15808 ("opencode run: MCP child processes not terminated on exit"): That issue is about the opencode run headless command not cleaning up MCP processes when the CLI exits. #15516 partially addressed it by adding descendant kill in the dispose handler. But the in-process teardown paths — disconnect(), add-replace, and defs-failure rollback — were never covered. This issue is specifically about those paths.

vs #8257 ("Memory leak: MCP clients not closed before reassignment"): That issue is about connections/sockets leaking when a client reference is overwritten without calling .close(). Our concern is broader: even when .close() is called (as in the current disconnect path), the process is not killed. Client close does not guarantee process termination.

No existing PR addresses this specific set of gaps. PR #15516 (merged) added descendant cleanup in the dispose path only. PR #21626 (open) is about SDK process groups, not MCP teardown. No one has submitted a fix covering the root PID kill or the disconnect/rollback paths.

Activity

  1. github-actions
    assigned
    rekram1-node
    on May 10, 2026
  2. github-actions commented on May 10, 2026

    @github-actions
    github-actionsBot
    on May 10, 2026 – with GitHub Actions
    Contributor
    More actions

    This issue doesn't fully meet our contributing guidelines.

    What needs to be fixed:

    • No issue template was used. Please use the Bug Report template, which requires a description of the problem and reproduction steps.
    • Missing system information: please include your OpenCode version, OS, and any other relevant environment details.

    Please edit this issue to address the above within 2 hours, or it will be automatically closed.


    This issue might be a duplicate of existing issues. Please check:

    • opencode run: MCP child processes not terminated on exit (orphan leak) #15808: MCP child processes not terminated on exit (orphan leak) — similar process cleanup issue in mcp/index.ts
    • Memory leak: MCP clients not closed before reassignment #8257: MCP clients not closed before reassignment — overlapping concern about teardown paths in MCP.add()

    If you believe this was flagged incorrectly, please let a maintainer know.

  3. github-actions
    added
    needs:complianceThis means the issue will auto-close after 2 hours.
    on May 10, 2026
  4. yangshuai0711
    closed this as a duplicateof opencode run: MCP child processes not terminated on exit (orphan leak) #15808 on May 10, 2026
  5. yangshuai0711
    reopened this on May 10, 2026
  6. github-actions
    removed
    needs:complianceThis means the issue will auto-close after 2 hours.
    on May 10, 2026
  7. github-actions commented on May 10, 2026

    @github-actions
    github-actionsBot
    on May 10, 2026 – with GitHub Actions
    Contributor
    More actions

    Thanks for updating the issue! Everything looks good now — the bug report has a clear description, steps to reproduce, version info, and OS details. Appreciate the thorough write-up!

  8. github-actions commented on Jul 10, 2026

    @github-actions
    github-actionsBot
    on Jul 10, 2026 – with GitHub Actions
    Contributor
    More actions

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

  9. github-actions
    closed this as not plannedon Jul 10, 2026
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

No labels
No labels

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.