OpenCode is an open-source AI coding agent by Anomaly that runs in the terminal with support for multiple AI models. Its MCP configuration differs from the canonical format in several meaningful ways: the root key is mcp instead of mcpServers, stdio servers use an array-format command that merges the command binary and all its arguments into a single list, and environment variables go in an environment field instead of env. Each server also requires an explicit type field (local for stdio servers, remote for HTTP). OpenCode uses JSONC format (JSON with comments), allowing you to annotate your config. Project-level configuration lives in opencode.json at the repository root and can be committed to version control.
The fastest way to install MCP servers in OpenCode is with the getmcp CLI:
npx @getmcp/cli add <server-id>Example configuration for the github server:
{
"mcp": {
"brave-search": {
"type": "local",
"command": [
"npx",
"-y",
"@brave/brave-search-mcp-server"
],
"enabled": true,
"environment": {
"BRAVE_API_KEY": ""
}
}
}
}