chrome-hook MCP

chrome-hook MCP

Drives real Chromium browsers for multi-account testing and full network capture, with Cloudflare bypass via patched Playwright and real browser attach mode.

Category
访问服务器

README

chrome-hook MCP

A local MCP server that drives real Chromium browsers (Chrome / Brave) for multi-account testing and full network capture, with a real-browser attach path for strict bot protection.

See CHANGELOG.md for recent behavior changes (optional proxy, no legacy auth seeds, public-doc hygiene).

Built on patchright (a drop-in Playwright with CDP-layer anti-detection patches), falling back to stock Playwright when patchright is absent.

Cross-platform (macOS / Windows / Linux). Chrome and Brave binaries are auto-detected from standard install locations and PATH — no hardcoded paths. The stealth UA is derived from the installed browser's version and the host OS.

Local-only. Everything runs on your machine. Captured traffic, cookies, auth state and browser profiles are written to local disk and are never uploaded anywhere. Do not commit the runtime dirs (see .gitignore).


What it does

  • Named browser slots (a, b, …) run side by side so you can test two accounts at once without logging out (servers often revoke tokens on logout — use two slots instead of switching).
  • Project-scoped auth/profiles (project= isolates cookies per site so accounts never bleed across projects).
  • Full capture by default: every HTTP(S) request/response + WebSocket frame, streamed to network.jsonl, saved bodies, and an exportable HAR.
  • Strict bot protection: patchright driver + a real-browser attach mode (Plan A) that gets past managed challenges a cold automated browser can never solve.
  • Optional proxy: off by default; set CHROME_HOOK_PROXY or proxy= when needed.

Install

pip install -r requirements.txt
# patchright ships its own patched driver; using channel="chrome"/"brave" (real
# binaries) means you do NOT need a separate `patchright install chromium` download.

Requires a real Google Chrome and/or Brave installed. Their binaries are auto-located on macOS, Windows, and Linux (standard install dirs + PATH).

Register with your MCP host (e.g. Grok CLI)

[mcp_servers.chrome-hook]
command = "python3"
# Prefer the installed runtime path (Grok loads this); keep in sync with repo.
args = ["/ABS/PATH/TO/chrome-hook-mcp/server.py"]  # or ~/.grok/tools/chrome-hook-mcp/server.py
enabled = true
startup_timeout_sec = 45
tool_timeout_sec = 180
# Proxy is optional (off by default). Uncomment when you need Burp/Clash:
# env = { CHROME_HOOK_PROXY = "http://127.0.0.1:8080" }

After editing server.py, copy to the installed path if needed, then restart the MCP host.

Agent workflows live in companion skill chrome-hook-browser (SKILL.md in this repo and ~/.grok/skills/chrome-hook-browser/).


Two ways to use it

1. Normal launch (most sites)

browser_launch(project="acme", slot="a", headless=false,
               start_url="https://example.com/")
browser_launch(project="acme", slot="b", headless=false,
               start_url="https://example.com/")   # second account, no logout
# ... log in each window the first time ...
browser_persist(slot="a"); browser_persist(slot="b")   # save auth
# later runs auto-restore — no re-login while the token is valid
browser_request(..., slot="a")

Anti-bot hardening applied automatically: patchright driver; UA auto-matched to the installed Chrome major version; locale/timezone_id left native under patchright (forcing e.g. en-US on an Asia machine is itself a Cloudflare mismatch flag); a JS stealth init-script is injected only on the stock-Playwright fallback.

2. Plan A — attach to a real, warm browser (strict bot protection)

Some sites hand a cold/freshly-launched automated browser an unsolvable managed challenge — even under patchright, even if you click the checkbox by hand. The reliable fix is to attach to a genuine, already-warmed browser that you passed the challenge in.

# step 1 — spawn YOUR real browser with a remote-debugging port + dedicated profile
browser_open_real(project="demo", slot="a",
                  url="https://example.com/",
                  port=9222, browser="brave")     # browser: "chrome" | "brave"

#   -> solve the challenge by hand in the window that opens

# step 2 — MCP connects over CDP and captures the warm session
browser_attach(project="demo", slot="a", port=9222)

Why this works, and the details that matter:

  • Brave (browser="brave") often clears strict challenges where a cold Chrome profile cannot, thanks to its built-in anti-fingerprinting. The dedicated profile lives in real-chrome/<project>/<slot>[-brave]/ and is reused across runs, so once you pass the challenge the clearance cookie persists and you rarely have to solve it again.
  • It uses a separate profile from your everyday browser (a running browser locks its own profile and can't expose CDP on it). Your normal browser is untouched.
  • A CDP-attached pre-existing tab emits no Playwright network events, so attach opens a fresh capture page in the same context — it inherits the context cookies (incl. clearance tokens), loads past the challenge with no new prompt, and lands on the tab's URL. Capture happens on that page.
  • browser_close on an attached slot only disconnects — it never closes your real browser or its original tab, and never overwrites its cookies with stale auth.

browser_launch(cdp_url="http://127.0.0.1:9222", …) is the low-level equivalent of browser_attach.


Tools (27)

Session / slots browser_set_project · browser_sessions · browser_focus · browser_launch · browser_status · browser_close

Plan A (real browser) browser_open_real — spawn real Chrome/Brave with a debug port · browser_attach — connect over CDP and capture the warm session

Auth persistence browser_persist · browser_restore · browser_storage_save · browser_storage_load · browser_cookies_get · browser_cookies_set

Page actions browser_navigate · browser_snapshot · browser_click · browser_type · browser_press · browser_wait · browser_screenshot · browser_eval

Network capture / replay browser_network_dump — events under the hits key (count = total) · browser_network_set_filter · browser_network_set_mode (all | api) · browser_export_har · browser_request — issue a request in-context


Proxy (optional)

Item Value
Default No proxy (direct)
Env CHROME_HOOK_PROXY (optional, e.g. http://127.0.0.1:8080 Burp)
Per-call browser_launch(proxy=…) / browser_open_real(proxy=…)
Force off proxy="none" or CHROME_HOOK_PROXY=none
MITM When proxy is set, cert errors are ignored automatically
Attach Does not change the real browser's proxy — set it at open_real time

On-disk layout

chrome-hook-mcp/
  server.py                     # the MCP server (27 tools)
  SKILL.md                      # companion agent skill (chrome-hook-browser)
  requirements.txt
  README.md
  # --- runtime state under ~/.grok/tools/chrome-hook-mcp/ (git-ignored) ---
  profiles/<project>/<slot>/    # Chromium user-data for normal launch
  auth/<project>/<slot>.json    # storage_state auto save/restore
  real-chrome/<project>/<slot>[-brave]/   # Plan A dedicated warm profiles
  sessions/<project>_<slot>_…/  # per-run network.jsonl + HAR + bodies

Defaults: auto_restore=true, auto_save=true (save on close), capture_mode="all", body caps 512 KB HTTP / 64 KB WS, no proxy unless CHROME_HOOK_PROXY or per-call proxy= is set.


Notes & limits

  • Restart the MCP host after editing server.py — a running process keeps the old code and won't expose new tools.
  • Browser-context only (not other OS processes). One Playwright driver thread; multiple Chromium/Brave processes are fine.
  • Ad-hoc testing via one-shot python3 -c hits Playwright's thread affinity (greenlet: Cannot switch to a different thread) and EPIPE on repeated connect_over_cdp; the long-lived MCP process is fine. To probe internals in a script, run your function on the driver thread via server._PW.submit(fn).
  • Security: never upload captured data, cookies, auth state, or profiles. Keep the runtime dirs local and out of version control.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选