[Bug]: v2: plugin fails to load when the host doesn't deliver the MCP namespace draft during setup (regression from #1327)
What happened, and what did you expect?
Summary
After #1327, createV2Setup throws during setup:
Unable to snapshot configured MCP namespaces: this host cannot expose configured
MCP namespaces; update to a supported v2 host
(cause: Error: MCP transform did not produce a configuration snapshot)so the plugin refuses to load. v2.2.25 (pre-#1327) loads fine on the same host.
Symptom
Host log: msg="loading plugin" … immediately followed by
message="failed to load plugin" plugin.id=oh-my-opencode-slim cause="… Unable to snapshot configured MCP namespaces … (cause: Error: MCP transform did not produce a configuration snapshot)".
Root cause
src/v2/setup.ts reads the configured namespace inventory inside
ctx.mcp.transform((draft) => { const configured = draft.list(); hostMcpSnapshot = Object.fromEntries(configured); … })
and hard-fails when hostMcpSnapshot === undefined.
On v2 hosts the transform callback is deferred until the transform service materializes, so it does not run during setup → hostMcpSnapshot stays undefined → hard-fail. The agent path works around this by forcing the flush with ctx.agent.list(); the MCP path has no equivalent force, and ctx.mcp.list() reads already-materialized runtime entries — it neither flushes the transform nor exposes the configured draft.
Intent conflict (needs maintainer guidance)
#1327's body states the hard-fail is deliberate:
V2 MCP boundary — The registry snapshots configured MCP namespaces from the synchronous MCP transform draft before plugin mutation. The v2 API exposes no separate configuration read/materialization endpoint; if the host cannot supply that draft, setup fails instead of finalizing an empty policy.
The premise ("synchronous draft") does not hold on 2.0.18: the host exposes the API but does not deliver the callback during setup, so strict fail-loud makes the plugin unloadable. This issue asks whether the intended resolution is: (a) graceful degradation (finalize config-only when the draft is unavailable), or (b) a different way to obtain the configured inventory, or (c) something else.
Steps to reproduce
Minimal repro:
SMOKE=$(mktemp -d)
mkdir -p "$SMOKE/cfg/opencode" "$SMOKE/data/opencode" "$SMOKE/proj"
cat > "$SMOKE/cfg/opencode/opencode.json" <<EOF
{ "plugins": ["<repo>/dist/server"], "mcp": { "servers": { "x": { "type": "local", "command": ["true"], "disabled": true } } } }
EOF
cd "$SMOKE/proj" && XDG_CONFIG_HOME="$SMOKE/cfg" XDG_DATA_HOME="$SMOKE/data" \
opencode2 run --standalone --auto -m opencode/<free-id> --print-logs "Say OK." 2>&1 | grep -i "failed to load"oh-my-opencode.json
IrrelevantOpenCode version
2.0.18
oh-my-opencode-slim version
master
Operating system
macOS 26.6.2
Logs, screenshots, or extra context
Source: alvinunreal/oh-my-opencode-slim