Connect OpenCode in the Terminal
Last modified by Vincent Massol on 2026/09/04 18:05
Tutorial
Connect the OpenCode terminal client to a wiki's MCP endpoint, from installing it to a working authenticated session. Read Agent Authentication for what the connected client is then allowed to do.
- Download and install OpenCode from the project's download page.
- Add the MCP server to OpenCode's configuration file — either
~/.config/opencode/opencode.jsoncor anopencode.jsoncfile in the root folder of your project — replacing the URL with your own endpoint URL.{ "$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 xwikiand open, in your browser, the URL it prints.
- Sign in and accept, then check the result: the browser reports the authorization as successful, and OpenCode is connected.

For further instructions, consult the OpenCode documentation on 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).