Skip to content

mcp: documented 5 s timeout default is actually 30 s; per-server scalar timeout also overwrites the 12 h execution window #63092

Open

Description

@WRgit420

Summary

Three related problems with MCP timeout configuration in opencode 2.2.5:

  1. The documented default is wrong. The published schema says 5000 ms. The bundled MCP client uses a 30000 ms startup deadline.
  2. A per-server scalar timeout silently rewrites the execution window. "timeout": 60000 is normalized to {startup: 60000, catalog: 60000, execution: 60000} — it lowers the 12 h execution budget to 60 s. The schema does not mention that the scalar is broadcast to all three phases.
  3. The per-server object form is dropped, taking the whole server with it (same class of bug as mcp: server entries with a "timeout" field are silently dropped from the normalized config #50807, still present in 2.2.5), even though an object is accepted one level up at mcp.timeout.

Net effect for a user who reads the schema to fix intermittent Request timed out on a slow local MCP: wrong default, silently truncated execution budget, and — if they try the object form — a server that disappears from the config.

Environment

  • opencode 2.2.5 (channel=latest), macOS darwin, packaged binary
  • schema: https://opencode.ai/config.json

Evidence

1. Documented default vs. actual constant

Schema ($defs.McpLocalConfig.properties.timeout and $defs.McpRemoteConfig.properties.timeout):

Timeout in ms for MCP server requests. Defaults to 5000 (5 seconds) if not specified.

Bundled client in 2.2.5 (strings on the binary):

var J=30000,pe=30000,ue=43200000,fe=600000,K=1000,
...
C.connect(e,{timeout:U?.startup??J})

Startup 30 s, catalog 30 s, execution 12 h, attached execution 10 min.

Behavioral check — a local MCP server that answers initialize only after 10 s connects successfully, which is impossible under a 5 s default:

level=INFO message="mcp connected" server=slowdemo10 tools=0 http.span=12892

2. Scalar timeout is broadcast to startup + catalog + execution

opencode debug config with a local server carrying "timeout": 60000:

"slow": {
  "type": "local",
  "command": ["/bin/true"],
  "disabled": false,
  "timeout": { "startup": 60000, "catalog": 60000, "execution": 60000 }
}

Same normalization on a real entry:

"playwright": { ..., "timeout": { "startup": 60000, "catalog": 60000, "execution": 60000 } }

The default execution budget is 43200000 (12 h), so raising the startup budget the documented way caps long-running tool calls at 60 s.

3. Per-server object form drops the server

Config:

{
  "mcp": {
    "s": {
      "type": "local",
      "command": ["/bin/true"],
      "timeout": { "startup": 60000, "catalog": 60000, "execution": 43200000 }
    }
  }
}

opencode debug config output for that source:

temp source mcp = undefined

Only a log line, nothing on stdout:

level=WARN message="configuration normalization diagnostic" source=<config>
  path=$.mcp.s kind=invalid action="skipped malformed recognized value"

Workaround that does work

Use the global object instead of a per-server scalar:

{
  "mcp": {
    "timeout": { "startup": 60000, "catalog": 60000, "execution": 43200000 },
    "slow": { "type": "local", "command": ["..."] }
  }
}

Verified — a local MCP answering after 35 s connects (http.span=36951) with startup: 60000, and fails under the default 30 s.

Expected behavior

References

Activity

  1. opencodejr commented on Nov 10, 2026

    @opencodejr
    Contributor

    Thanks for the detailed report. I reproduced this on 2.2.5, and it still happens on the latest dev (98e4b53). There, I checked by running the config normalizer directly, because the CLI from source wouldn't start in my sandbox.

    • Wrong default: the per-server timeout text in https://opencode.ai/config.json (McpLocalConfig / McpRemoteConfig) still says "Defaults to 5000 (5 seconds)", but the client uses a 30 s startup default.
    • Object timeout on a server directly under mcp: the entire server disappears from opencode debug config. The only trace is the skipped malformed recognized value warning in the log file. The same object under mcp.servers.<name>.timeout is kept, so that form, or the global mcp.timeout object you found, works as a workaround. This matches the mechanism in config: V2 silently ignores MCP servers defined directly under mcp instead of mcp.servers #56602.
    • Scalar timeout: setting all three phases (startup, catalog, execution) from a scalar is intentional. It keeps V1-style configs compatible (fix(core): accept numeric MCP timeouts #55851). But the schema doesn't say so, which is part of the docs problem.

    The script below runs opencode debug config on the three config shapes.

    Related: #56602, #50807 / #54184 (fixed by #55851), #23648.

    Reproduction script (repro.sh)
    #!/usr/bin/env bash
    # Reproduce #63092: MCP timeout normalization in `opencode debug config`.
    # Usage: OC="opencode" bash repro.sh   (or OC="bun ... packages/cli/src/index.ts")
    OC=${OC:-opencode}
    base=$(mktemp -d)
    run() {
      local name=$1 json=$2
      local d="$base/$name"; mkdir -p "$d"; echo "$json" > "$d/opencode.json"
      (cd "$d" && git init -q . && echo "=== $name ===" && $OC debug config --print-logs --log-level warn 2>&1 | grep -E 'mcp|"timeout"|startup|catalog|execution|normaliz' | head -30)
    }
    run flat-scalar '{"mcp":{"slow":{"type":"local","command":["/bin/true"],"timeout":60000}}}'
    run flat-object '{"mcp":{"s":{"type":"local","command":["/bin/true"],"timeout":{"startup":60000,"catalog":60000,"execution":43200000}}}}'
    run native-object '{"mcp":{"servers":{"s":{"type":"local","command":["/bin/true"],"timeout":{"startup":60000,"catalog":60000,"execution":43200000}}}}}'

    Run it: bash repro.sh

  2. ccclucky commented on Nov 10, 2026

    @ccclucky

    I'll take the config behavior part of this: keep a flat mcp.<name> server whose timeout uses the object form instead of dropping the whole entry.

    normalizeMcp decodes flat entries with the V1 schema, where timeout is a number, so an object there fails the decode and the server disappears with only a log warning. I'll read such an entry as a current server (mapping V1 enabled to disabled), mirroring the tolerance that already exists in the other direction — expandServerTimeouts accepts a bare number under mcp.servers.<name> so one V1-shaped field does not drop the server — and add regression tests in packages/core/test/config/normalization.test.ts.

    The wrong 5000 default text lives in the frozen V1 schema definitions that the published config.json still serves for the deprecated flat form, so that is a separate docs change; I'll keep this PR to the normalization behavior unless you would rather see both together.

  3. ccclucky commented on Nov 11, 2026

    @ccclucky

    #63166 now covers the config part I said I would take (accepting the per-server object form plus the corrected documented default), so I will not duplicate it. Leaving that half to #63166 and stepping back unless a maintainer wants the behaviour split out.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions