Connect OpenCode in the Terminal

Last modified by superadmin on 2026/10/23 16:28

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. The browser sign-in in step 3 needs the XWiki OIDC Provider; the FAQ covers what to do without it.

  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 wiki's endpoint URL. Your administrator can copy that URL from the MCP administration page.
    {
      "$schema": "https://opencode.ai/config.json",
      "mcp": {
        "xwiki": {
          "type": "remote",
          "url": "https://<server>/<webapp>/rest/wikis/xwiki/aiLLM/mcp",
          "enabled": true
        }
      }
    }
  3. Run opencode mcp auth xwiki and open, in your browser, the URL it prints.

    The terminal after running opencode mcp auth xwiki, with the Authorize in your browser prompt and the URL below it highlighted

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

    The browser page confirming that the authorization was successful and that OpenCode is now connected to MCP, highlighted

FAQ

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

What if the auth command does not open a browser?

The browser sign-in needs the XWiki OIDC Provider on the wiki. Without it, there is no sign-in challenge to follow; an unauthenticated caller gets a bare 401 unless the wiki allows guest access. See Agent Authentication for how a client authenticates then, or ask your administrator for a client configuration.

Related

Get Connected