nexus-browser-mcp
A browser-automation MCP server built on Playwright that provides deterministic snapshots via MutationObserver/requestAnimationFrame, HITL governance, multi-task isolation, and self-healing browser sessions for LLM-driven browsing.
README
English | 简体中文
nexus-browser-mcp
A browser-automation MCP server with event-driven, deterministic snapshots.
Built on Playwright. Drives a browser for LLMs through the Accessibility Tree — navigate, click, type, read, fill forms, manage tabs. Key differences from alternatives (e.g. Playwright MCP):
- Deterministic snapshots: no fixed-interval
sleepguessing. AMutationObserverrecords the last DOM mutation and the browser's ownrequestAnimationFrameloop decides when the page has been quiet forSTABLE_WINDOW_MS(default 800ms) before extracting a snapshot — eliminating "captured mid-animation" races. - Built-in governance gates: HITL rules (e.g. clicking "pay/confirm" requires human approval),
browser_evaluatedisabled by default with unconditional confirmation, JSONL audit log (with sensitive-parameter redaction). - Multi-task isolation: one MCP connection (session) can host multiple independent
task_ids, each with its own BrowserContext (no login-state cross-contamination). Idle tasks are reclaimed by TTL; on next use they're rebuilt and the last page is restored automatically. - Death observability + self-healing: if a tab or the whole browser is closed externally or crashes, the next call rebuilds it automatically (a persistent profile keeps your login state) and prepends a
[state change]notice telling the agent exactly what was restored and what was lost — no raw Playwright exceptions leak through.
Installation
pip install nexus-browser-mcp
# or
uvx nexus-browser-mcp
Two executable entry points are installed: nexus-browser-mcp and nexus-browser. A guaranteed fallback: python -m nexus_browser.server.
Requires playwright and its browser binary:
pip install playwright && playwright install chromium
Integrate (any MCP client)
opencode (~/.config/opencode/opencode.json):
{
"mcp": {
"browser": {
"type": "local",
"command": ["uvx", "nexus-browser-mcp"],
"enabled": true
}
}
}
Claude Code (.mcp.json, project root):
{
"mcpServers": {
"browser": {
"type": "stdio",
"command": "uvx",
"args": ["nexus-browser-mcp"]
}
}
}
Pi Coding Agent: reads standard MCP configuration — project .mcp.json or user-global ~/.config/mcp/mcp.json; stdio is the default transport:
{
"mcpServers": {
"browser": {
"command": "uvx",
"args": ["nexus-browser-mcp"]
}
}
}
See docs/INTEGRATE.md for details (Chinese).
Use your own browser (with login state)
By default, isolated mode launches Playwright's bundled Chromium without your cookies/login state. To use your own browser, pick one:
Option A — load your browser profile directly (recommended, simplest)
Use system Chrome with your everyday user data directory (cookies/login/bookmarks included):
BROWSER_CHANNEL=chrome
BROWSER_USER_DATA_DIR="C:\Users\<you>\AppData\Local\Google\Chrome\User Data"
Note: while running against your real User Data, the process owns the browser — launching your own Chrome concurrently will conflict. Prefer a copied profile or a dedicated
--user-data-dir.
Recommended: a tool-dedicated profile (no conflict with your daily browser)
Use BROWSER_CHANNEL=chrome plus a dedicated user data dir (e.g. C:\Users\<you>\.nexus-browser\chrome-profile):
BROWSER_CHANNEL=chrome
BROWSER_USER_DATA_DIR="C:\Users\<you>\.nexus-browser\chrome-profile"
On first use, log in to target sites once in the dedicated Chrome window that pops up when the agent calls a browser tool. Cookies persist in that profile forever after — the agent carries login state while staying fully isolated from your daily browser.
Option B — attach to a running Chrome via CDP
Start chrome --remote-debugging-port=9222 first, then set BROWSER_MODE=cdp.
If the CDP connection fails, the server now fails loudly (no silent fallback to a fresh browser) and tells you to start the debug-port browser first.
Configuration (environment variables)
Every option can be overridden via BROWSER_-prefixed env vars:
| Variable | Default | Description |
|---|---|---|
BROWSER_MODE |
isolated |
isolated (fresh isolated browser) / cdp (attach to your Chrome) |
BROWSER_CDP_ENDPOINT |
http://localhost:9222 |
CDP endpoint |
BROWSER_CHANNEL |
"" |
System browser channel: chrome/msedge etc. (empty = Playwright bundled Chromium) |
BROWSER_USER_DATA_DIR |
"" |
User data dir (carries cookies/login). When set, one shared persistent context across tasks. Empty = fresh profile |
BROWSER_HEADLESS |
false |
Headless mode (isolated only) |
BROWSER_DEFAULT_TIMEOUT_MS |
30000 |
Playwright per-operation timeout (navigation etc.) |
BROWSER_TOOL_TIMEOUT_MS |
60000 |
Outer timeout guard per tool call (returns ERROR instead of hanging) |
BROWSER_STABLE_WINDOW_MS |
800 |
Quiet window: how long without DOM mutations counts as "stable" |
BROWSER_STABLE_REQUIRED |
2 |
Consecutive identical snapshots confirming stability (guards non-DOM changes like animations) |
BROWSER_STABLE_TIMEOUT_MS |
3000 |
Total stability-wait timeout; degrades gracefully on expiry |
BROWSER_SNAPSHOT_MAX_NODES |
100 |
Max nodes per snapshot |
BROWSER_CONTEXT_TTL_SEC |
600 |
Idle task auto-reclaim (seconds) |
BROWSER_STREAM_CHAR_CAP |
16000 |
Max chars per stream buffer (oldest dropped with a seam marker) |
BROWSER_STREAM_PAGE_CAP |
64000 |
Total stream buffer chars per page |
BROWSER_ALLOW_JS_EXECUTION |
false |
Allow browser_evaluate (unconditional HITL when enabled) |
BROWSER_HITL_RULES |
[] |
JSON array of HITL rules, e.g. `[{"action":"click","name_pattern":"pay |
BROWSER_AUDIT_PATH |
~/.nexus-browser/audit.jsonl |
Audit log path |
Tools
20 tools: browser_navigate, browser_snapshot, browser_click, browser_type, browser_read, browser_screenshot, browser_evaluate, browser_wait, browser_wait_stable, browser_wait_ms, browser_scroll, browser_scroll_to, browser_wait_navigation, browser_dismiss_popup, browser_list_pages, browser_switch_page, plus 4 lifecycle tools: browser_tasks, browser_close_task, browser_list_sessions, browser_close_session.
Streaming content (AI replies etc.): browser_read(wait_stable=true) waits for DOM quiet and reads the full text in one call; browser_read(selector=..., follow=true) tracks incrementally and returns only new content per call (full=true returns the whole buffer). browser_wait_stable / browser_wait_ms provide event-driven and fixed-duration waiting primitives.
Most tools accept an optional task_id (defaults to a shared default task). See usage guides in docs/ (Chinese).
Development
uv venv
uv pip install -e ".[dev]"
python -m pytest tests -q
ruff check src tests
python -m smokes.test_e2e # real-browser smoke
python -m smokes.test_e2e_interact # forms + multi-task smoke
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 模型以安全和受控的方式获取实时的网络信息。