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

> ## Agent Instructions
> Anchor Browser is cloud browser infrastructure for AI agents and automation: browser sessions you control over CDP or REST, natural-language web tasks, versioned automation tasks, managed authentication into third-party web apps (identities with MFA), persistent volumes and profiles, recordings, live view, batch sessions, webhooks, and network options including residential proxies, extra stealth, and captcha solving for sites that block standard browsers. The for-agents page (https://docs.anchorbrowser.io/for-agents) covers authentication and the first API calls. API keys are created at https://app.anchorbrowser.io/api-keys. Append .md to any page URL for its Markdown version. The SDKs read the API key from ANCHORBROWSER_API_KEY, and REST calls send it in the anchor-api-key header. End every session you create with DELETE /v1/sessions/{id}, because a session is billed until it ends. Location targeting, captcha solving and managed authentication need the Starter plan, and extra stealth needs the Growth plan; on the Free plan, create a session with an empty body. Plans and limits are at https://docs.anchorbrowser.io/pricing. The hosted MCP server is https://api.anchorbrowser.io/v1/mcp.

# opencode

> Give opencode a cloud browser: connect the Anchor MCP server so it can run web tasks, drive sessions and use signed-in accounts.

Connect [opencode](https://opencode.ai) to Anchor's hosted MCP server. opencode can then run web tasks in plain English, open cloud browser sessions and work inside accounts you have signed in to.

Tested with opencode 1.19.6.

## Quick setup

Add the server from the terminal:

```bash theme={null}
opencode mcp add anchor --url https://api.anchorbrowser.io/v1/mcp
```

```text theme={null}
◆  MCP server "anchor" added to /Users/you/.config/opencode/opencode.json
```

Then sign in:

```bash theme={null}
opencode mcp auth anchor
```

opencode prints a sign-in link and opens it in your browser. Choose **Allow access** on the Anchor page, and the terminal confirms:

```text theme={null}
◇  Authorize in your browser:
●  https://signin.anchorbrowser.io/oauth2/authorize?response_type=code&client_id=...
◇  Authentication successful!
```

You are now connected to your default Anchor project.

Check the connection:

```bash theme={null}
opencode mcp list
```

```text theme={null}
●  ✓ anchor connected
│      https://api.anchorbrowser.io/v1/mcp
```

## Use an API key instead

For CI, a remote machine, or a project other than your default, send an API key instead of signing in. Create one at [API Keys](https://app.anchorbrowser.io/api-keys), export it as `ANCHORBROWSER_API_KEY`, and add the server with a header:

```bash theme={null}
opencode mcp add anchor --url https://api.anchorbrowser.io/v1/mcp --header 'anchor-api-key={env:ANCHORBROWSER_API_KEY}'
```

Keep the single quotes so your shell passes `{env:ANCHORBROWSER_API_KEY}` through unchanged. opencode reads the variable each time it connects, so the key itself is never written to the config file.

## Config file

The commands above write to `~/.config/opencode/opencode.json` (`opencode.jsonc` on some installs). This is what the API key setup looks like there:

```jsonc theme={null}
{
  "$schema": "https://opencode.ai/config.json",
  "mcp": {
    "anchor": {
      "type": "remote",
      "url": "https://api.anchorbrowser.io/v1/mcp",
      "headers": {
        "anchor-api-key": "{env:ANCHORBROWSER_API_KEY}"
      }
    }
  }
}
```

For sign-in, leave out the `headers` block. To share the server with a repository, put the same `mcp` block in an `opencode.json` at the project root.

## Try it

```text theme={null}
Use Anchor to open https://books.toscrape.com and return the title and price of the first five books.
```

```text theme={null}
Create an Anchor identity for https://linkedin.com and give me a link to sign in.
```

## Troubleshooting

* **Sign-in problems:** run `opencode mcp debug anchor`. It shows the auth status and whether the server answers.
* **Sign-in on a remote machine:** there is no browser to open. Use the API key setup.
* **401 with an API key:** confirm `ANCHORBROWSER_API_KEY` is exported in the shell that starts opencode.
* **`failed` in `opencode mcp list`:** check that the URL is exactly `https://api.anchorbrowser.io/v1/mcp`.

## Next steps

* [MCP servers and tools](https://docs.anchorbrowser.io/advanced/mcp.md): the three Anchor servers and what each tool does.
* [All integrations](https://docs.anchorbrowser.io/integrations/overview.md)


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