← Blog

BLOG

Claude Browser: Connect Claude to a Remote Chromium Session

Learn what a Claude browser setup involves, how to connect Claude workflows to remote Chromium with Playwright and CDP, and what to check before production.

9 min readRemote Browser
Ivory computer towers connected across terracotta platforms in a quiet desert landscape
The infrastructure behind your browserREMOTE BROWSER / ILLUSTRATION

A Claude browser setup usually means giving an application powered by Claude a way to inspect and interact with web pages. Claude does not connect to a Chrome DevTools Protocol (CDP) endpoint by itself: your application or agent framework must connect to a browser, expose useful observations and actions to Claude, and check the results. A hosted Chromium session can provide that browser without requiring Chrome to run on the same machine as your agent.

This guide explains the moving parts, shows how to connect Playwright to a remote browser over CDP, and covers the production decisions that affect reliability and security. The same architecture applies whether Claude is called from Claude Code, an application using an Anthropic API, or another agent framework.

What “Claude browser” means

The phrase can refer to several different things, so it is useful to separate the model from the browser runtime.

Claude is the reasoning component. It can interpret a task, choose among tools made available to it, and respond to the information those tools return. Chromium is the software that loads pages, stores browser state, and performs actions such as clicking and typing. Playwright is one way for application code to control Chromium. CDP is a protocol that lets compatible clients connect to a running Chromium instance.

A browser-enabled Claude workflow connects these pieces:

  1. Your application creates or obtains a browser session.
  2. Playwright connects to the session and reads the page state.
  3. Your application sends a focused observation to Claude.
  4. Claude selects an action through a tool or structured response.
  5. Your application validates and performs that action.
  6. Playwright checks what changed and reports the result.

This is not the same as installing a “Claude browser” or granting Claude unrestricted access to your computer. A browser workflow needs an explicit tool boundary, a runtime, and policies that govern what the agent may do.

Choose where Chromium runs

For a local experiment, Playwright can launch Chromium on the same machine as the agent. That is often the fastest way to verify the interaction loop. It also means your application is responsible for browser installation, operating-system dependencies, resource usage, cleanup, and any network access required by the browser.

A remote browser moves Chromium into a hosted session. Your application connects to it over CDP and continues to use familiar automation code. This can separate browser resources and session state from the agent process, and it can make live inspection and centralized session controls available. It also adds a network connection that must be secured and monitored.

ConsiderationLocal ChromiumHosted Chromium over CDP
SetupInstall and maintain browser dependenciesObtain a session and connection endpoint
ExecutionBrowser and agent share a machineBrowser runs in a separate environment
InspectionUsually local debugging toolsMay include a live session viewer
StateManaged by your applicationMay support isolated or persistent profiles
OperationsYou manage processes and capacityRuntime provider manages browser infrastructure
Connection riskMostly local process and permissionsCDP endpoint must be protected as a credential

A remote runtime does not make page behavior predictable by itself. Websites still change their markup, require authentication, rate-limit traffic, and sometimes present challenges that need human review. Treat remote execution as an infrastructure choice, not a guarantee that an agent will complete a task.

For more context, see remote browsers for AI agents and how remote browser sessions work.

Connect Playwright to a remote session

A hosted browser provider typically supplies a CDP WebSocket endpoint when a session is created. The exact process for creating a session, authenticating, and retrieving that endpoint depends on the provider. Keep the endpoint on the server side: anyone who can use it may be able to control the browser and inspect its state.

The following TypeScript example assumes that a session already exists and its endpoint is available in REMOTE_BROWSER_CDP_URL. It connects Playwright, reuses a context and page if the provider exposes them, then performs one navigation and reads a small observation.

import { chromium } from "playwright";

const endpoint = process.env.REMOTE_BROWSER_CDP_URL;

if (!endpoint) {
  throw new Error("REMOTE_BROWSER_CDP_URL is required");
}

const browser = await chromium.connectOverCDP(endpoint);

try {
  const context = browser.contexts()[0] ?? await browser.newContext();
  const page = context.pages()[0] ?? await context.newPage();

  await page.goto("https://example.com", {
    waitUntil: "domcontentloaded",
    timeout: 30_000,
  });

  const observation = {
    url: page.url(),
    title: await page.title(),
    text: (await page.locator("body").innerText()).slice(0, 8_000),
  };

  console.log(observation);
} finally {
  await browser.close();
}

Use a URL that you control when testing connectivity. For an authenticated workflow, use a dedicated test account and avoid logging cookies, authorization headers, or full page contents. Confirm the provider’s session lifecycle documentation before deciding whether closing the Playwright connection also ends the hosted session. In some setups, browser disconnection and session termination are separate operations.

The Playwright `connectOverCDP` documentation describes the client-side connection method. It is a Chromium-specific connection path; do not assume that the same CDP workflow applies to Firefox or WebKit.

Put a tool adapter between Claude and the page

The code above connects to a browser; it does not connect Claude to one. Your application needs to define what Claude can see and which actions it can request. Depending on your stack, that boundary might be an agent framework, a custom tool interface, or an MCP server that you have verified supports your browser runtime.

Avoid giving the model a raw CDP endpoint or asking it to produce arbitrary JavaScript to execute in the page. Instead, expose a small set of operations, such as:

  • get_page_summary: return the current URL, title, and relevant visible text.
  • click_element: accept a locator or application-defined target and check that it matches the expected element.
  • fill_field: fill a named field, with validation for sensitive values.
  • navigate: allow only permitted destinations.
  • request_confirmation: pause before a consequential action.

The application should own the browser connection, action validation, timeouts, and error handling. Claude should receive only the information needed for the current decision. For example, a summary of a results table is usually more useful than sending an entire page containing navigation, banners, and unrelated content.

A useful interaction loop is:

  1. Observe the page after navigation or a significant action.
  2. Ask Claude to choose a permitted next step.
  3. Validate the requested action against your policy.
  4. Execute one action with a bounded timeout.
  5. Observe again and verify the expected change.
  6. Stop, retry, or request human review if verification fails.

The observation step matters because successful execution of a click does not prove the intended result. The click might have targeted the wrong control, triggered a new tab, or done nothing because the page was still loading. Check a concrete outcome, such as a URL change, a success message, or an expected value appearing in the page.

Choose state deliberately

Browser state includes cookies, local storage, open tabs, and other data associated with a profile. A clean context is preferable when tasks should not inherit prior logins or preferences. A persistent profile can be useful when an agent must continue a workflow across sessions, but it increases the impact of a leaked session or mistaken action.

Decide which model fits each workflow:

  • Use an isolated session when each task should start independently.
  • Use a persistent profile when continuity is required and access is controlled.
  • Keep separate profiles for different users, tenants, or permission levels.
  • Set an explicit retention and cleanup policy for browser data.
  • Do not place production credentials in a shared test profile.

Session isolation is not the same as application authorization. Your server should still decide which user may create a session, which sites the agent may access, and which actions require approval. Review the provider’s profile, retention, and isolation behavior rather than inferring it from the word “session.”

Production checks for a Claude browser workflow

The browser connection is one part of the system. Before deploying, test the whole task loop under realistic network, page, and model conditions.

Bound every operation. Set timeouts for navigation, locators, and model calls. Limit the number of action-and-observation turns. A page that never reaches a requested state should produce a clear failure, not an unbounded retry loop.

Verify outcomes. Define a success condition for each task. For a form submission, that might be a confirmation message or a record visible on the next page. For a search, it might be a results heading plus at least one matching result. Avoid using “the click returned without error” as the success condition.

Control destinations and actions. Restrict navigation to expected domains where possible. Require confirmation before actions such as purchases, sending messages, deleting records, or changing account settings. Treat page content as untrusted input: a webpage can contain instructions that conflict with your application’s rules.

Manage credentials outside the prompt. Keep CDP endpoints, API keys, and account secrets in server-side secret storage. Pass a credential to the browser only when the workflow needs it. Do not include secrets in model context, application logs, screenshots, or error reports.

Make sessions observable. Record task IDs, session IDs, start and end times, action types, and failure reasons. Avoid capturing more page data than needed. A live viewer can help debug a stuck session, but access to that viewer should be controlled because it may expose authenticated pages.

Plan for failure. A remote session can disconnect, a website can change, or an action can time out after the page has already changed. Before retrying, inspect the current page and determine whether the action took effect. Retrying a payment or message submission blindly can duplicate a consequential operation.

For operational details about session management and access, consult the Remote Browser documentation. Check /pricing for current pricing and usage limits; do not build capacity assumptions around figures that may change.

When this approach fits

A remote Chromium workflow can fit Claude tasks that need access to a full browser, including navigating multi-page sites, working with authenticated web applications, or inspecting dynamic content. It is also useful when the agent process should not maintain local browser installations and when operators need a way to inspect a running session.

It may be unnecessary for a task that can be completed through a stable, supported API. APIs generally provide more explicit inputs and outputs than a graphical page, and they avoid some of the timing and layout variability of browser automation. Use a browser when the website interaction is required, not just because the model is capable of selecting browser actions.

The practical answer to “How do I use a Claude browser?” is to connect Claude’s tool-calling workflow to a browser runtime your application controls. Playwright over CDP is one way to drive hosted Chromium. Reliability comes from limiting the tool surface, managing session state, and verifying each meaningful result, not from the model name or the browser location alone.