Connect OpenCode (Terminal) to MCP
Last modified by gabrielc on 2026/07/29 09:36
Tutorial
- Download and install OpenCode Terminal from the project's download page.
- Locate the OpenCode config file
- Either
~/.config/opencode/opencode.jsonc, - Or an
opencode.jsoncfile in the root folder of your project.
- Either
- Replace the URL in the following snippet with your MCP Server URL, then copy it over to your OpenCode configuration:
{
"$schema": "https://opencode.ai/config.json",
"mcp": {
"xwiki": {
"type": "remote",
"url": "https://xwiki.yourdomain.com/xwiki/rest/wikis/xwiki/aiLLM/mcp",
"enabled": true
}
}
}- Run
opencode mcp auth xwiki, and follow the authentication process.
For further instructions, please consult the OpenCode documentation related to MCP servers.
FAQ
I get an "MCP server not found" error when running the mcp auth command.
In the opencode mcp auth xwiki command, the last parameter is the name of the MCP server, and it should match the name inside your config file. If instead of "xwiki", you named your MCP server something else (e.g.: "xwiki-sales-wiki"), then the mcp auth command should reflect that as well (e.g.: opencode mcp auth xwiki-sales-team).