agent-browser-mcp
Control and automate a real Chrome/Edge browser for AI agents using semantic refs and resilient sessions.
Navigate URLs and receive interactive-element snapshots with
[eN]refs.Take semantic page snapshots, filtered to interactive/text content or scoped by ref/selector.
Click, type, press keys, select dropdown options, hover, and scroll.
Capture screenshots of the viewport, full page, or a specific element.
Run JavaScript in the page as an escape hatch.
Wait for time, text, selector, URL changes, or network idle.
Manage tabs: list, open, select, and close.
Inspect browser health, tabs, restart count, errors, dialogs, and downloads.
Close the browser while keeping profile logins; the next call can restart it.
Use a persistent launch profile or connect to an existing browser with a debugging port.
Recover from closed/crashed browsers with lazy restart, tab restoration, orphan cleanup, and timeout guards.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@agent-browser-mcp Go to news.ycombinator.com and click the top story"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
browser-ref-mcp
A reliable browser-control MCP server for AI agents. Click by ref, not by brittle CSS selectors — and when the browser dies, the next call just brings it back.
Built for the two things that actually break agent-driven browsing:
The problem | What happens with most browser tools | What this server does |
The agent can't click what it sees | Selectors go stale between snapshot and click, shadow DOM and cross-origin iframes are invisible, the agent retries blindly | Semantic snapshot with |
Sessions keep dying | Browser closed by hand, process crash, port conflict — and the agent is stuck until you restart everything | Resident process, lazy restart on next call, tab session restored, orphan cleanup, timeout guardrails |
No browser download. It drives the Chrome or Edge you already have, via playwright-core.
Works with Claude Code, Claude Desktop, Cursor, Cline, Codex CLI, Windsurf, OpenClaw, and any client that speaks stdio MCP.
Quick start
Claude Code
/plugin install browser-ref-mcp --marketplace zy2755/browser-ref-mcpOne line installs the server plus a short skill that tells Claude when to reach for the browser and what to do when a ref goes stale.
LobeHub Skills marketplace
npx -y @lobehub/market-cli skills install zy2755-browser-ref-mcp-browser-control --agent claude-codeAlso listed as an MCP server at lobehub.com/mcp/zy2755-browser-ref-mcp.
Where else it's listed
punkpeye/awesome-mcp-servers — listed under "Web content access and automation"
mcpservers.org — directory listing with install and config walkthroughs
Glama — rated A for tool definitions, all 14 tools indexed
cursor.directory — Cursor plugin directory
Any other client
npx -y browser-ref-mcpOr add it to your client config:
{
"mcpServers": {
"browser-ref-mcp": {
"command": "npx",
"args": ["-y", "browser-ref-mcp"]
}
}
}Restart the client completely (on macOS quit from the menu bar — closing the window does not reload config).
git clone https://github.com/zy2755/browser-ref-mcp.git
cd browser-ref-mcp
npm install && npm run buildThen point command at node and args at the absolute path of dist/index.js — GUI apps often don't inherit your shell's working directory, so relative paths tend to fail:
{
"mcpServers": {
"browser-ref-mcp": {
"command": "node",
"args": ["/absolute/path/to/browser-ref-mcp/dist/index.js"]
}
}
}Config file locations:
Claude Desktop — macOS:
~/Library/Application Support/Claude/claude_desktop_config.json, Windows:%APPDATA%\Claude\claude_desktop_config.jsonCursor —
~/.cursor/mcp.json, or Settings → Features → MCPClaude Code —
claude mcp add, or the samemcpServersshape
Related MCP server: ecobrowser MCP server
The 14 tools
Tool | What it does |
| Navigate — automatically returns an interactive-element snapshot |
| Semantic snapshot. |
| Click by ref, returns a fresh snapshot. Stale refs are re-resolved automatically |
| Type into a field (clears first). |
| Key press, e.g. |
| Pick |
| Hover to reveal hover-only menus |
| Scroll the page, or a specific scroll container |
| Screenshot — returns the image and writes it to disk |
| Escape hatch: run JS in the page |
| Wait for a duration, text, element, URL change, or network idle |
| Multi-tab: |
| Health state, tab list, restart count, last error |
| Close the browser (profile logins are kept) |
Using refs
Every interactive element in a snapshot carries an [eN] label:
[e38] link "Sign in"
[e42] textbox "Email"
[e51] button "Continue"So the agent calls browser_click({ "ref": "e42" }) — no selector guessing, no DOM archaeology. Elements inside iframes are flattened into the same tree with the same numbering, including across origins.
How clicking actually works
Most "click by selector" failures come from the page changing between the moment the agent reads it and the moment it clicks. This server separates reading from locating:
Semantic snapshot — an in-page DOM walk (accessibility role + accessible name +
cursor: pointerheuristics) that pierces open shadow DOM and flattens cross-origin iframe content into a single tree.Ref → locator recipe — each ref stores both a CSS path (id-anchored +
nth-of-type, unique within its frame) and a role+name semantic description.Resolution fallback chain —
cssPath→getByRoleexact →getByRolefuzzy →getByText. Anything that hits is validated before use.Never a dead end — if a ref is truly dead, the error message tells the agent what to do next (re-snapshot, or wait first) instead of leaving it stuck in a retry loop.
How reconnection works
Process model — the MCP server itself is a resident daemon (stdio clients hold it open). The browser launches over a CDP pipe, not a websocket port, so there are no port conflicts.
Lazy restart — a health check runs before every tool call (
browser.isConnected()). If the browser was closed by hand or crashed, the next call relaunches it and restores all tabs, explicitly telling the agent that old refs are invalid.Orphan cleanup — if a leftover process is holding the profile, it is killed by profile path before retrying.
Hang guardrails — every Playwright call is wrapped in
withTimeout, so a frozen browser returns a timeout instead of hanging forever.Full-chain logging —
~/.browser-mcp/logs/server-YYYYMMDD.log(2 MB rotation, 3 files kept).browser_get_infoexposes the last error and restart count.
Browser modes
launch mode (default) — starts a dedicated Chrome with its profile at ~/.browser-mcp/profile. Logins persist across restarts. You sign in to a given site once in this profile.
connect mode — attach to an already-running browser that has a debugging port open; it is not killed on exit:
# start Chrome with a debugging port first
chrome.exe --remote-debugging-port=9222
node dist/index.js --connect # defaults to http://127.0.0.1:9222
node dist/index.js --cdp-url http://127.0.0.1:9223Configuration
Precedence: CLI args > env vars (BROWSER_MCP_*) > ~/.browser-mcp/config.json > built-in defaults.
Common flags: --headless / --profile <dir> / --channels chrome,msedge / --executable <path> / --viewport 1440x900 / --start-url <url> / --dialogs accept|dismiss (default accept).
Append them after the package name:
"args": ["-y", "browser-ref-mcp", "--headless", "--channels", "msedge"]Full list: npx -y browser-ref-mcp --help.
Don't set
executablePathunless you have to. Once it is set, thechannelsfallback chain (chrome→msedge) is skipped and only that single candidate remains — which lowers robustness across machines.
Security notes
The dedicated profile holds live logins (cookies) — it is your browser identity. Never commit
~/.browser-mcp/profileto any repository.Page dialogs are auto-accepted by default. The agent cannot handle CAPTCHAs or payment flows; those still need a human.
Logs may contain page URLs including query parameters — clean them up after debugging.
Roadmap
File upload, richer download management, request interception, cookie/storage management, PDF export, a CLI front end.
License
Available Tools
14 toolsbrowser_clickA
Click an element (prefer the ref from a snapshot). Waits until it is actionable, re-resolves refs that went stale, and returns a fresh snapshot afterwards. Dialogs are handled and reported automatically.
Inputs: ref, text, button, selector, +3 more.
browser_closeA
Close the browser (launch mode quits it but keeps profile logins; connect mode only disconnects). The next tool call restarts it automatically.
Inputs: no named parameters.
browser_evaluateA
Escape hatch: run JS in the page and return a JSON-serializable result. Pass a function string such as () => document.title or () => {...}; with a ref the function runs on that element as (el) => el.value.
Inputs: js (required), ref.
browser_get_infoA
Browser health: mode, tab list, restart count, recent errors / dialogs / downloads. Never launches the browser.
Inputs: no named parameters.
browser_hoverB
Hover an element to reveal hover-only menus or tooltips.
Inputs: ref, selector, timeoutMs.
browser_press_keyA
Press a key, e.g. Enter / Tab / ArrowDown / Control+a. With a ref, focuses that element first.
Inputs: key (required), ref.
browser_screenshotA
Screenshot the viewport, the full page, or a single element (ref). Returns the image and writes it to disk.
Inputs: ref, filename, fullPage.
browser_scrollB
Scroll the page, or one scroll container when a ref is given. Direction plus pixel amount.
Inputs: direction (required), ref, amount.
browser_select_optionC
Select options in a dropdown. values may be option values or visible labels; both are tried.
Inputs: values (required), ref, selector, timeoutMs.
browser_snapshotA
Semantic snapshot of the current page: interactive elements carry [eN] refs, and iframe content is flattened in. Narrow it with rootRef (the subtree of a single element), selector, or filter:interactive (interactive elements only).
Inputs: filter, rootRef, selector, maxElements.
browser_tabsB
Manage tabs: list / new / select (by the index or id that list shows) / close.
Inputs: action (required), id, url, index.
browser_typeB
Type text into a field (clears it first). submit:true presses Enter. Works with input/textarea/contenteditable.
Inputs: text (required), ref, clear, submit, +2 more.
browser_waitB
Wait for a condition: timeMs (fixed delay) / text (appears) / selector (appears) / url (changes) / idle (network quiet). Combine them freely.
Inputs: url, idle, text, timeMs, +2 more.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 14 tools
Each tool has a clearly delineated role: tabs/health/close for lifecycle, wait/navigate/snapshot for page state, and click/type/press_key/select_option/hover/scroll for interaction. Minor overlap exists between browser_press_key and browser_type (which can submit via Enter) and between browser_get_info and browser_snapshot, but descriptions steer selection well.
All 14 tools share a uniform browser_ prefix and snake_case, which makes the family instantly recognizable. The only deviation is stylistic: most are bare verbs (browser_click, browser_scroll) while a few are noun or get_-prefixed forms (browser_tabs, browser_get_info, browser_snapshot).
14 tools sit squarely in the well-scoped band and each maps to a distinct browser capability rather than a redundant variant. Nothing feels padded or conspicuously absent from the interaction set.
The surface covers the full browse-inspect-act loop including waiting, screenshots, tab management, and a JS escape hatch, so agents rarely hit a dead end. Gaps remain around history navigation (back/forward), file upload, drag-and-drop, and cookie/storage management.
Maintenance
Related MCP Connectors
Real Chrome for coding agents over MCP: browse, replay playbooks, human takeover, HIPAA & BAA.
Web scraping, browser automation, screenshots and AI data extraction for AI agents via MCP.
Control a real browser from AI agents: navigate, click, type, screenshot, read the page.
Browz hosted MCP (free public beta): let an AI app drive your own Browz browser profiles from anywhere. Connect https://mcp.gobrowz.com/mcp and sign in with your Browz account (OAuth) or an agent token. Each call is relayed to the Browz app on your computer, which must be online with Remote control on and have a hardware security chip (Mac Secure Enclave or TPM 2.0). 17 tools: profiles, tabs, navigate, snapshot, act, wait, screenshot. Cookies, downloads and stored sign-ins stay on your computer.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceEnables browser automation through the MCP protocol, allowing AI agents to control a real browser using accessibility snapshots and natural language commands.-
- AlicenseAqualityCmaintenanceEnables AI agents to control a browser via MCP with structured perception, verified actions, and self-healing capabilities.1310 npm1MIT
- AlicenseNot gradedqualityBmaintenanceEnables AI agents to operate an isolated local Chromium browser through MCP, with semantic snapshots, ref-based actions, search, research, crawling, and CDP access.Apache 2.0
- AlicenseAqualityBmaintenanceEnables AI agents to drive a Chromium browser through MCP, with persistent sessions, compact page snapshots, guarded actions, batched operations, and explicit result verification.16MIT