Problem
After a reboot, OpenCode 2 threads could start normally but have no s2 MCP tools until the s2 server was restarted. The provider instance took one snapshot of the host addresses before Tailscale had assigned its address and kept the negative reachability result for the life of the instance.
Fix
When preparing a turn with an MCP session, re-read the host addresses while the configured OpenCode connection is classified as unreachable. Cache a positive answer only for that connection, so an already-open thread can recover on its next turn without reconnecting and healthy connections don't keep looking up addresses. Owned servers keep their existing local behavior.
The first skipped registration on each connection logs Skipping MCP registration: OpenCode cannot reach the local MCP endpoint. with serverUrl set to the URL origin only (no credentials, path, query, or fragment).
OpenCode 1.x has no address snapshot to go stale: it excludes all configured external servers from s2 MCP registration. That policy is unchanged. This is a shared server-side fix for web, desktop, and mobile; no client or wire contract changes.
Verification
-
Extended the existing OpenCode2Server external-connection case with an injected address source. On main (422ef23c) the test fails because mcpReachable is a frozen boolean there (TypeError: yield* … is not iterable); with the address read planted back at connect time in the new code, it fails with expected false to be true. With the fix, the same connection recovers, and forgetting it clears the cached answer. No sleeps or real interface changes.
-
nice -n 19 node scripts/check-changed.ts origin/main --concurrency 2 passed (12 tests; typecheck, format, lint, Knip, GraphQL). The 13 existing OpenCode 2 adapter tests matching MCP also passed.
-
Local fixture transcript (in-process fake HTTP service, no live provider turns):
WARN Skipping MCP registration: OpenCode cannot reach the local MCP endpoint. { serverUrl: 'http://100.64.0.1:49374' }
Address absent: false
Address still absent: false
Address added, same connection: true
Upstream candidate: Not standalone. The file exists upstream, but the cached reachability gate comes from the fork's local-configured-server MCP support. This is worth carrying with that support if it goes upstream. No upstream PR was opened.
Model / harness: GPT-6.2 Sol (openai/gpt-6.2-sol) in OpenCode (shuvcode) via T3 Code.
Review notes (lead)
Opus high: APPROVE. Known trade-off, accepted: for a configured server on another machine, each turn with an MCP session re-reads interfaces and resolves the hostname (HostProcess.Addresses, no timeout), where it used to happen once per instance. A broken resolver could slow turn start; not addressed here as unlikely. No info log on unreachable -> reachable (optional nit, skipped).