> ## Documentation Index
> Fetch the complete documentation index at: https://docs.zenrows.com/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> The Zenrows HTTP API serves Fetch and Extract (extract=auto) at https://api.zenrows.com/v1/, Crawl at https://api.zenrows.com/v1/crawls, and Batch at https://async.api.zenrows.com/v1. Fetch, Extract, Crawl and Batch are described in OpenAPI 3.1 at https://www.zenrows.com/openapi.json and listed in the RFC 9727 API catalog at https://www.zenrows.com/.well-known/api-catalog. Every endpoint also has its own page under /api-reference with its schema. Use the spec for exact parameter names and types. Crawl's endpoints, parameters and errors are also at https://docs.zenrows.com/crawl/endpoints.md. To call Zenrows from an agent, connect the MCP server at https://mcp.zenrows.com/mcp. To search these docs from an agent, connect the docs MCP server at https://docs.zenrows.com/mcp. Agent skills for Zenrows are published at https://github.com/ZenRows/cli and install with `npx skills add ZenRows/cli`.

# How to Integrate Zenrows with OpenCode

> Add the Zenrows MCP to OpenCode and let your AI coding agent browse the web and fetch web content reliably without anti-bot or JavaScript rendering limitations. Fetch live documentation, pull real API specs, and scrape technical references directly inside your coding session.

## 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

* A Zenrows API key from the Zenrows dashboard.

  [Open the Playground](https://app.zenrows.com/fetch)

## Getting started

### 1. Install OpenCode

**Windows / Linux / macOS:**

```bash theme={"theme":"css-variables"}
npm install -g opencode-ai
```

Or via the install script (Windows PowerShell / Linux):

```bash theme={"theme":"css-variables"}
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](https://opencode.ai/docs/#install) for all options.

OpenCode runs natively on Windows via PowerShell or Command Prompt. WSL is optional.

Verify the install:

```bash theme={"theme":"css-variables"}
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:

```text theme={"theme":"css-variables"}
/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](https://opencode.ai/docs/providers/).

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 JSON theme={"theme":"css-variables"}
{
  "$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"
      }
    }
  }
}
```

> [!NOTE]
>
> `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:

```bash theme={"theme":"css-variables"}
opencode
```

Then prompt it to use Zenrows:

```text wrap theme={"theme":"css-variables"}
Fetch https://www.scrapingcourse.com/antibot-challenge and summarize the page.
```

Or for a development-focused example:

```text wrap theme={"theme":"css-variables"}
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:

```bash theme={"theme":"css-variables"}
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 JSON theme={"theme":"css-variables"}
{
  "$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:

```text wrap theme={"theme":"css-variables"}
@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](https://opencode.ai/docs/agents/).

## 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 Markdown theme={"theme":"css-variables"}
## 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:**

```bash theme={"theme":"css-variables"}
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:**

```batch theme={"theme":"css-variables"}
for /f "delims=" %i in ('npm config get prefix') do set PATH=%i;%PATH%
```

**Windows PowerShell:**

```powershell theme={"theme":"css-variables"}
$env:PATH = "$(npm config get prefix)" + ";$env:PATH"
```

Alternatively, install via snap:

```bash theme={"theme":"css-variables"}
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:

```powershell theme={"theme":"css-variables"}
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.

[Open the dashboard](https://app.zenrows.com)

### 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 JSON theme={"theme":"css-variables"}
"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)

> [accordion] Should I add Zenrows to the project config or the global config?
>
> 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.

> [accordion] Can I use the local stdio version of Zenrows MCP instead?
>
> Yes. Replace the remote config with the local stdio format:
>
> ```json JSON theme={"theme":"css-variables"}
> {
>     "$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, except `account_signup_answer`, which only the local server has. The remote approach requires no local installation.

> [accordion] Can I connect multiple MCP servers alongside Zenrows?
>
> Yes. Add each server as a named block under `mcp`:
>
> ```json JSON theme={"theme":"css-variables"}
> {
>     "$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": {}
>         }
>     }
> }
> ```

> [accordion] Does Zenrows work with all LLM providers in OpenCode?
>
> Yes. Zenrows MCP works regardless of which provider you connect via `/connect`. The MCP layer is independent of the model.

> [accordion] Can I temporarily turn off Zenrows without removing it from the config?
>
> Yes. Set `enabled: false` in the Zenrows block:
>
> ```json JSON theme={"theme":"css-variables"}
> {
>     "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.

> [accordion] Does Zenrows work in OpenCode's Plan mode?
>
> 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.

> [accordion] Can I use Zenrows with OpenCode's built-in webfetch tool simultaneously?
>
> 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.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.