Skip to content

Local MCPs fail to start - stdin closes immediately after spawn #8434

Closed as duplicate

Description

@yanosh-k

Description

Local MCPs that worked in v1.1.16 fail to connect in v1.1.17 and later (tested with v1.1.19). When attempting to enable a local MCP via /mcp menu, the MCP shows as "failed" instead of "connected".

Environment:

Installation Method: npm (npm install in /srv/ai/open_code/)
Execution Method: Direct invocation of /srv/ai/open_code/node_modules/.bin/opencode
Node Version: v24.13.0 (installed via snap at /snap/bin/node)

Findings:

When starting the MCP server with NODE_DEBUG=* and DEBUG=*, I get the following in the logs:

STREAM 135231: read undefined
STREAM 135231: need readable true

while the command for starting the MCP server exits with code 0.

This leads me to believe that the following is happening with the MCP server:

  1. Loads successfully
  2. Starts listening on stdin
  3. Immediately receives undefined (EOF) when trying to read from stdin
  4. Exits cleanly with code 0

Probably indicating that OpenCode is closing stdin before the MCP server can read from it, or not properly piping stdin to the MCP server process.

Analyzing the code changes between v1.1.16 and v1.1.17:

  • In v1.1.16:
    The postinstall.mjs script called symlinkBinary() which created a direct symlink from .bin/opencode to the native Bun binary at node_modules/opencode-linux-x64/bin/opencode
  • In v1.1.17:
    The symlinkBinary() call was removed
    The Node.js wrapper script at node_modules/opencode-ai/bin/opencode is now used instead
    This wrapper uses child_process.spawnSync() with stdio: "inherit"

When executed via the wrapper script:

  • Node.js wrapper spawns the native Bun binary with spawnSync(..., { stdio: "inherit" })
  • The Bun binary attempts to spawn MCP subprocesses via StdioClientTransport
  • The MCP subprocess receives EOF on stdin immediately and exits

The stdio inheritance chain appears to break somewhere between:

  • Node.js wrapper → Bun binary → MCP subprocess

The MCPs can be enabled correctly when:

  • Running the native Bun opencode binary directly (bypassing the Node.js wrapper) - /srv/ai/open_code/node_modules/opencode-linux-x64/bin/opencode
  • Running the MCP command manually from a terminal (terminal keeps stdin open)

Plugins

No response

OpenCode version

v1.1.17

Steps to reproduce

  1. Install opencode v1.1.17 with npm: npm install opencode-ai@1.1.17
  2. Configure a local MCP in ~/.config/opencode/opencode.json:
{
  "mcp": {
    "playwright-cdp": {
      "type": "local",
      "command": [
        "node",
        "/srv/ai/mcp/playwright/node_modules/@playwright/mcp/cli.js",
        "--cdp-endpoint=http://localhost:9222"
      ],
      "enabled": false
    }
  }
}
  1. Start opencode: /srv/ai/open_code/node_modules/.bin/opencode
  2. Type /mcp to open the MCP management menu
  3. Toggle the status of playwright-cdp from disabled to enabled

Screenshot and/or share link

Image

Operating System

Ubuntu 24.04

Terminal

Gnome Terminal

Activity

  1. github-actions commented on Jan 14, 2026

    @github-actions
    Contributor

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

    Feel free to ignore if this doesn't address your specific case.

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

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions