seleniumbase-mcp

seleniumbase-mcp

Enables undetected Chrome automation and JavaScript reverse engineering through SeleniumBase's CDP Mode, allowing MCP clients to control browsers and inspect page scripts.

Category
访问服务器

README

seleniumbase-mcp — SeleniumBase CDP Mode as an MCP server

An MCP server that exposes SeleniumBase's CDP Mode (undetected, driverless Chrome automation) to any MCP client — Claude Code, Claude Desktop, Cursor, or your own agent.

Beyond the usual click/type/screenshot tools, it ships a JavaScript reverse-engineering toolkit: grep across a page's bundles, dump a function's source, hook a function to record its arguments, and intercept fetch/XHR to discover a site's private API — all without pulling megabytes of minified code into the model's context.

Também disponível em português.

Why CDP Mode

SeleniumBase's CDP Mode drives Chrome over the DevTools Protocol with no WebDriver attached, which gets past most bot detection that trivially flags Selenium and Playwright. This server keeps that property intact and adds multi-browser session management on top.

Features

  • Many browsers at once. Every browser is named by a browser_id you choose, so one agent can drive several, and several agents can share one server without stepping on each other.
  • Thread-per-browser isolation. Each browser owns a dedicated thread and event loop — required, because SeleniumBase's CDP layer calls loop.run_until_complete internally and would deadlock inside FastMCP's loop.
  • Context-frugal reverse engineering. The RE tools run JavaScript inside the page and return only the match, the slice, or the payload you asked for.
  • stdio or HTTP. Run one server per client for full isolation, or one shared HTTP server for several clients.

Install

git clone https://github.com/ileonzin/seleniumbase-mcp.git
cd seleniumbase-mcp
pip install -r requirements.txt

Requires Python 3.10+ and a local Chrome installation.

Register with a client

Claude Code

claude mcp add seleniumbase-cdp -- python /absolute/path/to/seleniumbase-mcp/sb_mcp_server.py

Claude Desktop / any client with a JSON config

{
  "mcpServers": {
    "seleniumbase-cdp": {
      "command": "python",
      "args": ["/absolute/path/to/seleniumbase-mcp/sb_mcp_server.py"]
    }
  }
}

Restart the client; the tools appear as mcp__seleniumbase-cdp__*.

Shared HTTP server (several clients, one browser pool)

python sb_mcp_server.py --http --port 8765
claude mcp add --transport http seleniumbase-cdp http://127.0.0.1:8765/mcp

Give each client its own browser_id prefix (agent1-main, agent2-main) so they don't collide.

Tools

Lifecycle

Tool What it does
browser_open(browser_id, url, headless, incognito, proxy) Launch a CDP-mode Chrome under a name you pick
browser_close(browser_id) Close it and free the Chrome process
browser_list() Names of all open browsers

Navigation and interaction

Tool What it does
navigate(browser_id, url) Go to a URL, returns the landed URL
click(browser_id, selector) Click the first CSS match
type_text(browser_id, selector, text) Type into a field
get_text(browser_id, selector) Visible text of an element
get_html(browser_id) Full page source
current_url(browser_id) Current URL
eval_js(browser_id, script) Evaluate JS, return the value
wait_for_element(browser_id, selector, timeout) Wait until visible
screenshot(browser_id) PNG returned as an image

Reverse-engineering toolkit

Tool What it does
list_scripts(browser_id) Inventory of <script> tags — URLs, sizes, same-origin flags. No content, just the map.
get_script(browser_id, target, offset, length) Read one script by index or URL substring, paginated. Same-origin only (CORS blocks the rest).
grep_js(browser_id, pattern, flags, max_hits, max_script_kb) Regex every inline and same-origin script; returns matching lines with file and line number.
get_fn_source(browser_id, expression) toString() any live function — window.app.encrypt, JSON.parse, anything defined.
hook_fn(browser_id, path) Wrap a function so its calls are recorded (args + return). Cleared on navigation.
get_hook_log(browser_id, clear) Last 200 recorded calls.
network_log(browser_id, enable) Install fetch/XHR interceptors to record URL, method, body, status.
get_network(browser_id, clear) Last 200 captured requests.

Example: find out how a site signs its API calls

browser_open(browser_id="re", url="https://target.example")
network_log(browser_id="re")                       # start watching traffic
click(browser_id="re", selector="#search-button")  # trigger the action
get_network(browser_id="re")                       # → POST /api/v2/search, X-Sig header
grep_js(browser_id="re", pattern="X-Sig|signature")
get_fn_source(browser_id="re", expression="window.__app.sign")
hook_fn(browser_id="re", path="__app.sign")        # capture real inputs
get_hook_log(browser_id="re")
browser_close(browser_id="re")

The model sees a handful of matched lines and one function body instead of a 3 MB bundle.

Notes and limits

  • Prefer headless=False on anti-bot sites. CDP Mode is meaningfully more stealthy with a visible window.
  • Cross-origin scripts are unreadable by get_script and grep_js — the page's own fetch is subject to CORS. They're reported under unreadable.
  • hook_fn captures the return value synchronously. For an async function you get the Promise object, not its resolution; the arguments — the usually interesting part — come through fine.
  • Hooks die on reload. Both hook_fn and network_log patch live objects, so navigation or a reload wipes them. Re-install after navigating.
  • Every browser_open starts a real Chrome process. Close what you open.

Intended use

Built for authorized work: testing your own sites, scraping where you have permission, security research, and understanding APIs you're allowed to integrate with. Respect the terms of service and the law of whatever you point it at.

License

MIT — see LICENSE.

推荐服务器

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 模型以安全和受控的方式获取实时的网络信息。

官方
精选