mcp: expected remote-server reconnects and capability-probe misses flood the service log at WARN
Summary
Remote MCP servers that disconnect on a fixed cycle (e.g. a reverse proxy with a ~60s total-duration route timeout on the SSE stream) generate one mcp transport error WARN per reconnect, forever — even though the client reconnects and re-authenticates successfully every time and all tool calls succeed. Servers that don't implement resources/templates/list additionally produce WARN noise at every session init. Over 20 days this filled our service log with >28,000 WARN lines for two servers (~96% of a 39 MB log), drowning the real WARN/ERROR signal in the same file.
Environment
- opencode version: 2.4.1
- OS: macOS (Darwin 27.2.0, arm64)
- Terminal: headless background service (
opencode service), log consumed by a custom web dashboard; iTerm when used interactively - Shell: /bin/zsh
- Install/channel: latest
- Active plugins: none
Reproduction
- Configure a remote MCP server (streamable HTTP) whose infrastructure terminates the SSE GET after ~60s (in our case: a Gateway-API HTTPRoute with a 60s total-duration timeout; the OAuth access token also lives 60s).
- Run the opencode background service continuously for days.
- Watch
~/.local/share/opencode/log/opencode.log.
Also configure any remote MCP server that does not implement resources/templates/list (e.g. Firecrawl) and start a few sessions.
Expected Behavior
- A disconnect that is immediately and successfully reconnected is an expected, handled condition → INFO/DEBUG, not WARN; repeated identical transport errors per server should be rate-limited or downgraded after the first occurrence.
- Missing
resources/templates/listsupport is a stable per-server property → WARN at most once per server (then DEBUG), not once per session init. - A per-server or per-category log-level override would let users quiet one known-noisy server without globally raising the service level (the global
OPENCODE_LOG_LEVEL=ERRORworkaround silences ALL WARN signal — we count WARN compaction-rejection lines in tooling, so that's a real cost).
Actual Behavior
20 days, two servers, all tool calls succeeding throughout:
- 19,460 ×
mcp transport error—SSE stream disconnected: TypeError: ECONNRESET(one per ~63s cycle) - 6,033 ×
mcp http authentication rejected(the same cycle re-authing with the 60s-TTL token) - 401 ×
failed to list MCP resource templates+mcp transport error—-32601 "Method not found"(HTTP 404), every session init
Sample (redacted) log lines:
timestamp=2026-12-01T22:25:26.204Z level=WARN run=51c1a71e message="mcp transport error" server=<remote-a> error="Error POSTing to endpoint: {\"jsonrpc\":\"2.0\",\"id\":4,\"error\":{\"code\":-32601,\"message\":\"Method not found\"}} (HTTP 404)" http.span=2140 role=server
timestamp=2026-12-01T22:26:29.155Z level=WARN run=51c1a71e message="mcp transport error" server=<remote-b> error="SSE stream disconnected: TypeError: ECONNRESET: The socket connection was closed unexpectedly..." http.span=65091 role=server
Additional Context
The 60s disconnect cadence is our server-side config (fix in progress on our side) — but the logging severity is client-side: an expected reconnect that succeeds is not a warning, and anyone behind a proxy with a short SSE timeout hits the same flood. Workarounds evaluated: manual log rotation (cosmetic only), global OPENCODE_LOG_LEVEL=ERROR (loses all WARN signal for tooling), per-server disable (loses the tools).
Thanks, maintainers will consider this; no promise on whether or when. As far as I can see, the change would be in packages/core/src/mcp/client.ts, where client.onerror logs every transport error at WARN as mcp transport error, including SSE disconnects that reconnect successfully. The only log level control I found is the global OPENCODE_LOG_LEVEL; I found no override per server or per category.
Two different conditions are reported through one path, and only one is a fault.
A 60s SSE end of stream is a normal termination: the client reconnects, re-authenticates, and every tool call succeeds. The unconditional WARN in client.onerror counts that as a transport error, once per cycle, forever. The file already draws this line one branch up: retrying() logs at WARN only while a retry remains, gated on isTransient, and the finalizer sets client.onerror = undefined before terminateSession so an expected failure is not reported twice.
Concretely: keep a counter per server and stream, log the first reconnect at WARN with the budget, then one rollup per window instead of N lines. Escalate on every event only once negotiate exhausts its deadline, which is the real outage. Whether a reconnect is expected is a transport property, so it belongs in transport config beside the timeout.
The resources/templates/list noise is a separate class: a -32601 MethodNotFound answer is a stable fact about that server, not a transport fault. Cache it per server and client version, log at DEBUG, and read the resources capability from the initialize result before calling at all.