
Nexus Browser Mcp
io.github.paipaipai666由 GitHub 帳號 paipaipai666 發布v0.3.0更新於 Oct 24, 2026
Event-driven deterministic browser MCP: HITL gates, audit, console/network/perf observability.
概覽
以 Playwright 為基礎的瀏覽器自動化 MCP 伺服器,讓助理透過確定性的無障礙樹快照進行導覽、點擊、輸入與讀取頁面。
- 可以做什麼
- 導覽頁面、上一頁、等待導覽,並管理分頁與頁面,在 CDP 或持久化設定模式下經確認後可接管已開啟的分頁。點擊、輸入、懸停、按鍵、選擇選項、拖曳、上傳檔案、捲動、關閉彈出視窗並回應被暫置的對話框。讀取頁面內容、截圖、依文字尋找內容,僅在明確啟用時執行 JavaScript。檢視主控台訊息、未攔截例外、網路請求中繼資料與效能指標,回應內容需開啟開關後按需讀取。管理任務與工作階段,每個任務使用隔離的瀏覽器內容,閒置回收並在崩潰後自動重建。
- 適用情境
- 適合助理需要驅動真實瀏覽器完成多步驟網頁任務的情境,例如填寫表單、搜尋、閱讀網站,或排查頁面為何沒有反應。治理閘門、稽核日誌與可觀測性使其適合需要對敏感點擊進行人工核准的受監督流程。
- 執行需求
- 以 Python 套件形式透過 stdio 在本機執行(pip 或 uvx),需安裝 Playwright 及其 Chromium 瀏覽器。選用環境變數用於設定瀏覽器模式、CDP 端點、系統瀏覽器通道、使用者資料目錄、逾時、快照上限、HITL 規則、稽核路徑、下載目錄與代理。HTTP 傳輸綁定非本機位址時必須提供 BROWSER_HTTP_TOKEN。
安裝
在 SourceWeft 中
- 開啟 儀表板中的 Nexus Browser Mcp,將其新增到工作區。
- 為需要使用其工具的對話啟用該服務。
Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。
其他 MCP 客戶端
參照 儲存庫 中的啟動說明。
README
English | 简体中文
nexus-browser-mcp
[PyPI] [CI] [Python 3.11+] [License: MIT] [MCP Registry] [Glama]
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 (sensitive-parameter redaction + per-call in/out character metering, so token cost can be reconciled). - 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. - Developer observability: every page records console messages, uncaught JS exceptions and network request metadata (method/URL/status/failure reason — never bodies) into capped ring buffers;
browser_console/browser_errors/browser_networkread them incrementally via asincecursor, so the agent can answer "why did nothing happen" instead of guessing.
Installation
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:
Integrate (any MCP client)
opencode (~/.config/opencode/opencode.json):
Claude Code (.mcp.json, project root):
Pi Coding Agent: reads standard MCP configuration — project .mcp.json or user-global ~/.config/mcp/mcp.json; stdio is the default transport:
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):
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):
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.
In CDP (or persistent-profile) mode the agent can also take over tabs you already have open: browser_list_pages shows them under "external tabs", and browser_adopt_page(ext_index) pulls one into the task (snapshot/click/read all work from then on). Adoption always requires confirmed=true — it hands the agent full read/write access to that page, including its login state.
Configuration (environment variables)
Every option can be overridden via BROWSER_-prefixed env vars:
评测/全功能使用:两个高危能力默认关闭(安全优先)。需要
browser_evaluate时设BROWSER_ALLOW_JS_EXECUTION=true,需要browser_network_body时设BROWSER_ALLOW_NETWORK_BODY=true——冷启动跑基准/评测不开它们,对应子任务会被拒(这是设计,不是故障)。
Tools
34 tools: browser_navigate, browser_navigate_back, browser_snapshot, browser_click, browser_type, browser_hover, browser_press_key, browser_select_option, browser_upload_file (HITL-confirmed), browser_drag, browser_dialog_respond (dialogs are parked for agent/user decision; accept requires confirmed=true), browser_adopt_page (take over an already-open browser tab in cdp/persistent mode; HITL-confirmed), browser_read, browser_screenshot, browser_evaluate, browser_wait, browser_wait_stable, browser_wait_ms, browser_scroll, browser_scroll_to, browser_wait_navigation, browser_find (locate content by text → refs), browser_dismiss_popup, browser_list_pages, browser_switch_page, observability tools browser_console, browser_errors, browser_network, browser_perf, browser_network_body, plus 4 lifecycle tools: browser_tasks, browser_close_task, browser_list_sessions, browser_close_session.
Observability (debugging): console output, uncaught exceptions and request metadata are buffered per page from creation; browser_errors() returns a merged "JS exceptions + console.error + failed requests" view in one call. All three support a since cursor (omit = continue from last read, 0 = full) and limit paging.
Performance: browser_perf() returns FCP/LCP/CLS/INP, navigation timings and the 5 slowest resources. Response bodies can be fetched on demand with browser_network_body(seq) — off by default (BROWSER_ALLOW_NETWORK_BODY), every call gated by confirmed=true, hard char cap, and the body never enters the audit log.
Token cost: measured, not claimed
Same 10-step task, both servers at default config, metered at the JSON-RPC payload layer (cl100k tokens; harness + raw data in docs/bench/token-comparison.md, reproduce with bench/compare.py):
7.5x fewer tokens overall; 100x on repeated snapshots — the dominant cost in real agent loops (polling, multi-step forms, state confirmation).
Real-site benchmark (7 scenarios × 5-7 verifiable sub-tasks each: Baidu/Bing/DuckDuckGo search, Wikipedia reading, Hacker News, GitHub browsing — docs/bench/realworld.md): sub-task completion 37/42 vs 31/42, 18.2k vs 566.4k tokens (31x), wall-clock 107s vs 179s — one Wikipedia article snapshot alone costs pw-mcp ~252k tokens where nexus caps + diffs. Enterprise task suite (filter/sort, dashboard reading, KB answers, multi-step ordering, price comparison — docs/bench/enterprise-ops.md): 21/21 on all three servers (vs playwright-mcp and chrome-devtools-mcp); tokens 3.6k vs 5.1k vs 10.9k. At scale (106 cases / 184 sub-tasks, three servers, seeded deterministic fixtures — docs/bench/scale-ops.md): completion 184/184 vs 180/184 vs 178/184; tokens 153.5k vs 180.5k vs 231.1k (1.00 : 1.18 : 1.51) — the competitor gaps are stable zeros (richtext-iframe writes, download observability, right-click), not noise.
Element-identification accuracy on adversarially complex pages (duplicate-name button grids, shadow DOM, iframes, hidden/disabled traps, full re-render — docs/bench/element-acc.md): nexus 92% = pw 92% < chrome-devtools-mcp 100%, with cdt also cheapest — its verbose per-node dump carries product texts that lean snapshots drop, which value-based targeting needs. We publish this as a known tradeoff of text clipping: total-token savings mean nothing unless per-point-of-accuracy cost holds, and this suite is the canary (fix direction benchmarked: attach sibling-text summaries only when same-name candidates conflict).
HITL confirmation closes a loop: any gated call returns CONFIRMATION_REQUIRED once; after the user approves in chat, the agent re-calls with confirmed=true (applies to HITL rules, browser_evaluate, browser_network_body).
HTTP transport (remote / multi-client)
Default is stdio (single client). For remote or multi-client use, run a streamable-HTTP server:
Each MCP session gets an isolated session_id (isolated contexts per task, as usual). Safety rule: binding a non-localhost address without BROWSER_HTTP_TOKEN refuses to start — an unauthenticated browser-control port is a footgun; with a token set, requests must send Authorization: Bearer <token>.
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.
Snapshot diff: a repeated browser_snapshot whose tree is node-for-node identical to the last one (refs excluded — Playwright renumbers them per generation) returns a ~120-char [no change] notice instead of the full tree, and previously issued refs remain valid via generation chaining; diff=false forces a full snapshot. Any real change (content, box, attributes) yields the full snapshot — no partial merges, no stale views.
Most tools accept an optional task_id (defaults to a shared default task). See usage guides in docs/ (Chinese).
Development
License
MIT
來源:README.md,提交 9501512
工具
0版本歷史
1- v0.3.0最新Sep 16, 2026
評分
已滿足適用檢查項的 50%
該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。
- 近 30 天內可連通25 分
請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。
- 已宣告認證方式10 分
請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。
- 已列出工具15 分
請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。
- 描述必需15 分
- 圖示10 分
- 文件15 分
- 授權條款10 分