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 — mcp: initial reconciliation can duplicate stdio servers · Issue #52741 · anomalyco/opencode

mcp: initial reconciliation can duplicate stdio servers #52741

New issue
Copy link
New issue
Copy link
Closed
#58349
Closed
mcp: initial reconciliation can duplicate stdio servers#52741
#58349
Copy link
Assignees
rekram1-node

Description

@everlastingQAQ
everlastingQAQ
opened on Oct 2, 2026
Issue body actions

Description

In packages/core/src/mcp/index.ts, initial reconciliation populates the server entries before scheduling asynchronous startup. It can yield during registration or status-event publication, allowing connect() or disconnect() to finish first. The subsequent initial startup does not recheck the entry's current state under the server lock.

Deterministic tests show two stdio children starting for the same entry after connect(), or a child starting despite an earlier disconnect(). From the implementation, the duplicate startup overwrites entry.scope / entry.client; the next disconnect can close only the currently recorded scope. The earlier scope remains attached to the enclosing location scope, so its child may remain alive until that scope closes unless it exits independently.

Expected: initial startup should not duplicate a connection already established for the same entry, or undo a disconnect. This is not a request to share MCP processes across different locations.

Plugins

None required by the isolated reproduction.

OpenCode version

v2.0.22; affected code also present at v2 commit 134d0ede4dfe4b509dea58baa261e8a307816ac7.

Steps to reproduce

This is a test-level reproduction; the Deferred barrier below controls timing rather than representing a user-facing operation.

  1. Start initial reconciliation with a disabled gate entry followed by an enabled local stdio server.
  2. Use a Deferred barrier in the test bus to pause publication of the gate's status event, after registration but before the local server's startup task is scheduled.
  3. Call connect() for the local server, release the barrier, let reconciliation finish, then disconnect the server. The fixture records two child PIDs instead of one.
  4. Repeat with disconnect() in step 3: the fixture records one child starting instead of zero.

The linked PR adds both regressions in packages/core/test/mcp.test.ts, using the existing stdio fixture. Run them with:

cd packages/core
bun test test/mcp.test.ts -t 'preserves (connect|disconnect) while initial MCP' --timeout 10000

On the unpatched implementation, both fail on the startup-count assertion. With the fix, both pass, and the connect test also verifies the recorded child is gone after disconnect, before disposing the surrounding layer. No mailbox, model calls, or live server are required. A separate isolated test with 20 sequential reloads did not reproduce accumulation; this report concerns the initial-startup race, not every reload.

Operating System

Debian Linux, x86_64; kernel 6.12.107+deb13-amd64.

Terminal

OpenChamber web interface with a local OpenCode release backend; shell zsh. Reproduction runs as a Bun core-package test, independently of the terminal.

Activity

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

    @github-actions
    github-actionsBot
    on Oct 2, 2026 – with GitHub Actions
    Contributor
    More actions

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

    • [Bug] Desktop app spawns every local stdio MCP server twice at session start #41331: Reports every local stdio MCP server spawning twice at session start, matching the duplicate-startup symptom.
    • MCP servers spawn 2-4 duplicate processes per server on startup, causing TasksMax exhaustion and EAGAIN errors #31554: Reports 2–4 duplicate MCP processes per server on startup, a similar startup-duplication symptom.
  3. rekram1-node
    closed this as completedin #58349on Oct 23, 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.