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.

  1. Download and install OpenCode from the project's download page.
  2. Add the MCP server to OpenCode's configuration file — either ~/.config/opencode/opencode.jsonc or an opencode.jsonc file 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
        }
      }
    }
  3. Run opencode mcp auth xwiki and open, in your browser, the URL it prints.

    opencode-auth-command.png

  4. Sign in and accept, then check the result: the browser reports the authorization as successful, and OpenCode is connected.

    opencode-authorized.png

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).

 

Related

Get Connected