---
url: https://chartbuddy.io/hub/docs/connect-mcp/opencode.md
---
# Connect OpenCode

Wire **[OpenCode](https://opencode.ai)** to Chartbuddy Hub over local stdio MCP.

OpenCode config uses a top-level `mcp` key (not `mcpServers`). Local servers are `type: "local"` with the binary and args in one `command` array.

Prefer the **global** config so the absolute Chartbuddy path is not committed to a repo:

* Global: `~/.config/opencode/opencode.json` (or `.jsonc`)
* Project: `opencode.json` / `opencode.jsonc` in the repo root (avoid for Chartbuddy Hub — machine-specific path)

::: tip Agent path

1. Fetch [`/hub/llms.txt`](https://chartbuddy.io/hub/llms.txt) → [`mcp-setup.md`](https://chartbuddy.io/hub/mcp-setup.md) → [this page `.md`](https://chartbuddy.io/hub/docs/connect-mcp/opencode.md).
2. Do not load `llms-full.txt` by default.
   :::

## Config

Add a `chartbuddy` entry under `mcp`:

::: code-group

```json [Windows]
{
  "$schema": "https://opencode.ai/config.json",
  "mcp": {
    "chartbuddy": {
      "type": "local",
      "command": [
        "C:\\Users\\YOUR_USER\\AppData\\Local\\Programs\\Chartbuddy\\chartbuddy.exe",
        "--mcp"
      ],
      "enabled": true
    }
  }
}
```

```json [macOS]
{
  "$schema": "https://opencode.ai/config.json",
  "mcp": {
    "chartbuddy": {
      "type": "local",
      "command": [
        "/Applications/Chartbuddy.app/Contents/MacOS/chartbuddy",
        "--mcp"
      ],
      "enabled": true
    }
  }
}
```

:::

::: info Windows install
A public Windows Chartbuddy Hub build is not shipping yet. Use the **macOS** tab until it does, then replace `YOUR_USER` (or use the path shown after install).
:::

Keep **Chartbuddy Hub** running, restart OpenCode (or reload config), and start a new session if tools do not appear.

## Verify

::: code-group

```powershell [Windows]
& "$env:LOCALAPPDATA\Programs\Chartbuddy\chartbuddy.exe" --mcp-status
```

```bash [macOS]
/Applications/Chartbuddy.app/Contents/MacOS/chartbuddy --mcp-status
```

:::

Exit `0` = Chartbuddy Hub bridge up.

## Handoff

Optional context for a chat that will use the tools:

```text
Chartbuddy MCP is configured (stdio → chartbuddy --mcp → Chartbuddy Hub).
Transport: newline JSON-RPC or Content-Length framed MCP — not HTTP docs.
Open charts: list_charts (chart-* refs). get_active_chart skips menus/popovers.
Missing tools usually mean the chartbuddy MCP server is off for the chat, or a new chat is needed.
```
