Skip to content

feat: Add OpenCode MCP configuration support #21

Description

@nazt

Problem

OpenCode uses a different MCP configuration format than Claude Code. Currently:

  1. Install script only supports Claude Code - Uses claude mcp add command
  2. No global config documentation - OpenCode requires manual ~/.config/opencode/opencode.jsonc
  3. MCP disappears in OpenCode - When not in a project directory with opencode.jsonc

Symptoms in OpenCode

  • "0 MCP" shown in status bar
  • Oracle shows as "failed" or "Disabled"
  • MCP works in some directories but not others

Root Cause

OpenCode MCP config is per-project by default, unlike Claude Code which loads from ~/.claude.json globally. Without a global config at ~/.config/opencode/opencode.jsonc, MCP servers don't load.

Config Format Differences

Aspect Claude Code OpenCode
Config file ~/.claude.json ~/.config/opencode/opencode.jsonc
MCP key mcpServers.name mcp.name
Type field Not required "type": "local" required
Command format "command": "bun", "args": [...] "command": ["bun", "..."]
Global config Automatic Must create manually

Working OpenCode Config

// ~/.config/opencode/opencode.jsonc
{
  "$schema": "https://opencode.ai/config.json",
  "mcp": {
    "oracle": {
      "type": "local",
      "command": [
        "/Users/USERNAME/.bun/bin/bun",
        "/Users/USERNAME/.local/share/oracle-v2/src/index.ts"
      ],
      "enabled": true,
      "environment": {
        "PATH": "/Users/USERNAME/.bun/bin:/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin"
      }
    }
  }
}

Key requirements:

  • Use full paths (no ~ expansion in command array)
  • Add PATH environment variable
  • Use array format for command

Proposed Changes

1. Separate Install Scripts

Keep editor configurations optional and separate from main install:

scripts/
├── install.sh              # Main install (clone + bun install only)
├── setup-claude.sh         # Claude Code MCP config (optional)
└── setup-opencode.sh       # OpenCode MCP config (optional)

Benefits:

  • Cleaner main install - just installs the code
  • User choice - run only the setup script for their editor
  • Easier maintenance - each editor's quirks in separate files
  • No bloat - don't check for editors user doesn't have

Usage:

# Install oracle-v2
curl -sSL .../install.sh | bash

# Then configure for your editor:
~/.local/share/oracle-v2/scripts/setup-claude.sh   # Claude Code users
~/.local/share/oracle-v2/scripts/setup-opencode.sh # OpenCode users

2. Add docs/OPENCODE.md

Full documentation for OpenCode users covering:

  • Why global config is needed
  • Config format differences
  • Troubleshooting common issues
  • Full working example

3. Update README.md

Add OpenCode section to Install documentation with link to docs/OPENCODE.md

Testing

Verified fix on 2026-01-19:

  1. Created ~/.config/opencode/opencode.jsonc with config above
  2. Restarted OpenCode
  3. Oracle MCP now loads from any directory

Related

  • Discovered while debugging "MCP disappearing" issue in OpenCode
  • Oracle learning: 2026-01-19_opencode-mcp-global-config-required

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentationenhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions