Connecting a Remote MCP Server to OpenCode

To add an MCP server to OpenCode, just follow these steps:

  • Open opencode.json config file for editing, e.g. nano .config/opencode/opencode.json on macOS.
  • Add the following section:
"mcp": {
"my-remote-mcp": {
"type": "remote",
"url": "https://my-mcp-server.com",
"enabled": true,
"headers": {
"Authorization": "Bearer MY_API_KEY"
}
}
}

If opencode.json already has data in it, make sure to paste the above after schema and to add a , after the last closing braces, or opencode will error out.

Sources:

https://opencode.ai/docs/mcp-servers

Unknown's avatar

About Ahmed Tawfik

Cybersecurity Professional, Systems Engineer, OSS & Linux Geek
This entry was posted in Linux and tagged , . Bookmark the permalink.

Leave a comment