Wiki source code of Connect OpenCode in the Terminal
Last modified by Vincent Massol on 2026/09/04 18:05
Show last authors
| author | version | line-number | content |
|---|---|---|---|
| 1 | Connect the OpenCode terminal client to a wiki's MCP endpoint, from installing it to a working authenticated session. Read [[Agent Authentication>>doc:documentation.extensions.user.llm.mcp-server.agent-authentication.WebHome]] for what the connected client is then allowed to do. | ||
| 2 | |||
| 3 | 1. Download and install OpenCode from the project's [[download page>>https://opencode.ai/download]]. | ||
| 4 | 1. Add the MCP server to OpenCode's configuration file — either {{code}}~/.config/opencode/opencode.jsonc{{/code}} or an {{code}}opencode.jsonc{{/code}} file in the root folder of your project — replacing the URL with your own endpoint URL.((( | ||
| 5 | {{code language="json"}} | ||
| 6 | { | ||
| 7 | "$schema": "https://opencode.ai/config.json", | ||
| 8 | "mcp": { | ||
| 9 | "xwiki": { | ||
| 10 | "type": "remote", | ||
| 11 | "url": "https://xwiki.yourdomain.com/xwiki/rest/wikis/xwiki/aiLLM/mcp", | ||
| 12 | "enabled": true | ||
| 13 | } | ||
| 14 | } | ||
| 15 | } | ||
| 16 | {{/code}} | ||
| 17 | ))) | ||
| 18 | 1. Run {{code}}opencode mcp auth xwiki{{/code}} and open, in your browser, the URL it prints.((( | ||
| 19 | {{image reference="opencode-auth-command.png" size="extra" alt="The terminal after running opencode mcp auth xwiki, with the Authorize in your browser prompt and the URL below it highlighted"/}} | ||
| 20 | ))) | ||
| 21 | 1. Sign in and accept, then check the result: the browser reports the authorization as successful, and OpenCode is connected.((( | ||
| 22 | {{image reference="opencode-authorized.png" size="large" alt="The browser page confirming that the authorization was successful and that OpenCode is now connected to MCP, highlighted"/}} | ||
| 23 | ))) | ||
| 24 | |||
| 25 | For further instructions, consult the [[OpenCode documentation>>https://opencode.ai/docs/mcp-servers/]] on MCP servers. |