mcp-browser
Exposes Playwright browser automation as MCP tools, enabling AI assistants to control a real browser tab-by-tab for form filling, navigation, and more, while preserving the user's active session.
README
mcp-browser
A production-grade FastMCP server that exposes Playwright browser automation as MCP tools — letting Claude (or any MCP client) drive a real browser tab-by-tab without ever touching the user's active session.
Built and used daily as part of an autonomous agentic fleet that fills forms, navigates sites, applies to jobs, and manages profiles — all via Claude tool calls.
What's inside
30+ pw_* browser primitives
Every tool follows the same contract: target a specific tab (page_index or page_url), never tab 0 (the user's active tab). Returns structured JSON — no raw HTML noise.
| Tool | What it does |
|---|---|
pw_goto |
Navigate to a URL |
pw_click |
Click a CSS selector |
pw_fill |
Fill a form field (instant set) |
pw_type |
Type text key-by-key (with delay) |
pw_press |
Send a keyboard key |
pw_snapshot |
Get a compact map of clickable/fillable elements — the token-efficient alternative to dumping the full DOM |
pw_get_text |
Read visible text content |
pw_get_html |
Read the raw HTML (with optional region scoping) |
pw_screenshot |
Capture the page as a base64 PNG |
pw_scroll |
Scroll to top/bottom/by pixels |
pw_select |
Choose a <select> option |
pw_hover |
Hover a selector |
pw_evaluate |
Run arbitrary JS in the page and return the value |
pw_wait |
Sleep N ms |
pw_wait_for |
Wait for a CSS selector to appear |
pw_new_tab |
Open a new background tab |
pw_close_tab |
Close a tab by index |
pw_list_tabs |
List all open tabs |
pw_back / pw_forward / pw_reload |
Browser history navigation |
pw_download / pw_save_download |
Trigger and save file downloads |
pw_handle_filechooser |
Intercept file picker dialogs |
pw_intercept |
Intercept / block network requests |
pw_pdf |
Export page to PDF |
pw_status |
Get tab URL + title |
pw_cookies |
Read cookies |
pw_console |
Capture browser console output |
pw_test |
Assert a condition, return pass/fail |
pw_act |
Run a whole step-list in ONE round-trip (goto → fill → click → snapshot) — the biggest speedup available |
Arc browser tab management
Tools for inspecting and driving Arc tabs by space/title/URL — works alongside the pw_* primitives.
Compiled recipes
A pw_recipe dispatcher that runs pre-verified multi-step flows without burning schema tokens. Two examples included:
the_internet/login— canonical UI-automation sandbox (deterministic creds, read-only)wikipedia/summary— fetch an article summary
Architecture
server.py ← 3-line FastMCP entry point
server_base.py ← factory: auto-discovers tools + starts file watcher
tools_registry.py ← walks tools/ and registers every non-private function
tools/
browser/
config.py ← MCP_PLAYWRIGHT_RUNTIME env var (path to Node runtime)
recipe.py ← pw_recipe dispatcher
playwright/
_cdp.py ← persistent CDP daemon bridge (one connectOverCDP per session)
_resolve_page.py ← shared JS: resolve page by index or URL substring
cdp_daemon.js ← long-lived Node daemon; reuses the CDP connection across calls
pw_*.py ← one file per tool; auto-registered at startup
arc/
*.py ← Arc-specific tab management tools
recipes/
the_internet/login.py
wikipedia/summary.py
playwright-runtime/
package.json ← { "dependencies": { "playwright": "^1.58.2" } }
The CDP daemon
By default every Playwright tool would spawn a fresh node -e process, pay a full connectOverCDP handshake, and enumerate all tabs — adding ~300–800 ms per call. The daemon (cdp_daemon.js) holds one live CDP connection and routes action bodies to it over HTTP on localhost:9224. Result: per-call overhead drops to near zero; the first call pays the startup cost, every subsequent one is just the action.
The daemon is started lazily on the first tool call and exits after 10 minutes idle.
Auto-discovery
tools_registry.py walks tools/ at startup and registers every non-underscore .py file as an MCP tool — no explicit imports, no decorator boilerplate. Add a new tool file → it's live on the next hot-reload (via mcp-hmr).
Setup
Prerequisites
- Python 3.10+
- Node.js 18+
- A Chromium-family browser running with
--remote-debugging-port=9222(Arc on macOS does this automatically; for others:chromium --remote-debugging-port=9222)
Install
# Python deps
python -m venv venv && source venv/bin/activate
pip install -r requirements.txt
# Node Playwright runtime
cd playwright-runtime && npm install && cd ..
Register with Claude
Add to your claude_desktop_config.json (or equivalent MCP config):
{
"mcpServers": {
"mcp-browser": {
"command": "/path/to/venv/bin/python",
"args": ["-m", "server"],
"cwd": "/path/to/mcp-browser",
"env": {
"MCP_PLAYWRIGHT_RUNTIME": "/path/to/mcp-browser/playwright-runtime"
}
}
}
}
Run standalone
python server.py
Usage pattern
A typical Claude interaction:
# 1. Open a new worker tab (never hijack tab 0 — that's the user's view)
pw_new_tab() → { page_index: 3 }
# 2. Navigate
pw_goto(url="https://example.com/login", page_index=3)
# 3. Inspect what's actionable
pw_snapshot(page_index=3) → { elements: [ { tag: "input", label: "Email", selector: "#email" }, ... ] }
# 4. Fill and submit
pw_fill(selector="#email", value="me@example.com", page_index=3)
pw_fill(selector="#password", value="...", page_index=3)
pw_click(selector="button[type='submit']", page_index=3)
# 5. Verify
pw_get_text(selector=".dashboard-header", page_index=3)
Or run the whole flow in one call with pw_act:
pw_act(steps=[
{"goto": "https://example.com/login"},
{"fill": "#email", "value": "me@example.com"},
{"fill": "#password", "value": "..."},
{"click": "button[type='submit']"},
{"wait_for": ".dashboard-header"},
{"text": ".dashboard-header"},
], new_tab=True)
Design decisions
Tab 0 is sacred. Every tool refuses to default to tab 0. The user's active tab must never be hijacked mid-session — this is a hard invariant, not a convention.
One tool = one file. Each pw_*.py is a standalone module with a single exported function. Auto-discovery means adding a tool is as simple as dropping a new file.
JSON in, JSON out. Every tool returns { status: "ok"|"error", ... }. No exceptions surface as unhandled Python tracebacks.
pw_act for multi-step flows. N round-trips of goto → fill → click → snapshot cost N × (model latency + daemon call). pw_act collapses them into 1 — especially valuable in agentic loops.
License
MIT
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。