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 — Background service leaks MCP server processes across reconnects and reloads · Issue #53992 · anomalyco/opencode

Background service leaks MCP server processes across reconnects and reloads #53992

New issue
Copy link
New issue
Copy link
Closed as duplicate
Closed as duplicate
Background service leaks MCP server processes across reconnects and reloads#53992
Copy link
Assignees
rekram1-node
Labels
pending closetriaging

Description

@Sbakkalii
Sbakkalii
opened on Oct 8, 2026
Issue body actions

Summary

With the background service running (opencode TUI session kept open), MCP server processes accumulate instead of being reaped. Repeated reconnects and opencode reload spawn additional instances of the same configured server, all children of the single service PID. Servers with startup cost (model loading) then exhaust their resource budget and connections start failing, and the accumulated processes survive service restart for a while.

Environment

  • opencode v2.0.25 (background service mode, the default)
  • Linux, 32 cores
  • Local stdio MCP servers configured in the global ~/.config/opencode/opencode.json under mcp.servers
  • Observed with a Python MCP server (paddleocr_mcp) that loads large models at startup, and also with a lightweight one

Reproduction

  1. Configure one local stdio MCP server with mcp.servers.
  2. Start OpenCode (background service is spawned).
  3. Run opencode mcp list a few times, and/or opencode reload, and/or start
    sessions repeatedly.
  4. Count the server processes:
pgrep -af "[p]addleocr_mcp"

Observed 4-5 concurrent instances of a single configured server, all sharing
one parent (the service PID).

Impact

  • Resource exhaustion. Each instance held ~2 GB of GPU memory in my case;
    four instances took 7.8 GB of 8 GB, after which every further connection
    failed with a CUDA out-of-memory error surfaced only as
    failed: Connection closed: MCP server process exited with code 1.
  • Leftovers after restart. Immediately after opencode service restart
    there were still multiple stale instances resident.
  • The leak also affects a small server (five instances of a ~300 MB CPU model
    server), so it is not model-specific.

Questions / what I would like confirmed

  1. Is the intended lifecycle that the service owns exactly one process per
    configured server, and reaps it on reconnect or on reload?
  2. Is there a known path where a reconnect spawns a replacement before the old
    process has exited, without deduplication?
  3. Should opencode reload and service restart terminate MCP child processes
    they own?

Notes

  • Reproduces with mcp.servers entries of type local (command arrays).
  • opencode mcp list appears to trigger a connection attempt, so it is a cheap
    way to accumulate instances; I used it as the reproduction driver.
  • I can provide nvidia-smi and ps output showing the shared parent PID if
    useful.

Activity

  1. github-actions
    assigned
    rekram1-node
    on Oct 8, 2026
  2. opencode-agent commented on Oct 8, 2026

    @opencode-agent
    opencode-agentBot
    on Oct 8, 2026 – with OpenCode Agent
    Contributor
    More actions

    Thanks for the detailed report and the measurements. I think this is a duplicate of #52965: duplicate instances of the same MCP server pile up under a single live service process when you run repeated CLI invocations (including opencode mcp list) or start sessions. The reload/restart part of your report is already tracked in #50758.

    Possible duplicates and closely related issues, ordered by likelihood:

    • Duplicate MCP servers accumulate under one opencode process (5× mcp-reva, ~6GB RAM) #52965: duplicate MCP server instances accumulate under one opencode service process across sessions/CLI invocations (opencode mcp list, opencode run); expects one instance per configured server
    • server: stdio MCP child processes not terminated on service restart / config reload #50758: stdio MCP child processes are not terminated on service restart / config reload; old and new sets overlap and servers fail with Connection closed (PR fix(core): close a Location's MCP servers when it shuts down #51730 is open for the reload case)
    • mcp: global stdio servers spawn once per loaded directory and exhaust memory #51003: global stdio servers start once per loaded directory; a comment there confirms opencode reload leaves the previous set running
    • mcp: initial reconciliation can duplicate stdio servers #52741: a startup race in MCP reconciliation can spawn two stdio children for the same server entry
    • MCP: local servers are spawned per session and never released when a session ends #51249: local MCP servers are spawned per session and not released when the session ends (PR fix(core): stop stdio MCP servers when a location's last session is deleted #53366 is open)
    • mcp: orphaned local MCP server processes accumulate after sessions end #50363: orphaned local MCP server processes accumulate after sessions end

    Your nvidia-smi/ps output showing the shared parent PID, plus the confirmation that this still happens on 2.0.25, would be a useful data point on #52965 or #50758.

    The bot will close this issue as a duplicate in 1 day unless you reply explaining how your problem is different.

  3. opencode-agent
    added
    pending close
    triaging
    on Oct 8, 2026
  4. opencode-agent
    closed this as duplicateon Oct 9, 2026
  5. opencode-agent commented on Oct 9, 2026

    @opencode-agent
    opencode-agentBot
    on Oct 9, 2026 – with OpenCode Agent
    Contributor
    More actions

    Closing this as a duplicate of #52965, since we haven't heard back in the day since it was flagged. Duplicate instances of the same local MCP server piling up under the service process are tracked there. The opencode reload / service restart part is tracked in #50758, and PR #51730 is open for the reload case.

    Your ps/nvidia-smi output showing the shared parent PID, plus confirmation that this still happens on 2.0.25, would help on either of those issues. If your problem turns out to be different, reply here and we can reopen.

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.