Skip to main content

What is OpenCode?

OpenCode is an open-source AI coding agent available as a terminal UI, desktop app, or IDE extension. It connects to your codebase, understands your project structure, and helps you build features, refactor code, fix bugs, and navigate unfamiliar code, all from your editor or terminal. Like other AI coding tools, OpenCode can call external tools via MCP. Connect ZenRows and it gains reliable access to any web resource: protected documentation sites, JavaScript-rendered API references, paywalled technical content, and any page that would otherwise return a blocked or empty response.

Why connect ZenRows to OpenCode?

  • Fetch live docs that block automated requests. Many documentation sites (Cloudflare, AWS, Stripe, and others) return challenges or empty pages to automated clients. ZenRows bypasses that so OpenCode gets the actual content.
  • Pull real API responses, not cached snapshots. When OpenCode needs to understand an external API, ZenRows fetches the live spec or reference page rather than relying on potentially stale training data.
  • Research technical content during a coding session. Ask OpenCode to scrape Stack Overflow threads, GitHub issues, technical blogs, or framework changelogs and incorporate the findings directly into the task it’s working on.
  • Access JavaScript-rendered pages. Developer tools, dashboards, and interactive docs often require JavaScript to render their content. ZenRows handles that automatically.

What you can build

  • Live documentation lookup during development. Ask OpenCode to fetch the latest docs for a library you’re integrating and use them to generate correct, up-to-date code, not code based on training data that may be months old.
  • Automated competitor or dependency research. Have OpenCode scrape changelogs, release notes, or breaking change announcements across your key dependencies and summarize what needs updating in your project.
  • Technical reference extraction. Describe a problem and let OpenCode scrape relevant Stack Overflow threads, GitHub issues, or RFC documents to inform its solution.
  • Live API testing context. Before generating integration code, have OpenCode scrape the target API’s reference page to confirm endpoint signatures, auth patterns, and response shapes.

Prerequisites

Getting started

1

Install OpenCode

Windows / Linux / macOS:
npm install -g opencode-ai
Or via the install script (Windows PowerShell / Linux):
curl -fsSL https://opencode.ai/install | bash
Other options: Homebrew (brew install anomalyco/tap/opencode), Chocolatey (choco install opencode), Scoop (scoop install opencode). See the full install guide for all options.OpenCode runs natively on Windows via PowerShell or Command Prompt. WSL is optional.Verify the install:
opencode --version
2

Connect an LLM provider

OpenCode needs an LLM provider to process your prompts and call tools like ZenRows. Run the /connect command inside OpenCode and select your provider:
/connect
For Anthropic, select Anthropic, enter your API key, then run /models to pick a model like claude-sonnet-4-6. For other providers, see the OpenCode full provider guide.Once a model is selected, you’re ready to add ZenRows.
3

Add ZenRows MCP to OpenCode

ZenRows connects as a remote MCP server. You’ll need to create an opencode.json config file and add it under the mcp key.Create the file at one of these locations depending on your preferred scope:
  • Project-level (opencode.json in your project root): ZenRows available only in this project.
  • Global (~/.config/opencode/opencode.json): ZenRows available across all projects.
If neither file exists yet, create it. Then paste the following:
JSON
{
  "$schema": "https://opencode.ai/config.json",
  "mcp": {
    "zenrows": {
      "type": "remote",
      "url": "https://mcp.zenrows.com/mcp",
      "oauth": false,
      "enabled": true,
      "headers": {
        "Authorization": "Bearer YOUR_ZENROWS_API_KEY"
      }
    }
  }
}
oauth: false is required. Without it, OpenCode’s automatic OAuth detection will intercept the request before the Bearer token header is sent.
4

Try it out

Start OpenCode in your project:
opencode
Then prompt it to use ZenRows:
Fetch https://www.scrapingcourse.com/antibot-challenge and summarize the page.
Or for a development-focused example:
Use zenrows to scrape https://github.com/vercel/next.js/issues and find open issues related to hydration errors. Summarize the most common causes and suggested fixes.
OpenCode will call the right ZenRows tool and incorporate the response directly into its reply.

Scoping ZenRows to a specific agent (optional)

OpenCode supports custom agents: specialized AI assistants with their own prompts, models, and tool access. You can create one using:
opencode agent create
Then follow the interactive prompts to create one. If you want ZenRows available only to a specific agent and not the default build agent, turn off the ZenRows tools globally using the permission key and re-enable them per agent:
JSON
{
  "$schema": "https://opencode.ai/config.json",
  "mcp": {
    "zenrows": {
      "type": "remote",
      "url": "https://mcp.zenrows.com/mcp",
      "oauth": false,
      "enabled": true,
      "headers": {
        "Authorization": "Bearer YOUR_ZENROWS_API_KEY"
      }
    }
  },
  "permission": {
    "zenrows_*": "deny"
  },
  "agent": {
    "researcher": {
      "description": "Web research agent with ZenRows access",
      "mode": "subagent",
      "permission": {
        "zenrows_*": "allow"
      }
    }
  }
}
The researcher agent is now the only one that can call ZenRows tools. Invoke it by @ mentioning it in your session:
@researcher scrape https://github.com/vercel/next.js/issues and find open issues related to hydration errors.
For more on creating and configuring agents, see the OpenCode agents docs.

Add a ZenRows instruction to your agent file (optional)

When you run opencode agent create and follow the interactive prompts, OpenCode generates a markdown agent file at .opencode/agents/<agent-name>.md. The file has a frontmatter block for config and a body for the system prompt. Add the ZenRows instruction to the Guidelines section of the body if one exists, or anywhere in the prompt body if not. For example:
Markdown
## Guidelines

- Use `zenrows_scrape` for fast, single-page fetches
- Use `zenrows_browser_*` tools when pages require complex navigation or user interaction
This tells the agent to use ZenRows when automatically fetching external content, so you don’t need to specify it in every prompt.

Troubleshooting

Command ‘opencode’ not found after install

The npm global bin directory isn’t in your PATH. Fix it by adding it. Linux / macOS:
export PATH="$(npm config get prefix)/bin:$PATH"
Add that line to your ~/.bashrc or ~/.zshrc to make it permanent, then run source ~/.bashrc. Windows CMD:
for /f "delims=" %i in ('npm config get prefix') do set PATH=%i;%PATH%
Windows PowerShell:
$env:PATH = "$(npm config get prefix)" + ";$env:PATH"
Alternatively, install via snap:
sudo snap install opencode

ERROR: CreateProcessCommon: execvpe(/bin/bash) failed: No such file or directory on Windows

This means WSL is installed, but no proper Linux distro is set up. The docker-desktop distro that ships with Docker Desktop is headless and doesn’t provide a usable shell. You have two options: Install a proper WSL distro:
wsl --install -d Ubuntu
Or skip WSL entirely. OpenCode runs natively on Windows via PowerShell without needing WSL.

ZenRows tools not appearing in OpenCode

  • Confirm enabled: true is set in the ZenRows MCP block.
  • Check that ZENROWS_API_KEY is correct.
  • Restart OpenCode after saving the config.
  • Run opencode mcp list to see all registered MCP servers and their status.

Authentication error when calling ZenRows tools

Verify your API key is active in the ZenRows dashboard. Also confirm oauth: false is in your config. Without it, OpenCode’s OAuth auto-detection will intercept the connection before the Bearer token is applied.

OpenCode not using ZenRows even when available

Be explicit in your prompt: use zenrows to fetch https://www.scrapingcourse.com/antibot-challenge. Alternatively, add an instruction in your <agent-file.md> to set ZenRows as the default tool for external web fetches.

Context limit warnings after adding ZenRows

ZenRows adds its full tool list to the context on every request. If you’re hitting context limits, restrict OpenCode to only the tools you need using glob patterns in the tools config:
JSON
"tools": {
  "zenrows_browser_*": false
}
This turns off all browser automation tools and keeps only zenrows_scrape active. Or switch to a model with a larger context window.

FAQ (Frequently asked questions)

Use project config to make ZenRows available only when working in a specific codebase. Use global config if you want it available across all your OpenCode sessions. The project config takes precedence over the global config when both are present.
Yes. Replace the remote config with the local stdio format:
JSON
{
    "$schema": "https://opencode.ai/config.json",
    "mcp": {
        "zenrows": {
            "type": "local",
            "command": ["npx", "-y", "@zenrows/mcp"],
            "enabled": true,
            "environment": {
                "ZENROWS_API_KEY": "YOUR_ZENROWS_API_KEY"
            }
        }
    }
}
Both options expose the same tools. The remote approach requires no local installation.
Yes. Add each server as a named block under mcp:
JSON
{
    "$schema": "https://opencode.ai/config.json",
    "mcp": {
        "zenrows": {
            "type": "remote",
            "url": "https://mcp.zenrows.com/mcp",
            "oauth": false,
            "enabled": true,
            "headers": {
                "Authorization": "Bearer YOUR_ZENROWS_API_KEY"
            }
        },
        "sentry": {
            "type": "remote",
            "url": "https://mcp.sentry.dev/mcp",
            "oauth": {}
        }
    }
}
Yes. ZenRows MCP works regardless of which provider you connect via /connect. The MCP layer is independent of the model.
Yes. Set enabled: false in the ZenRows block:
JSON
{
    "mcp": {
        "zenrows": {
            "type": "remote",
            "url": "https://mcp.zenrows.com/mcp",
            "oauth": false,
            "enabled": false,
            "headers": {
                "Authorization": "Bearer YOUR_ZENROWS_API_KEY"
            }
        }
    }
}
Restart OpenCode, and the server won’t load. Flip it back to true when you need it again.
Plan mode restricts file edits and bash commands but doesn’t restrict MCP tool calls by default. ZenRows scraping tools remain available in Plan mode unless you explicitly deny them via the permission config.
Yes, they coexist. webfetch is OpenCode’s native HTTP fetch tool, useful for simple, unprotected pages. ZenRows is better for pages behind bot protection, JavaScript rendering, or geo-restrictions. OpenCode will reach for whichever tool you specify, or make its own judgment if you don’t specify one.