
How to Add MCP Servers to opencode
opencode.aiOpen-source terminal coding agent from the SST team. MCP servers go in the `mcp` block of opencode.json — `"type": "local"` with a command array for stdio servers, `"type": "remote"` with a URL for hosted ones. A project-root opencode.json overrides the global config.
Setup Guide
1. Locate the config file
~/.config/opencode/opencode.json2. Add a server configuration
Add the following to your JSON config:
{
"$schema": "https://opencode.ai/config.json",
"mcp": {
"filesystem": {
"type": "local",
"command": ["npx", "-y", "@modelcontextprotocol/server-filesystem", "/path/to/allowed/dir"],
"enabled": true
},
"my-remote-server": {
"type": "remote",
"url": "https://my-mcp-server.example.com/mcp",
"enabled": true
}
}
}3. Restart opencode
Restart or reload opencode to pick up the new MCP server configuration.