OpenCode
OpenCode reads its MCP servers from a single project-scope JSON file at the repo root. The shape differs from Claude Code / Cursor / Windsurf — pay attention to the keys.
Config file
Section titled “Config file”- Project:
opencode.json(oropencode.jsoncfor comments) at the repo root.
Snippet
Section titled “Snippet”{ "$schema": "https://opencode.ai/config.json", "mcp": { "codehub": { "type": "local", "command": ["codehub", "mcp"], "enabled": true } }}Three things differ from the typical Claude / Cursor shape:
- The top-level key is
mcp, notmcpServers. typeis required, set to"local"for stdio servers.commandis a single array containing the binary and its args — there is no separateargsfield.- The env-var key is
environment, notenv.
If you need env vars:
{ "$schema": "https://opencode.ai/config.json", "mcp": { "codehub": { "type": "local", "command": ["codehub", "mcp"], "enabled": true, "environment": { "LOG_LEVEL": "info" } } }}Verification
Section titled “Verification”- Restart OpenCode (or reload the workspace).
- Open a chat session.
- Ask:
which OpenCodeHub tools do you see? - Expect 29 tools under
mcp__opencodehub__*.
OpenCode logs MCP server stderr to its dev console — open it if the server fails to register.
Caveats
Section titled “Caveats”- The
$schemaURL gives you autocomplete and validation in editors that respect JSON Schema. Keep it. enabled: falsedisables the server without removing the entry — useful when triaging.- OpenCode supports stdio MCP servers; OpenCodeHub is stdio, so this matches.
Idiomatic prompts Five copy-paste prompts to test the wiring.