Skip to main content

Module opencode

Module opencode 

Source
Expand description

OpenCode (opencode): SPEC 7.3, 7.4 and 7.5.

  • User scope: $XDG_CONFIG_HOME/opencode/opencode.json (default ~/.config, on Windows too), or opencode.jsonc there when only that one exists. Both are JSONC; a new file starts with OpenCode’s $schema line.
  • Project scope: <P>/opencode.json[c], else an existing <P>/.opencode/opencode.json[c].
  • Entries: mcp.<name>: {type: "local", command: [cmd, ...args], environment, enabled} or {type: "remote", url, headers, enabled}. command is one array holding the command and its arguments. A remote entry reads as http unless its URL path ends in /sse (SPEC 7.5); an SSE server is written as a remote entry too, since OpenCode tries Streamable HTTP first and falls back to SSE. No cwd, no per-server tool filter.
  • enabled: false disables an entry; a project hides a user server with the whole entry and enabled: false (OpenCode merges project over user, SPEC 7.4).
  • Variables: OpenCode substitutes {env:NAME} anywhere in the file before parsing it; Surjection writes {env:NAME}.

Assumptions left for Tier C verification (scripts/verify-clients.md, OC-*): [verify] the user and project files (OC-1, OC-2, including which file wins when opencode.json and opencode.jsonc both exist), the remote fallback to SSE (OC-3), that a project entry with enabled: false hides the user entry (OC-4; Surjection writes the whole entry, as OpenCode validates each file on its own and a partial entry has no type), the deep merge of project over user entries (OC-5), that an entry without type is rejected (OC-6), that {env:NAME} is expanded in every field (OC-7), that any non-empty name loads (OC-8), that Windows starts npx without cmd /c (OC-9) and the detection probes (OC-10).

Structs§

OpenCodeJson
The mcp.<name> entry of an OpenCode config file (see the module docs).

Constants§

ID
SKELETON
The text of a new OpenCode config file.

Statics§

SPEC

Functions§

is_sse_url
Whether the path of url ends in /sse (query and fragment ignored, trailing slashes too), which makes a remote entry SSE (SPEC 7.5).