OpenCode keeps MCP tools listed when servers disconnect

OpenCode 2.4.5 reconnects when a retained MCP tool is called and retries eligible failed first starts on later agent steps. Here’s how to verify recovery in the same session.

Editorial cover: OpenCodeEditorial cover: OpenCode
Company marks identify their owners. Reference only; no endorsement.

OpenCode 2.4.5, released December 4, keeps Model Context Protocol (MCP) tools listed when their server drops its connection. When the agent next calls one of those tools, OpenCode can attempt to reconnect. New sessions can also start with a saved tool list while a server connects. For developers whose coding agents rely on a local helper or a remote documentation server, a brief interruption can now clear without a manual reconnect or a new session. OpenCode 2.4.5 release notes

Two OpenCode recovery paths. If saved tools exist, the list stays visible and a tool call can trigger reconnection. If an eligible first start fails with no saved tools, a later agent step can trigger a background retry.Two OpenCode recovery paths. If saved tools exist, the list stays visible and a tool call can trigger reconnection. If an eligible first start fails with no saved tools, a later agent step can trigger a background retry.
OpenCode 2.4.5 uses two recovery triggers. A call can reconnect a server with retained tools, while a later agent step can trigger a due retry after an eligible first-start failure.

The OpenCode v2.4.5 release page on GitHub.
The OpenCode project’s v2.4.5 release page on GitHub. · Original source

Recovery depends on whether OpenCode knows the tools

If OpenCode has the server’s tool list, it can keep offering those tools to the agent after the connection drops. A later call can trigger a reconnect once the backoff permits it. The saved list also gives a new session something to work with while the live server starts. Previously, the behavior depended on mcp_resilience. The release makes it unconditional and removes the flag. The implementation notes say old entries in experimental.mcp_resilience or OPENCODE_FLAGS are ignored, so an explicit opt-out in an existing config no longer controls recovery. OpenCode pull request #67926

A server that fails its first start and has no saved tools needs a different trigger. The agent has no tool to call, so OpenCode checks for a due retry as the agent takes later steps. Eligible retries run in the background and stop after a bounded series of attempts. The implementation describes six backoff delays, starting at two seconds and ending at 2,048 seconds. Those delays govern when a retry is due. An agent step still has to reach the check, so leaving an idle session open is a poor way to test this path. The merged change also keeps background retries from holding an agent step while the connection is in progress. OpenCode pull request #67899

What happened What OpenCode 2.4.5 does
A previously connected server drops Keeps its tools listed and can reconnect on a later call when backoff permits.
A new session has a saved tool list Starts with that list while the server connects.
An eligible first start fails and there is no saved list Checks for a due background retry on later agent steps.
The server is gone, such as a missing local command or a URL returning HTTP 404 or 410 Drops the server instead of continuing to retry it.

The first-start implementation also excludes cases that require authentication or have invalid configuration. If a server needs sign-in or its command has moved, fix that underlying issue before expecting a successful call. A retained tool listing tells you OpenCode remembers the interface. A successful response tells you the server handled the request. Release notes · First-start retry implementation

Check for a fresh tool result in the same session

  1. Establish a baseline. In a test workspace, connect a server you control and ask OpenCode to call one read-only tool whose output you can check. A documentation lookup against a local fixture works well. Confirm that the transcript records the tool call and that the result matches the fixture.
  2. Interrupt and restore the connection. Stop the test server, keep the OpenCode session open, then bring the server back. Change a harmless value in the fixture while the server is down so that you can distinguish a fresh response from text already in the conversation.
  3. Make another call. After any reconnect backoff has elapsed, ask the agent to invoke the same tool again. Look for a successful tool response containing the changed value. If the request fails, record the error and check the server directly before trying again. The MCP Inspector guide covers how to check the connection and exercise a tool outside the agent.

If your actual problem is a local service that comes up late, run a second check with a fresh test configuration that has no saved list for that server. Start the session while the service is unavailable, bring it up, then give the agent another step after a retry is due. Once the tools appear, require a successful read before counting the recovery. That exercises the first-start behavior that matters when OpenCode launches before a local dependency is ready. First-start retry implementation

Sources

  1. Release v2.4.5 · anomalyco/opencode · GitHub
  2. feat(core): make MCP resilience always-on and remove mcp_resilience flag by rekram1-node · Pull Request #67926 · anomalyco/opencode · GitHub
  3. fix(core): add bounded step-time retries for failed MCP first starts by rekram1-node · Pull Request #67899 · anomalyco/opencode · GitHub