opencodemcpconfiguration

opencode JSON + MCP Search Defaults

Configure opencode with MCP search for live web access. Set up opencode.json with search defaults for development and research workflows.

5 min read

Sensible opencode.json defaults should balance permissive file operations with guarded destructive commands, and include MCP tool configuration for web search to make the agent genuinely useful for research-heavy coding. Here is a production-tested configuration.

Permission Defaults

The permission structure should allow common read and build operations while requiring confirmation for anything destructive.

JSON
{
  "permission": {
    "bash": {
      "*": "allow",
      "rm *": "ask",
      "rm -rf *": "ask",
      "git push*": "ask",
      "git reset --hard*": "ask",
      "*--force*": "ask",
      "docker*rm*": "ask",
      "chmod*": "ask"
    },
    "edit": { "*": "allow" },
    "read": { "*": "allow" }
  }
}

Adding MCP Search Tools

Without web search, opencode works from training data only. It will confidently reference deprecated APIs, invent function signatures, and cite wrong package versions. Adding a search MCP tool fixes this.

JSON
{
  "mcp": {
    "servers": {
      "search": {
        "url": "https://mcp.scavio.dev/mcp",
        "headers": {
          "x-api-key": "your-api-key"
        }
      }
    }
  }
}

This gives opencode access to Google, Reddit, YouTube, Amazon, and Walmart search results. The agent can now verify package versions, check current API docs, and look up error messages before suggesting fixes. Free tier covers 250 searches per month, which handles casual development use.

Model and Context Settings

Set the model explicitly to avoid surprises when defaults change. Context window settings affect how much code the agent can reference at once.

JSON
{
  "model": "claude-sonnet-4-6",
  "context": {
    "max_tokens": 200000
  },
  "auto_compact": true
}

Complete Configuration

Combining permissions, MCP, and model settings into a single opencode.json that works for most development workflows.

JSON
{
  "permission": {
    "bash": {
      "*": "allow",
      "rm *": "ask",
      "git push*": "ask",
      "*--force*": "ask",
      "*--hard*": "ask",
      "docker*rm*": "ask"
    },
    "edit": { "*": "allow" },
    "read": { "*": "allow" }
  },
  "mcp": {
    "servers": {
      "search": {
        "url": "https://mcp.scavio.dev/mcp",
        "headers": { "x-api-key": "your-api-key" }
      }
    }
  },
  "model": "claude-sonnet-4-6",
  "auto_compact": true
}

What This Gets You

With these defaults, opencode can read and edit files freely, run most shell commands without prompting, verify facts against live web data, and pause before destructive operations. The MCP search integration is the single biggest quality improvement for coding agents that need to reference current documentation.