Summary
A local stdio MCP server whose command depends on a daemon that finishes booting after OpenCode starts (canonical case: docker run … ghcr.io/github/github-mcp-server) loses the startup race, fails its single connect attempt, and then stays failed for the entire session. There is no retry, no re-probe of the dependency, and no CLI recovery path — even though the dependency answers docker info seconds later.
Requested fix: a reachability watchdog — failed servers get re-probed on a backoff schedule and are auto-connected once their dependency becomes reachable — plus optional per-server readyCheck / readyTimeout and opencode mcp reconnect [name].
Environment
- opencode version:
2.3.0 (homebrew stable, /opt/homebrew/bin/opencode)
- OS: macOS 26.6 (
Darwin 25.6.0) arm64
- Terminal: Ghostty,
TERM=xterm-256color; shell /bin/zsh
- Active plugins: one local
.opencode/plugin/ file only (no MCP plugins)
- MCP config:
"github": {
"type": "local",
"command": ["docker", "run", "-i", "--rm", "-e", "GITHUB_PERSONAL_ACCESS_TOKEN", "ghcr.io/github/github-mcp-server"],
"environment": { "GITHUB_PERSONAL_ACCESS_TOKEN": "{env:GITHUB_PERSONAL_ACCESS_TOKEN}" },
"enabled": true
}
Reproduction
- Configure the server above (image already pulled:
ghcr.io/github/github-mcp-server v2.0.2, stdio transport).
- Quit OpenCode. Make sure Docker Desktop is not up yet (it is a login item here, so on a cold boot it appears 20–60 s after the desktop session).
- Start OpenCode.
github fails within the first second.
- ~25 s later Docker Desktop is ready:
docker info succeeds and printf '<initialize>' | docker run -i --rm -e GITHUB_PERSONAL_ACCESS_TOKEN ghcr.io/github/github-mcp-server answers on stdio.
opencode mcp list keeps reporting the server as failed for as long as the service lives, and GitHub tools never appear in the session.
- Only rewriting the
mcp block of opencode.json (or a service restart) recovers it.
Actual behaviour (v2.3.0 log excerpt)
# connect attempt — Docker socket does not exist yet
timestamp=2026-11-15T13:25:20.282Z level=WARN message="mcp transport error" server=github
error="MCP server process exited with code 1: failed to connect to the docker API at unix:///Users/chainweb/.docker/run/docker.sock; check if the path is correct and if the daemon is running: dial unix /Users/chainweb/.docker/run/docker.sock: connect: no such file or directory"
timestamp=2026-11-15T13:25:20.283Z level=WARN message="mcp connect failed" server=github status.status=failed
# Docker Desktop finished launching 24 s later (process start 2026-11-15T13:25:44Z). Nothing retries.
# 2 h 22 m later: first successful connect — triggered only by an edit to the mcp config block
timestamp=2026-11-15T15:47:43.073Z level=INFO message="mcp connected" server=github tools=46 http.span=8544821
http.span=8544821 (ms) is the time between the failed attempt and the connect, i.e. the config rewrite rather than a retry. The same docker-socket failure appears on 2026-11-13 (twice) and 2026-11-15, so this is a recurring cold-boot pattern, not a one-off.
The three remote servers in the same config recovered across locations; only the local docker run server stayed wedged for the whole session.
Expected behaviour
A server whose dependency is currently unreachable should be treated as waiting, not terminal failed, and should connect automatically as soon as the dependency becomes reachable — with no config edit and no service restart.
Proposal
- Backoff retry for failed servers — reconnect attempts with exponential backoff (
0.5s, 1s, 2s … 60s, then a 60 s steady poll bounded by a configurable retryWindow/attempts) instead of one attempt per location. Keep attempts strictly serial so this does not become the retry-storm class of bug (mcp: no-backoff resources/list retry storm wedges the service; new MCP connects stall #63876).
- Dependency probe (
readyCheck) — let a local server declare how to detect that its dependency is up, so the client can skip doomed spawns and reconnect the moment it is ready:
"github": {
"type": "local",
"command": ["docker", "run", "-i", "--rm", "-e", "GITHUB_PERSONAL_ACCESS_TOKEN", "ghcr.io/github/github-mcp-server"],
"readyCheck": ["docker", "info", "--format", "{{.ServerVersion}}"],
"readyTimeout": 300000,
"retry": { "initialDelay": 500, "maxDelay": 60000, "attempts": 20 }
}
- Probe triggers — initial connect failure,
config.updated, new session in a location, service restart, and (nice to have) system wake / network change, which would also cover the remote cases in mcp: remote MCP servers that fail once are never retried until service restart #52237 and mcp: remote server stays failed after system wake, retries stop after ~1.3s #62405.
- Status surface —
opencode mcp list should distinguish waiting for dependency (probe failing) from failed (probe fine, server broken), and there should be a manual trigger: opencode mcp reconnect [name], or the TUI equivalent.
- Agent visibility — a configured-but-retrying server should be visible to the model as retrying so it cannot silently conclude "not configured" (mcp: failed servers are indistinguishable from unconfigured ones for the agent #62973).
Workaround used meanwhile
Make sure the dependency is up before OpenCode spawns MCP, e.g. with a launcher wrapper:
command -v docker >/dev/null && ! docker info >/dev/null 2>&1 && open -a Docker 2>/dev/null
for _ in $(seq 60); do docker info >/dev/null 2>&1 && break; sleep 1; done
exec opencode "$@"
Related
I also prototyped the client-side workaround as a V2 plugin (ctx.mcp.list() poll + ctx.mcp.reload() once the dependency probes OK). Happy to upstream it, or to send a PR for the retry policy itself, if you can confirm the preferred shape (retry loop inside the location's MCP supervisor vs. a new readyCheck config field).
Additional finding: a plugin cannot work around this today
I tried to implement the watchdog as a V2 plugin, since ctx.mcp does expose the connection state:
const list = await ctx.mcp.list()
// { location: { directory }, data: [{ name: "github", status: { status: "failed", error: "…" } }] }
but there is no reconnect primitive:
ctx.mcp.reload() re-reconciles config and does not re-spawn a failed server — list() before/after a reload() with the dependency demonstrably reachable stays failed (verified on 2.3.0, probe:failed → probe:failed).
- The documented lifecycle lever (
ctx.mcp.transform(editor => editor.update(name, s => { s.disabled = true })) + reload() + re-enable + reload()) is the only other option, and it is a config-level disable/enable rather than a connection retry.
- The HTTP client routes (
/mcp/{name}/connect) are not reachable from the plugin context, and opencode mcp exposes no reconnect/retry subcommand.
So the only client-side mitigation available to users today is to make sure the dependency is up before OpenCode starts (launcher wrapper in the workaround above). A retry loop or a plugin-callable ctx.mcp.connect(name) would unblock this properly.