browser-mcp
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., "@browser-mcp Go to example.com and show me the page snapshot"
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 MCP
Derived from internal Hermes project.
Agent-native browser control MCP server — 让任何支持 MCP 的 AI agent 都能浏览网页。
为什么需要这个?
现有的浏览器 MCP(Playwright、Puppeteer)是给程序员写代码用的底层 API。这个 MCP 是给 LLM agent 用的:
Accessibility tree snapshot — agent "看到"的是可读的 DOM 树,不是原始 HTML
Ref ID 交互 —
click("@e5")就行,不用写 CSS 选择器本地运行 — 不需要云端浏览器,不需要 API key
开箱即用 — 13 个工具覆盖浏览器操作 + 网络调试 + 测试用例录制
Related MCP server: mcp-server-agent-browser
工作原理
MCP 客户端 (Claude Code / Cursor / ZCode ...)
│ stdio
▼
browser-mcp (本仓库,Python MCP server)
│ subprocess
▼
agent-browser CLI ──► 本地 Chrome (headless 或 headed)browser-mcp 是一层薄封装,把 agent-browser CLI 的能力以 MCP 工具的形式暴露给 LLM agent。agent 通过 ref ID 与页面交互,不用写选择器。
安装
前置依赖
需要 Python ≥ 3.10 和 Node.js(用于安装 agent-browser)。
第 1 步:安装 agent-browser 并下载 Chrome
# 安装 CLI(需要 Node.js)
npm install -g agent-browser
# 下载它自带的 Chrome for Testing(首次安装必做)
agent-browser install验证:
agent-browser --version
agent-browser open example.com && agent-browser snapshot -i
# 能看到页面的可交互元素列表,说明 agent-browser 就绪第 2 步:安装 browser-mcp
git clone https://github.com/huaka1/browser-mcp.git
cd browser-mcp
# 建议用虚拟环境
python -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
# 可编辑安装(同时注册 `browser-mcp` 命令行入口)
pip install -e .验证:
browser-mcp --help # 或:python -m browser_mcp.server一键安装(让 Agent 帮你装)
不想手动跑命令?把下面这段 prompt 复制给你的 AI agent(Claude Code / Cursor / ZCode 等),它会自己执行安装、生成配置、并引导你验证。
请帮我安装并配置 browser-mcp(一个让 AI agent 控制浏览器的 MCP server)。
按步骤执行,每步验证通过后再进入下一步;失败就停下来告诉我原因和修复建议。
【前提检查】
- 跑 `node --version`;失败就提示我装 Node.js(macOS: `brew install node`)
- 跑 `python3 --version` 确认 ≥ 3.10;失败就提示我装 Python 3.10+
【1. 安装浏览器引擎】
npm install -g agent-browser
agent-browser install # 下载 Chrome for Testing,约 1-2 分钟
验证:agent-browser open example.com && agent-browser snapshot -i
能列出页面可交互元素即成功
【2. 克隆并安装 browser-mcp】
git clone https://github.com/huaka1/browser-mcp.git ~/browser-mcp
cd ~/browser-mcp
python3 -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
pip install -e .
验证:`python -m browser_mcp.server` 能启动(或 browser-mcp 在 PATH 中)
【3. 生成 MCP 配置 — 关键:合并而非覆盖】
- 用 `~/browser-mcp/.venv/bin/python` 的绝对路径作为 command
- 定位我的 MCP 配置文件:优先当前项目 ./.mcp.json,其次 ~/.claude.json
- 若文件已存在:解析 JSON,在 mcpServers 下新增 "browser" 键(保留其它配置)
- 若不存在:新建文件,写入 {"mcpServers": { ... }}
- browser 配置内容:
"browser": {
"command": "<venv python 绝对路径>",
"args": ["-m", "browser_mcp.server"],
"env": { "BROWSER_MCP_HEADED": "1" }
}
【4. 收尾】
告诉我重启 MCP 客户端以加载新配置。
重启后引导我调用 browser_navigate 打开 https://example.com 做最终验证——
返回页面快照即代表安装链路打通。提示:prompt 里默认开启有头模式(
BROWSER_MCP_HEADED=1),方便你看到浏览器在干什么。如果旧 daemon 还在 headless 跑导致看不到窗口,让 agent 执行agent-browser close --all后重试即可。
配置 MCP 客户端
在你的 MCP 客户端配置里添加一个 browser server。最简单的方式是直接用 Python 模块启动:
{
"mcpServers": {
"browser": {
"command": "/你/克隆的路径/browser-mcp/.venv/bin/python",
"args": ["-m", "browser_mcp.server"],
"env": {
"BROWSER_MCP_HEADED": "1"
}
}
}
}仓库里有一份现成模板
.mcp.json.example,复制成.mcp.json后改路径即可。
command 一定要指向你本机的 venv python 绝对路径,否则 MCP 客户端找不到 browser_mcp 包。如果用的是全局 pip install,可以直接写 "command": "browser-mcp"、去掉 args。
各客户端配置文件位置
客户端 | 配置文件 |
Claude Code |
|
Cursor / Windsurf | 各自的 MCP 设置面板 |
ZCode | 项目 |
配置完成后重启客户端,确认 browser_* 工具已加载。
想看到浏览器窗口(有头模式)
默认 headless,看不到浏览器在干什么。设环境变量即可显示窗口:
"env": {
"BROWSER_MCP_HEADED": "1"
}⚠️
agent-browser是 daemon 模式,--headed只在 daemon 首次启动时生效。如果之前已经有 headless daemon 在跑,新设的有头模式会被忽略。遇到这种情况,在终端跑agent-browser close --all关掉旧 daemon,再重新触发 MCP 工具调用即可。
首次验证
配置好后,让 agent 执行一个最简单的流程来确认链路通了:
调用
browser_navigate打开https://example.com调用
browser_snapshot—— 应返回页面的可交互元素列表(链接、按钮 + ref ID)调用
browser_vision—— 应返回页面截图
三条都成功,说明安装完成。
工具列表
浏览器操作
工具 | 说明 |
| 导航到 URL,返回页面快照 |
| 获取页面 accessibility tree + ref ID |
| 点击元素(通过 ref ID) |
| 在输入框中输入文本 |
| 按键盘按键 |
| 滚动页面 |
| 浏览器后退 |
| 截图 |
| 获取控制台输出 / 执行 JS |
| 列出页面图片 |
网络层调试
工具 | 说明 |
| 获取网络请求日志(支持 URL/方法/状态码/类型过滤) |
| 查看请求的完整详情(headers + response body) |
| 拦截/模拟/阻断请求(block ads, mock API) |
测试用例录制(无感留痕 + 导出)
工具 | 说明 |
| 列出当前 session 缓冲区里已留痕的操作步骤 |
| 把操作步骤导出成 jsonl 测试用例,同时保存登录态 |
录制出的 jsonl 可让 agent 自己读回、用 role+name 重新定位元素重放,做无代码 E2E 回归。导出目录由
BROWSER_MCP_E2E_DIR指定。
环境变量
变量 | 说明 | 默认 |
|
| headless |
|
| 关 |
| jsonl 测试用例导出目录 | 无 |
License
MIT
Available Tools
15 toolsbrowser_backB
Go back in browser history.
Args: session_id: Browser session ID
Inputs: session_id. Returns: result
browser_clickA
Click an element by its ref ID from the snapshot.
Args: ref: Element reference like "@e5" or "@e12" from the snapshot session_id: Browser session ID
Inputs: ref (required), session_id. Returns: result
browser_consoleA
Get browser console output or evaluate a JavaScript expression.
Without expression: returns recent console.log/warn/error messages. With expression: evaluates the JS and returns the result.
Args: session_id: Browser session ID expression: JavaScript expression to evaluate (optional)
Inputs: expression, session_id. Returns: result
browser_export_stepsA
把缓冲区的页面操作步骤导出成 jsonl 测试用例,同时保存登录态。
导出后清空缓冲区。以后回归时:让 agent Read 这个 jsonl, 用 browser state load 加载 auth.json,按步骤用 browser_navigate/click/type 重放 (用 role+name 定位,不用 ref),看当下 url/title 跟录制时一不一致自己判断对错。
Args: name: 用例名,文件名为 test_{name}.jsonl domain: 领域名(如 auth/task/file/cron/skill),作为子目录名 from_step: 从第几步开始导出(1-based),默认 1=全部。用 browser_list_steps 看编号后决定。 session_id: Browser session ID(用于保存登录态)
Inputs: name (required), domain (required), from_step, session_id. Returns: result
browser_get_imagesA
List all images on the current page with their URLs and alt text.
Args: session_id: Browser session ID
Inputs: session_id. Returns: result
browser_get_network_logsA
Get network request logs from the current browser session.
Returns captured HTTP requests with URL, method, status code, headers, resource type, and timing. Useful for discovering hidden APIs, debugging failed requests, and analyzing page load performance.
Args: session_id: Browser session ID url_filter: Filter by URL pattern (e.g., "api", "json", ".js") method: Filter by HTTP method (e.g., "GET", "POST") status: Filter by status code (e.g., "200", "4xx", "404") resource_type: Filter by resource type (e.g., "xhr", "fetch", "document")
Inputs: method, status, session_id, url_filter, +1 more. Returns: result
browser_get_response_bodyA
Get the full details of a specific network request, including response body.
Use browser_get_network_logs first to find request IDs, then call this tool to see the complete request/response including body content.
Args: request_id: The request ID from browser_get_network_logs (e.g., "39C8D9...") session_id: Browser session ID
Inputs: request_id (required), session_id. Returns: result
browser_intercept_requestA
Intercept, block, or mock network requests matching a URL pattern.
Use this to:
Block requests (e.g., block ads, tracking scripts)
Mock API responses (return custom JSON)
Test error handling (simulate network failures)
Args: url_pattern: URL pattern to match (e.g., "/api/*", "/analytics/*") action: "block" to abort matching requests, "mock" to return custom response response_body: JSON string for mock responses (only used when action="mock") session_id: Browser session ID
Inputs: url_pattern (required), action, session_id, response_body. Returns: result
browser_list_stepsA
列出当前 session 缓冲区里已留痕的页面操作步骤。
每次调 browser_navigate/click/type/press/scroll/back 都会自动留痕。 用这个 tool 看看刚才干了哪些步骤,再决定导出哪些(配合 browser_export_steps 的 from_step 参数)。
Returns: 步骤列表,每行一个步骤:编号 + action + role+name + value
Inputs: no named parameters. Returns: result
browser_pressB
Press a keyboard key.
Args: key: Key to press (e.g., "Enter", "Tab", "Escape", "ArrowDown", "Control+a", "Meta+a") session_id: Browser session ID
Inputs: key (required), session_id. Returns: result
browser_scrollA
Scroll the page up or down.
Args: direction: "up" or "down" pixels: Number of pixels to scroll (default: 500) session_id: Browser session ID
Inputs: direction (required), pixels, session_id. Returns: result
browser_snapshotA
Get a text snapshot of the current page's accessibility tree.
Returns interactive elements with ref IDs (like @e1, @e2) for use with browser_click and browser_type.
Args: session_id: Browser session ID full: If true, return full page content. If false (default), return only interactive elements (compact view).
Inputs: full, session_id. Returns: result
browser_typeA
Type text into an input field identified by its ref ID.
Clears the field first, then types the new text.
Args: ref: Element reference like "@e3" from the snapshot text: Text to type into the field session_id: Browser session ID
Inputs: ref (required), text (required), session_id. Returns: result
browser_visionA
Take a screenshot of the current page.
Use this when you need to see what the page looks like visually — CAPTCHAs, complex layouts, or when the text snapshot is not enough.
Args: session_id: Browser session ID full_page: If true, capture the full page (not just viewport)
Inputs: full_page, session_id. Returns: result
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 15 tools
Each tool has a unique and clear purpose: navigate, click, type, scroll, press keys, snapshot, console, images, network logs, intercept, export steps, list steps, and vision. No two tools overlap in function.
All tools follow the consistent pattern 'browser_verb[_noun]' in snake_case (e.g., browser_navigate, browser_get_network_logs). No mixing of conventions.
15 tools cover the core browser automation domain without being excessive. The count is well-scoped for navigation, interaction, debugging, and recording.
The tool surface covers navigation, DOM interaction, snapshot, screenshot, console, network logging, request interception, and step recording/exporting. No obvious gaps for standard browser automation tasks.
Maintenance
Related MCP Connectors
Official Browserless MCP server: browser automation, scraping, screenshots and PDFs for AI agents.
Control a real browser from AI agents: navigate, click, type, screenshot, read the page.
Search, read, and act on the web. The Stophy MCP server for agents.
Web scraping, browser automation, screenshots and AI data extraction for AI agents via MCP.
Related MCP Servers
- AlicenseAqualityDmaintenanceAn MCP server providing AI agents with a stealth Chromium browser that uses hybrid accessibility-object-model and set-of-mark vision for token-lean snapshots and reliable action via ref ids.1376 npm2Apache 2.0
- FlicenseNot gradedqualityCmaintenanceMCP server that wraps agent-browser to let LLMs control a real browser, providing tools for navigation, interaction, reading page content, accessibility snapshots, screenshots, and session management.1-
- AlicenseAqualityCmaintenanceBrowser automation MCP server that uses a real browser to give agents eyes and hands—open pages, click, fill, screenshot, and run scripts via accessibility-tree snapshots.22MIT
- AlicenseNot gradedqualityBmaintenanceLocal browser MCP server that lets AI assistants control a real desktop browser via tools like navigate, snapshot, and search_web.MIT