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-mcpopen google.com and search for MCP"
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
将浏览器自动化框架封装为标准 MCP Server,使 AI 编程工具(Cursor、Windsurf、Cline/Roo Code)能通过 MCP 协议调用浏览器能力。
分享文档:
English: docs/usage-guide-en.md
功能概览
提供四个 MCP Tool:
工具 | 功能 |
| 在持久页面上执行简化自然语言操作,支持多轮互动 |
| 提取网页结构化 UI 信息(清洗后的 DOM + 无障碍树) |
| 嗅探页面网络 API 请求与响应 |
| 获取页面全页截图(Base64 编码) |
核心特性:
默认优先使用浏览器 CDP 可见模式(自动探测
9222)支持 stdio 和 SSE 双传输模式
Docker 容器化一键部署
会话持久化(跨调用保持登录状态)
playwright-stealth 反检测集成
上下文压缩(控制返回数据量,避免超出 AI 上下文窗口)
Related MCP server: Browser Automation MCP
快速开始
方式一:Docker 部署(推荐)
# 克隆项目
git clone <repo-url>
cd browser-use-mcp-server
# 启动服务(SSE 模式,监听 8000 端口)
docker-compose up -d
# 查看日志
docker-compose logs -f容器启动后会自动检测 Chromium 浏览器是否可用,检测通过后以 SSE 模式启动 MCP Server。
如果本机 Chrome 已用 --remote-debugging-port=9222 启动,服务会默认接管该可见浏览器。
方式二:本地开发
# 安装依赖
pip install -e '.[dev]'
# 安装 Playwright 浏览器
playwright install chromium
# 以 stdio 模式启动(默认)
python -m src
# 或以 SSE 模式启动
MCP_TRANSPORT=sse python -m src传输模式
stdio 模式
适用于本地 IDE 直接集成。IDE 以子进程方式启动 MCP Server,通过标准输入输出通信。
python -m src
# 默认 MCP_TRANSPORT=stdioSSE 模式
适用于 Docker 部署或远程访问。MCP Server 启动 HTTP 服务,通过 Server-Sent Events 通信。
MCP_TRANSPORT=sse MCP_PORT=8000 python -m src
# SSE 端点: http://localhost:8000/sse默认会优先自动探测 127.0.0.1:9222 和 host.docker.internal:9222 的 CDP 端口。
如果需要手动指定,可设置 MCP_CDP_ENDPOINT。
IDE 配置
Cursor
将以下内容添加到 Cursor 的 MCP 配置中(参考 configs/cursor_mcp.json):
stdio 模式(本地运行):
{
"mcpServers": {
"browser-use-mcp-server": {
"command": "python",
"args": ["-m", "src"],
"env": {
"MCP_TRANSPORT": "stdio"
}
}
}
}SSE 模式(连接 Docker 容器):
{
"mcpServers": {
"browser-use-mcp-server-sse": {
"url": "http://localhost:8000/sse"
}
}
}Windsurf
参考 configs/windsurf_mcp_config.json:
stdio 模式:
{
"mcpServers": {
"browser-use-mcp-server": {
"command": "python",
"args": ["-m", "src"],
"env": {
"MCP_TRANSPORT": "stdio"
}
}
}
}SSE 模式:
{
"mcpServers": {
"browser-use-mcp-server-sse": {
"serverUrl": "http://localhost:8000/sse"
}
}
}Cline / Roo Code
参考 configs/cline_mcp.json:
stdio 模式:
{
"mcpServers": {
"browser-use-mcp-server": {
"command": "python",
"args": ["-m", "src"],
"env": {
"MCP_TRANSPORT": "stdio"
}
}
}
}SSE 模式:
{
"mcpServers": {
"browser-use-mcp-server-sse": {
"url": "http://localhost:8000/sse"
}
}
}环境变量
变量名 | 说明 | 默认值 |
| 传输模式: | 本地: |
| 监听地址(SSE 模式) |
|
| 监听端口(SSE 模式) |
|
| 日志级别 |
|
| 会话存储路径 | 本地: |
| 默认超时时间(秒) |
|
| 默认最大 Token 数 |
|
| CDP 地址,默认 |
|
简化交互
新增 browser_action tool,适合 MCP 多轮互动。默认 session_id="default",会持续复用同一个页面。
示例:
{"instruction":"打开网址 baidu.com"}{"instruction":"搜索A股行情,打开第二个网址"}返回示例:
{
"success": true,
"message": "Browser action executed successfully",
"session_id": "default",
"actions": ["searched A股行情", "opened result 2"],
"page_title": "...",
"current_url": "..."
}工具详细说明
map_and_extract_ui
提取网页结构化 UI 信息,包括清洗后的 DOM 和无障碍树。
参数:
参数 | 类型 | 必填 | 说明 |
| string | 是 | 目标 URL |
| string | 否 | 页面交互指令(如点击、滚动等) |
| string | 否 | CSS 选择器,限定提取范围 |
| bool | 否 | 是否启用 CSS 还原(默认 false) |
| string | 否 | 会话 ID,用于跨调用保持状态 |
| int | 否 | 超时秒数(默认 120) |
| int | 否 | 最大 Token 数(默认 8000) |
返回格式:
{
"cleaned_html": "<div>...</div>",
"accessibility_tree": "...",
"page_title": "页面标题",
"current_url": "https://example.com",
"estimated_tokens": 3500,
"truncated": false
}intercept_network_api
嗅探页面网络 API 请求与响应,自动过滤静态资源,仅保留 XHR/Fetch 数据接口。
参数:
参数 | 类型 | 必填 | 说明 |
| string | 是 | 目标 URL |
| string | 是 | 页面交互指令(触发 API 调用) |
| string | 否 | 会话 ID |
| int | 否 | 超时秒数(默认 120) |
| int | 否 | 最大 Token 数(默认 8000) |
返回格式:
{
"api_calls": [
{
"url": "https://api.example.com/data",
"method": "GET",
"request_payload": null,
"response_body": {"key": "value"},
"status_code": 200,
"truncated": false
}
],
"estimated_tokens": 1200,
"truncated": false
}注:单个 API 响应体超过 50KB 时会被截断,
truncated标记为true。
visual_inspect
获取页面全页截图,以 Base64 编码返回,适用于多模态 AI 视觉核对。
参数:
参数 | 类型 | 必填 | 说明 |
| string | 是 | 目标 URL |
| string | 否 | 页面交互指令 |
| string | 否 | 会话 ID |
| int | 否 | 超时秒数(默认 120) |
返回格式:
{
"screenshot_base64": "iVBORw0KGgo...",
"page_title": "页面标题",
"current_url": "https://example.com"
}错误处理
所有工具在异常情况下返回统一的错误结构:
{
"error": true,
"error_type": "timeout | navigation | blocked | internal",
"error_message": "错误描述",
"blocked": false,
"screenshot_base64": null,
"partial_result": null
}navigation:URL 无法访问、DNS 解析失败timeout:操作超时,partial_result中包含已完成的部分数据blocked:被反爬拦截,screenshot_base64中包含拦截页面截图internal:服务内部异常
开发
# 安装开发依赖
pip install -e '.[dev]'
# 运行测试
pytest
# 运行测试(含覆盖率)
pytest --cov=src
# 仅运行属性测试
pytest tests/test_*_properties.py项目结构
browser-use-mcp-server/
├── src/
│ ├── __main__.py # 启动入口
│ ├── server.py # MCP Server,Tool 注册与传输配置
│ ├── config.py # 配置管理(环境变量)
│ ├── models.py # 核心数据结构
│ ├── tools/ # 三个 MCP Tool 实现
│ │ ├── map_and_extract_ui.py
│ │ ├── intercept_network_api.py
│ │ └── visual_inspect.py
│ └── services/ # 共享服务模块
│ ├── session_manager.py
│ ├── dom_cleaner.py
│ ├── context_compressor.py
│ └── stealth.py
├── configs/ # IDE 配置示例
├── Dockerfile
├── docker-compose.yml
├── pyproject.toml
└── tests/许可证
MIT
This server cannot be deployed
Maintenance
Related MCP Connectors
MCP server for building and testing AI agents with multi-model experimentation and insights.
MCP server for Mint — AI-powered QA that runs your app in a real browser on every PR.
Live browser debugging for AI assistants — DOM, console, network via MCP.
A paid remote MCP for AI agent browser approval MCP, built to return verdicts, receipts, usage logs,
Related MCP Servers
- AlicenseBqualityCmaintenanceAn MCP server that provides AI models with full browser automation capabilities through Chrome. It enables navigation, interaction, screenshots, and complete DevTools access by bridging AI clients with a companion Chrome extension.9910 npm3Apache 2.0
- AlicenseAqualityBmaintenanceMCP server for AI browser automation with tools for navigation, actions, data extraction, and scripting, supporting local and cloud execution.14105 npm2Apache 2.0
- AlicenseAqualityDmaintenanceA MCP server that gives AI assistants full browser control, enabling navigation, clicking, form filling, and screenshots via any MCP client.8MIT
- FlicenseNot gradedqualityDmaintenanceMCP server that enables AI agents to automate browser testing via Chromium, providing tools for navigation, interaction, and inspection.-