You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
MCP: invalid location of mcp when used --global #49904
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 serversinside that map (abridged; the command pretty-prints with expanded command arrays):
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:
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).
I reproduced this on current v2. The CLI always writes mcp.servers.<name>, while the config normalizer intentionally accepts both the legacy flat mcp.<name> shape and the native V2 nested shape.
I'm going to keep new/native configs on mcp.servers, but preserve an existing flat MCP map when adding another server so a shared global config does not become a mixed shape that 1.x cannot load. I'll add regression coverage for both shapes.
Implementation is now in #52667. It preserves an existing flat MCP map, while new/native V2 configs continue to use mcp.servers; the added tests cover both shapes and the real --global reproduction passes.
Thanks for the report! This is working as intended. In OpenCode V2, MCP servers go under mcp.servers, so opencode mcp add --global writes the correct shape:
The older shape, with servers directly under mcp, is from V1. V2 still reads those entries and migrates them, so existing configs keep working, but new entries use mcp.servers.
Activity
aanbrn commentedon Sep 30, 2026
Reproduced on 2.0.21 (macOS, arm64; Homebrew
opencode-v2). Adding--globalwritesmcp.servers— and when the config already has the flatmcpmap, it nestsserversinside that map (abridged; the command pretty-prints with expandedcommandarrays):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; no2.xversions are published under that name) and JetBrains' ACP integration (1.18.15) still distribute. A 1.x binary exits 1 against that config:A pure top-level
mcp.serversfails identically; a flatmcpmap 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 V2permissionsarray (Unrecognized key: permissions) and, once that is converted to the 1.xpermissionshape, on themcp.serversentry written bymcp add.Suggested fix: when the file uses the flat
mcpmap, write a flat entry (mcp.<name>) rather than adding aserverskey — 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
$schemais a hybrid V1 shape, so editors flag valid V2 configs).Keep the global MCP config loadable by both OpenCode lines (#466)
yaohuangguan commentedon Oct 2, 2026
I reproduced this on current
v2. The CLI always writesmcp.servers.<name>, while the config normalizer intentionally accepts both the legacy flatmcp.<name>shape and the native V2 nested shape.I'm going to keep new/native configs on
mcp.servers, but preserve an existing flat MCP map when adding another server so a shared global config does not become a mixed shape that 1.x cannot load. I'll add regression coverage for both shapes.yaohuangguan commentedon Oct 2, 2026
Implementation is now in #52667. It preserves an existing flat MCP map, while new/native V2 configs continue to use mcp.servers; the added tests cover both shapes and the real --global reproduction passes.
rekram1-node commentedon Oct 15, 2026
Thanks for the report! This is working as intended. In OpenCode V2, MCP servers go under
mcp.servers, soopencode mcp add --globalwrites the correct shape:{ "mcp": { "servers": { "my-server": { "type": "remote", "url": "https://mcp.example.com/mcp" } } } }The older shape, with servers directly under
mcp, is from V1. V2 still reads those entries and migrates them, so existing configs keep working, but new entries usemcp.servers.See the V2 docs for the full config reference: https://opencode.ai/v2/docs/mcp-servers
Closing this. If a server added this way doesn't connect, please open a new issue with your config and the output of
opencode mcp list.