BLOG
Browser Use MCP: Connect AI Agents to Remote Chromium
Learn how browser use MCP connects AI clients to browser tools, and build a small Playwright MCP server backed by remote Chromium.

Browser use MCP is a way to make browser capabilities available to an AI client through the Model Context Protocol (MCP). An MCP server exposes tools; the client discovers and invokes them; and a browser automation implementation carries out the requested work in a browser session.
The key distinction is that MCP is the tool interface, not the browser. Browser Use can provide agent-oriented browser automation, while a runtime such as Remote Browser can provide hosted Chromium. You can also expose narrower Playwright operations through MCP without using the Browser Use library at all.
This guide explains those choices and builds a small TypeScript MCP server that reads a fixed page through a remote Chromium CDP connection. It is a Playwright example, not an official Browser Use MCP server.
How browser use MCP fits together
A browser use MCP integration usually has four responsibilities:
AI application or MCP client
|
| MCP tool discovery and calls
v
MCP server
|
| Browser automation or agent implementation
v
Browser Use, Playwright, or another controller
|
| CDP or another supported browser connection
v
Local or hosted browser sessionThe client decides when to call a tool. The MCP server defines the tool’s inputs and outputs. The browser controller translates the operation into browser actions. The runtime supplies the browser and its session lifecycle.
These layers can run in different places. For example, an MCP server can run next to a developer’s AI client while Chromium runs remotely. Alternatively, the server and browser can both run on infrastructure you control.
Browser Use versus an MCP browser tool
Browser Use is an agent-oriented browser automation project. A Browser Use-based MCP server could expose a high-level task tool that delegates work to a Browser Use agent. A different server might expose lower-level operations such as opening a page or reading text.
Those approaches have different control boundaries:
| Approach | What the MCP client invokes | Main advantage | Main trade-off |
|---|---|---|---|
| Browser Use-backed task tool | A task delegated to a Browser Use agent | Encapsulates a multi-step browser workflow | Another agent may make decisions inside the tool call; inspect its limits and outputs |
| Playwright-backed browser tools | Specific actions or reads implemented by the server | Explicit inputs, validation, and action boundaries | The client or your application must coordinate the workflow |
| Hosted browser API without MCP | Your application’s own browser integration | Fewer protocol components for application-owned workflows | An MCP client cannot discover those capabilities unless you add an adapter |
Tool names, installation commands, authentication, and remote-browser support depend on the particular MCP server and version. Check that server’s documentation rather than assuming that every browser use MCP implementation accepts the same settings.
Choose the tool boundary before writing configuration
The most important design decision is how much authority to give each tool.
A high-level tool such as complete_task might accept a natural-language instruction and allow an agent to navigate and interact with pages. That is convenient for exploratory work, but the server must define which sites and actions are permitted and when the agent must stop.
A narrower tool might accept an identifier, open a known page, and return selected fields. It is less flexible, but easier to test and constrain. For workflows involving accounts or transactions, separate reading from actions that change state.
Before choosing or building a browser use MCP server, check:
- Browser connection: Can it connect to the hosted browser using the protocol and authentication method your provider supplies?
- Tool surface: Does it expose an agent task, individual browser actions, or both?
- Session scope: Do tool calls share a browser session, or does each call create a new one?
- State: How are cookies, authenticated profiles, downloads, and artifacts handled?
- Action controls: Can you restrict destinations and require approval for writes?
- Outputs: Are results structured, size-limited, and suitable for the MCP client?
- Operations: How are timeouts, errors, cleanup, and session termination handled?
Remote Browser provides hosted Chromium sessions with CDP access, persistent profiles, session isolation, a live viewer, and configurable browser settings. Those capabilities address the runtime side of the integration; they do not by themselves define an MCP tool or authorize an agent’s actions.
Build a minimal Playwright MCP server
The following example exposes one tool, read_example_page. It connects to an existing Chromium session over CDP, opens a fixed public URL, and returns the page title and a short text excerpt.
This example demonstrates the MCP-to-remote-browser boundary. It does not install or invoke Browser Use. To use a Browser Use agent instead, implement the MCP tool handler using the Browser Use APIs supported by your chosen version, and verify its remote-browser configuration separately.
Prerequisites
You need:
- Node.js and npm.
- A hosted Chromium session that exposes a CDP connection URL.
- An MCP client that can launch a local server over standard input/output.
- Network access from the server to the CDP endpoint and from the browser to
https://example.com/.
Obtain the CDP URL using your browser provider’s documented session workflow. Treat it as a credential: a party with access to it may be able to control the browser. Do not paste a real endpoint into source control or a public issue.
Create a project and install the dependencies:
mkdir browser-mcp-example
cd browser-mcp-example
npm init -y
npm install @modelcontextprotocol/sdk playwright zod
npm install --save-dev typescript tsxSave this file as server.ts:
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
import { chromium } from "playwright";
import { z } from "zod";
const server = new McpServer({
name: "remote-browser-example",
version: "1.0.0",
});
server.registerTool(
"read_example_page",
{
description: "Read the title and a text excerpt from example.com.",
inputSchema: {
maxChars: z.number().int().min(100).max(3500).default(1500),
},
},
async ({ maxChars }) => {
const cdpUrl = process.env.CDP_URL;
if (!cdpUrl) {
return {
isError: true,
content: [{ type: "text" as const, text: "CDP_URL is not set." }],
};
}
let browser;
try {
browser = await chromium.connectOverCDP(cdpUrl, {
timeout: 15_000,
});
// This example expects an existing default Chromium context.
const context = browser.contexts()[0];
if (!context) throw new Error("No browser context available");
const page = await context.newPage();
try {
await page.goto("https://example.com/", {
waitUntil: "domcontentloaded",
timeout: 15_000,
});
const title = await page.title();
const body = (await page.locator("body").innerText()).slice(
0,
maxChars,
);
return {
content: [
{
type: "text" as const,
text: JSON.stringify({ title, url: page.url(), body }),
},
],
};
} finally {
await page.close();
}
} catch {
// Avoid returning endpoint credentials or raw browser errors.
return {
isError: true,
content: [
{
type: "text" as const,
text: "Could not read the page. Check the browser session and server logs.",
},
],
};
} finally {
if (browser) await browser.close().catch(() => {});
}
},
);
async function main() {
const transport = new StdioServerTransport();
await server.connect(transport);
}
main().catch(() => {
// stdout is reserved for MCP protocol messages.
console.error("MCP server failed to start");
process.exit(1);
});The example assumes the provider exposes a Chromium CDP endpoint compatible with Playwright’s connectOverCDP. See the Playwright CDP connection documentation for connection behavior and limitations.
The tool opens a page and closes it after the read. It also closes the Playwright browser connection in finally. Check your provider’s lifecycle semantics before using this pattern: closing or disconnecting a client may affect the remote session, and some providers require an additional explicit session-stop operation.
Connect the MCP client
MCP client configuration formats differ. The following illustrates a common local stdio configuration; use your client’s documented configuration location and field names. Replace the path and endpoint placeholder with values for your environment.
{
"mcpServers": {
"remote-browser-example": {
"command": "/ABSOLUTE/PATH/TO/browser-mcp-example/node_modules/.bin/tsx",
"args": ["/ABSOLUTE/PATH/TO/browser-mcp-example/server.ts"],
"env": {
"CDP_URL": "YOUR_PROVIDER_CDP_URL"
}
}
}
}Prefer your client’s secret-management mechanism or a protected environment over storing a live CDP URL in a shared configuration file. The placeholder is not a real endpoint, and the example does not assume a particular provider’s URL format.
Restart the client if required, then check that it discovers read_example_page. Invoke the tool with maxChars set to 500. A successful result should contain a JSON-formatted text response with a title, the resulting URL, and a bounded body excerpt.
This is deliberately a single-call example. It does not preserve a tab between calls or implement a reusable Browser Use agent session.
Troubleshoot the connection by layer
When browser use MCP does not work, first identify which connection failed.
| Symptom | Likely layer | What to check |
|---|---|---|
| Tool does not appear in the client | MCP startup | Executable path, client configuration, dependency installation, and server stderr |
CDP_URL is not set | Server environment | Whether the client passes the variable to the server process |
| Page read returns an error | CDP, session, or navigation | Session status, endpoint validity, network access, and provider diagnostics |
| No browser context is available | Browser/runtime | Whether the endpoint exposes an existing default context as the example expects |
| Tool runs but returns unexpected page content | Website or browser state | Redirects, authentication, page changes, and the final URL |
The sample intentionally avoids returning raw exceptions to the model because connection errors can contain sensitive URLs. For production, add protected, redacted diagnostics with a request identifier. Never log CDP credentials, cookies, or complete page contents by default.
Also distinguish a CDP endpoint from an MCP endpoint: they speak different protocols. An MCP client cannot use a Chromium CDP URL as though it were an MCP server URL.
Production controls for browser use MCP
A successful page read is a connectivity test, not a production security review. Browser content and tool arguments can both be untrusted.
Constrain navigation. The example uses a fixed URL rather than accepting arbitrary destinations. For broader browsing, enforce destination policy at the server and network layers. Account for redirects, DNS resolution, private and link-local addresses, and cloud metadata endpoints; checking only the initial URL is insufficient.
Separate reads from writes. A browser can submit forms, send messages, and change account settings. Expose sensitive actions as distinct tools, validate their parameters, and require human approval where appropriate. A page instruction telling the model to perform an action is not authorization.
Isolate sessions and profiles. Avoid sharing an authenticated browser context across unrelated users or jobs. Persistent profiles can save login state, but they also retain sensitive data. Define who owns each profile, how long it lives, and how it is revoked.
Bound execution and output. Apply navigation and overall tool timeouts, limit returned text and artifacts, and cap the number of browser actions in agent-driven workflows. The example limits navigation time and output size; a production implementation should also enforce an end-to-end deadline and concurrency controls.
Plan for cleanup and recovery. Track the relationship between an MCP request and its browser session. Decide who stops the session after errors, client disconnects, or timeouts, and verify that behavior against the provider’s API. Retries should not automatically repeat a state-changing action without checking whether it already succeeded.
Inspect failures without exposing data. A live viewer can help diagnose unexpected redirects, login screens, or broken page flows. Restrict viewer access and apply retention rules to screenshots, recordings, and logs. Use Remote Browser documentation to evaluate the session controls available for your deployment.
Where Remote Browser fits
For a browser use MCP deployment, Remote Browser can supply the hosted Chromium session while your chosen MCP server defines and enforces the tools. Its CDP access supports a Playwright connection like the one above; its persistent profiles and configurable browser settings can help when a workflow needs state or specific runtime configuration.
That does not make every MCP server automatically compatible. Confirm that the server supports the connection method your session provides, then test navigation, authentication, cleanup, and isolation with your own workload.
Start with a narrow read-only tool, verify the session lifecycle, and add capabilities only when you can define their permissions and failure behavior. For runtime background, see remote browsers for AI agents; for current service costs and limits, see pricing.