Reproduced on 2.0.21 (macOS, arm64; Homebrew opencode-v2). Adding --global writes mcp.servers — and when the config already has the flat mcp map, it nests servers inside that map (abridged; the command pretty-prints with expanded command arrays):
mkdir -p /tmp/fh/.config/opencode
cat > /tmp/fh/.config/opencode/opencode.jsonc <<'JSON'
{ "$schema": "https://opencode.ai/config.json",
"mcp": { "github": { "type": "local", "command": ["gh", "mcp"] } } }
JSON
HOME=/tmp/fh opencode mcp add --global probe -- gh mcp
# the file then contains, under "mcp":
# "github": { "type": "local", "command": ["gh", "mcp"] }
# "servers": { "probe": { "type": "local", "command": ["gh", "mcp"] } }
Why it matters beyond the shape: the result is unloadable by the 1.x line — which is what npm opencode-ai@latest (1.18.34; no 2.x versions are published under that name) and JetBrains' ACP integration (1.18.15) still distribute. A 1.x binary exits 1 against that config:
Error: Configuration is invalid at /tmp/fh/.config/opencode/opencode.jsonc
↳ Expected { readonly "type": "local", ... } | { readonly "type": "remote", ... }, got {"probe":{"type":"local","command":["gh","mcp"]}} mcp.servers
↳ Missing key mcp.servers.enabled
A pure top-level mcp.servers fails identically; a flat mcp map exits 0 under 1.x. So the flat form — the one #52177 reports the 2.0.19 runtime reads, and the form a flat-shape project config uses — is the one both lines accept.
This broke IntelliJ IDEA's AI in practice: its ACP session launches opencode 1.18.15, which first exits on a V2 permissions array (Unrecognized key: permissions) and, once that is converted to the 1.x permission shape, on the mcp.servers entry written by mcp add.
Suggested fix: when the file uses the flat mcp map, write a flat entry (mcp.<name>) rather than adding a servers key — or, when the file already uses that map, warn before writing.
Related: #52177 (the V2 MCP docs page disagrees with the published schema and the runtime on this shape) and #43748 (the published $schema is a hybrid V1 shape, so editors flag valid V2 configs).