To add an MCP server to OpenCode, run opencode mcp add <name> --env KEY=value -- <command> for a local package.
Steps
- Run
opencode mcp add <name> --env KEY=value -- <command>for a local package. - Or add it under
mcpinopencode.json:"type": "local"with acommandarray, or"type": "remote"with aurl.
Checked against OpenCode's official MCP documentation on 2026-12-01.
Copy-paste examples
Example: Playwright MCP (local package)
OpenCode
opencode mcp add playwright-mcp -- npx -y @playwright/mcpOpenCode (opencode.json)
{
"mcp": {
"playwright-mcp": {
"type": "local",
"command": [
"npx",
"-y",
"@playwright/mcp"
]
}
}
}From the Playwright MCP server page.
Example: GitHub (hosted (remote) server)
OpenCode (opencode.json)
{
"mcp": {
"github-mcp-server": {
"type": "remote",
"url": "https://api.githubcopilot.com/mcp/"
}
}
}From the GitHub server page.
Find a server
Every server page on getmcpindex has a ready-made setup for OpenCode under Set up in your MCP client. Search all servers, browse categories or remote servers.