Skip to content

Local (stdio) MCP processes leak — new processes spawned per session, never cleaned up #19168

Closed

Description

@athal7

Description

Local MCP servers configured with "type": "local" (stdio transport) spawn a new process for every session opened, but the processes are never terminated when the session ends. Over time this leads to a large number of orphaned processes consuming significant memory.

Steps to reproduce

  1. Configure a local MCP in opencode.json, e.g.:
    "firefox-devtools": {
      "type": "local",
      "command": ["npx", "@padenot/firefox-devtools-mcp", "--firefox-path", "..."]
    }
  2. Open and close several sessions in OpenCode Desktop or the web UI
  3. Check running processes: ps aux | grep firefox-devtools-mcp

Expected behaviour

When a session ends, the stdio MCP child process it spawned should be terminated.

Observed behaviour

Each session spawns a new npm exec + node process pair. After ~12 sessions, 24 orphaned processes were running consuming ~1.2GB RSS combined. They are never cleaned up until the host process is restarted or they are killed manually.

Plugins

opencode-pty, opencode-wakatime

OpenCode version

v1.3.0

Operating System

macOS (Apple Silicon)

Terminal

Ghostty

Activity

  1. added
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    perfIndicates a performance issue or need for optimization
    on Mar 25, 2026
  2. github-actions commented on Mar 25, 2026

    @github-actions
    Contributor

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

    If your issue is distinct from these (e.g. specifically about the stdio/local transport teardown path rather than crash orphans or concurrent-session sharing), please clarify how it differs so it can be tracked separately.

  3. athal7 commented on Mar 26, 2026

    @athal7
    ContributorAuthor

    Thanks for the references. Checking each:

    The specific case here is: after a clean session close (no crash, single session), the stdio/local-transport child processes are not terminated. The teardown path for type: local MCP connections doesn't appear to send SIGTERM to the child before the session is destroyed. Keeping this open as it's a distinct and more precisely scoped bug.

  4. added 5 commits that reference this issue on Mar 26, 2026
    860a7b8
    74d4ff1
    141d912
    ebdecf2
  5. added a commit that references this issue on Sep 19, 2026
    f4ef3b4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

coreAnything pertaining to core functionality of the application (opencode server stuff)perfIndicates a performance issue or need for optimization

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions