Back to the partner catalog

OpenCode — connect an AI agent through MCP

Connect OpenCode to Deskgram 2 MCP: local server URL, Bearer token, configuration and read-only tool checks.

OpenCode — connect an AI agent through MCP
AI and MCPAI agent

OpenCode is an AI agent that supports MCP servers. It can connect to Deskgram 2's local MCP server to access permitted tools, such as reading module schemas and task status. Configure the language model used by OpenCode separately.

Prepare Deskgram

Start Deskgram, open MCP settings, set a token, enable the listener and save. The default address is http://127.0.0.1:8765/mcp. If you changed the port, use that value in the agent configuration.

For the first check, keep read-only mode and enable only the tools you need. Use the actual MCP tool catalog to see what your installed version supports.

Configure OpenCode

Add the following server to your OpenCode configuration. Set the DESKGRAM_MCP_TOKEN environment variable to the token saved in Deskgram before starting the agent.

{
  "$schema": "https://opencode.ai/config.json",
  "mcp": {
    "deskgram": {
      "type": "remote",
      "url": "http://127.0.0.1:8765/mcp",
      "headers": { "Authorization": "Bearer {env:DESKGRAM_MCP_TOKEN}" },
      "oauth": false,
      "enabled": true
    }
  }
}

If the configuration already has MCP servers, add deskgram to the existing mcp object without replacing the others. oauth: false selects Bearer token access instead of automatic OAuth discovery.

127.0.0.1 refers to the computer or environment running OpenCode. Inside a container or on a remote server, it will not automatically point to Deskgram on your computer.

Check without launching tasks

Run opencode mcp list, then ask the agent to call deskgram_health and deskgram_list_modules. Inspect parameters with deskgram_get_module_schema, for example for profile_setup.

Reading a schema does not launch a module. Before creating a task, review the accounts, parameters, MCP permissions and execution mode. Write operations may require additional permissions; a listed tool is not necessarily enabled in the current settings.

OpenCode versus OpenRouter

OpenCode handles the conversation and MCP tool calls. OpenRouter provides access to language models. If OpenCode uses OpenRouter for its model, configure its key and billing separately. A key saved inside Deskgram does not configure the external agent or grant MCP access.

Troubleshooting and documentation

For connection failures, check that Deskgram and the listener are running and that the port and /mcp path match. For authorization failures, check the environment variable and Bearer header; restart OpenCode after changing its environment. A browser GET returning 405 does not test the MCP exchange: use the MCP client.

See OpenCode MCP documentation, Deskgram MCP and the separate OpenRouter guide.

Terms and disclosure

Model costs depend on the chosen provider. The button opens the official website without a referral code. This guide does not imply an official partnership.

Settings checked on 20 October 2026.

Open website