Docs
Log in

About OpenCode

OpenCode is a terminal AI coding agent (similar in shape to Claude Code or Aider) with native support for the Model Context Protocol — both local stdio servers and remote HTTP servers, with OAuth and bearer-auth helpers for the remote variant. The Crawlbase MCP server is a local stdio server, so the local-config block below is what you want.

Install OpenCode

Skip this section if you already have OpenCode running. Otherwise the canonical install path is:

# macOS / Linux / WSL — one-liner installer
curl -fsSL https://opencode.ai/install | bash

# Or via npm / Homebrew / paru — see opencode.ai for details

Config file

OpenCode reads MCP servers from a JSON config alongside its other settings. Pick the scope that fits — global means every project you open with OpenCode sees the Crawlbase tools; per-project means only the repo that contains the file.

ScopePath
Global (all projects)~/.config/opencode/opencode.jsonc
Per projectopencode.jsonc (or opencode.json) in the project root

Configuration

{
  "$schema": "https://opencode.ai/config.json",
  "mcp": {
    "crawlbase": {
      "type": "local",
      "command": ["npx", "-y", "@crawlbase/mcp@latest"],
      "enabled": true,
      "environment": {
        "CRAWLBASE_TOKEN": "YOUR_TOKEN",
        "CRAWLBASE_JS_TOKEN": "YOUR_JS_TOKEN"
      }
    }
  }
}

Note the OpenCode-specific keys: mcp (not mcpServers), type: "local" (not "stdio"), command as an array of strings, and environment (not env). The Crawlbase MCP package on npm is the same one used by every other client — only the wrapping config schema differs.

Save the file and restart OpenCode. The Crawlbase tools surface as standard MCP tools the agent can pick up mid-conversation; you don't need to mention them by name in the prompt.

Usage in chat

Drop into an OpenCode session and ask for something that would benefit from live web context. The agent decides when to reach for the Crawlbase tools — you don't have to invoke them explicitly.

Pull the latest TanStack Query docs from
https://tanstack.com/query/latest and refactor our hooks
in src/hooks/useUser.ts to match the v5 API.

Patterns that work well

  • Live docs lookup: "Read the latest library docs and update our usage" — beats whatever's in the model's training cut-off.
  • Competitive analysis: "Look at how competitor implements feature on their public site, then propose an equivalent in our codebase."
  • Build-time scraping: one-off data fetches from inside an agent task — useful when the data is too transient or too target-specific to belong in your codebase.
Per-project config = per-project token

Drop an opencode.jsonc into a repo's root and that project gets its own Crawlbase token — useful when prod and dev workloads sit on different accounts, or when you want a teammate's checkout to use a shared service token instead of yours.