Skip to main content
Glama

cdpilot

从终端进行零依赖浏览器自动化。一条命令,完全掌控。

npm version npm downloads License: MIT Node.js MCP Compatible cdpilot MCP server

快速开始

npx cdpilot launch    # Start browser with CDP
npx cdpilot go https://example.com
npx cdpilot shot      # Take screenshot

无需配置文件。无需样板代码。只需 npx 即可运行。

Related MCP server: Scout

为什么选择 cdpilot?

AI 代理和开发者需要能够直接运行的浏览器控制工具:

  • 零配置npx cdpilot launch 启动一个隔离的浏览器会话

  • 零依赖 — 无需 Puppeteer、Playwright 或 Selenium。纯粹的 HTTP CDP 协议

  • 40+ 命令 — 导航、点击、输入、截图、网络、控制台、无障碍功能等

  • AI 代理友好 — 专为 Claude、GPT、Gemini 及任何 LLM 工具使用工作流设计

  • 隔离会话 — 您的个人浏览器保持不变。cdpilot 在其自己的配置文件中运行

  • 视觉反馈 — 绿色光晕覆盖、光标可视化、点击涟漪和按键显示,让您在自动化过程中随时了解状态

  • 多项目隔离 — 每个项目自动获得自己的浏览器实例和端口,互不冲突

  • AI 控制警告 — 当您在自动化运行期间移动鼠标时,会出现红色提示通知

  • 隐私优先 — 所有操作均在本地运行。没有任何数据离开您的机器

浏览器选择(工作负载感知自动选择)

cdpilot 会根据您的操作选择合适的浏览器。auto(默认)采用双轴策略 — 扩展工作负载 × 平台稳定性:

您的工作负载

自动选择顺序

已注册扩展 (ext-install)

vivaldi → brave → edge → chromium → chrome

无扩展(纯自动化)

chrome → vivaldi → edge → chromium → brave

随时可以覆盖:

cdpilot browser            # show current pick + reason
cdpilot browser vivaldi    # pin to Vivaldi
cdpilot browser auto       # restore smart default

为什么要这样拆分?

  • Chrome 147+ 会静默丢弃 --load-extension(针对未打包的扩展,无错误,无警告)。经核实 — chrome://extensions 显示为 0 项。

  • Vivaldi、Brave、Edge、Chromium 支持 --load-extension(已测试)。

  • macOS 26 (Tahoe) 上,Brave 1.89 在运行约 7 分钟后会确定性地崩溃(ThreadPoolForegroundWorker 中的 SIGTRAP)。cdpilot 会检测操作系统并自动降级 Brave,直到 Brave 发布修复版本。

每个浏览器都有其独立的配置文件(~/.cdpilot/.../profile-vivaldi 等),因此切换永远不会导致偏好设置损坏。

安装

# Use directly (no install needed)
npx cdpilot <command>

# Or install globally
npm i -g cdpilot

要求: Node.js 18+ 以及以下浏览器之一:Brave Browser、Google Chrome 或 Chromium。

首次设置

npx cdpilot setup     # Auto-detect browser, create isolated profile
npx cdpilot launch    # Start browser with CDP enabled
npx cdpilot status    # Check connection

命令

导航与内容

cdpilot go <url>              # Navigate to URL
cdpilot content               # Get page text content
cdpilot html                  # Get page HTML
cdpilot shot [file]           # Take screenshot (PNG)
cdpilot pdf [file]            # Save page as PDF

交互

cdpilot click <selector>      # Click element
cdpilot type <selector> <text># Type into input
cdpilot fill <selector> <val> # Set input value (React-compatible)
cdpilot submit <form>         # Submit form
cdpilot hover <selector>      # Hover element
cdpilot keys <combo>          # Keyboard shortcut (ctrl+a, enter, etc.)
cdpilot scroll-to <selector>  # Scroll element into view
cdpilot drag <from> <to>      # Drag and drop

调试

cdpilot console [url]         # Capture console logs
cdpilot network [url]         # Monitor network requests
cdpilot debug [url]           # Full diagnostic (console+network+perf+shot)
cdpilot perf                  # Performance metrics
cdpilot eval <js>             # Execute JavaScript

标签页管理

cdpilot tabs                  # List open tabs
cdpilot new-tab [url]         # Open new tab
cdpilot switch-tab <id>       # Switch to tab
cdpilot close-tab [id]        # Close tab
cdpilot close                 # Close active tab

网络控制

cdpilot throttle slow3g       # Simulate slow 3G
cdpilot throttle fast3g       # Simulate fast 3G
cdpilot throttle offline      # Go offline
cdpilot throttle off          # Back to normal
cdpilot proxy <url>           # Set proxy
cdpilot proxy off             # Remove proxy

请求拦截

cdpilot intercept block <pattern>                    # Block requests
cdpilot intercept mock <pattern> <json-file>         # Mock responses
cdpilot intercept headers <pattern> <header:value>   # Add headers
cdpilot intercept list                               # List active rules
cdpilot intercept clear                              # Clear all rules

设备模拟

cdpilot emulate iphone        # iPhone emulation
cdpilot emulate ipad          # iPad emulation
cdpilot emulate android       # Android emulation
cdpilot emulate reset         # Back to desktop

地理位置

cdpilot geo istanbul          # Set location to Istanbul
cdpilot geo london            # Set location to London
cdpilot geo 41.01 28.97       # Custom coordinates
cdpilot geo off               # Remove override

无障碍功能

cdpilot a11y                  # Full accessibility tree
cdpilot a11y summary          # Quick summary
cdpilot a11y find <role>      # Find elements by ARIA role

会话管理

cdpilot session               # Current session info
cdpilot sessions              # List all sessions
cdpilot session-close [id]    # Close session

高级功能

cdpilot cookies [domain]      # List cookies
cdpilot storage               # localStorage contents
cdpilot upload <sel> <file>   # Upload file to input
cdpilot multi-eval <js>       # Execute JS in all tabs
cdpilot headless [on|off]     # Toggle headless mode
cdpilot frame list            # List iframes
cdpilot dialog auto-accept    # Auto-accept dialogs
cdpilot permission grant geo  # Grant geolocation

隐身与验证码

零依赖的反指纹层 — 修补了 navigator.webdriverchrome.runtime、插件(正确的 PluginArray 继承)、WebGL vendor/renderer、权限、硬件并发和 Worker 构造函数。在任何页面脚本运行之前通过 Page.addScriptToEvaluateOnNewDocument 注入。默认禁用;需手动开启。

cdpilot stealth on            # enable fingerprint patches (opt-in)
cdpilot stealth off           # disable (default)
cdpilot stealth status        # show which patches are applied

cdpilot captcha-check         # JSON detection of Turnstile/hCaptcha/reCAPTCHA/
                              # DataDome/PerimeterX/Arkose/GeeTest. Exit 0/3
cdpilot captcha-wait [sec]    # block until user solves (interactive)
                              # or poll with JSON stream (non-interactive)

已通过公共机器人检测面板验证:

  • bot.sannysoft.com: 24/24 通过 (WebDriver, Chrome obj, Plugins as PluginArray, WebGL, PHANTOM_, HEADCHR_, SELENIUM_DRIVER)

  • bot.incolumitas.com intoli: 6/6 OK — new-tests: 6/7 OK (一个失败 = 纯 CDP 存在,无法通过 JS 修补)

  • nowsecure.nl (Cloudflare 全挑战): 通过

  • arh.antoinevastel.com/areyouheadless: "You are not Chrome headless"

可靠性

cdpilot browser [name|auto]   # workload-aware browser selection
cdpilot health                # JSON: alive, port, tabs, browser, today's crashes

cdpilot health 专为 shell 守护进程设计:

until cdpilot health >/dev/null; do cdpilot launch; sleep 2; done

显示 macOS 上 ~/Library/Logs/DiagnosticReports/ 中今日的 Brave 崩溃次数 — 在自动化静默停滞前发现性能退化。

与 AI 代理配合使用

cdpilot 旨在作为工具被 AI 代理调用:

Claude Code (MCP)

{
  "mcpServers": {
    "cdpilot": {
      "command": "npx",
      "args": ["cdpilot", "mcp"]
    }
  }
}

任何 LLM (工具使用)

{
  "name": "browser",
  "description": "Control a browser via CDP",
  "parameters": {
    "command": "go https://example.com"
  }
}

Python (子进程)

import subprocess
result = subprocess.run(["npx", "cdpilot", "go", url], capture_output=True, text=True)
print(result.stdout)

环境变量

变量

默认值

描述

CDP_PORT

9222

CDP 调试端口

CHROME_BIN

自动检测

浏览器二进制路径

CDPILOT_PROFILE

~/.cdpilot/profile

隔离的浏览器配置文件

BROWSER_SESSION

自动

会话标识符

工作原理

┌─────────────┐     HTTP/WebSocket      ┌──────────────┐
│  cdpilot │ ◄──────────────────────► │ Brave/Chrome │
│   (CLI)     │    Chrome DevTools       │  (CDP mode)  │
└─────────────┘     Protocol             └──────────────┘
       │                                        │
       │  Zero dependencies                     │  Isolated profile
       │  Pure HTTP + WebSocket                 │  Separate from your
       │  ~2500 lines, single file              │  personal browser
       └────────────────────────────────────────┘

无需 Puppeteer。无需 Playwright。无需 Selenium。 仅直接进行 CDP 通信。

对比

特性

cdpilot

Puppeteer

Playwright

Selenium

安装大小

~50KB

400MB+

200MB+

100MB+

依赖项

0

50+

30+

Java + 驱动

设置时间

即时

分钟

分钟

繁琐

AI 代理就绪

手动

手动

手动

浏览器下载

是 (Chromium)

是 (3 浏览器)

CLI 优先

否 (库)

否 (库)

MCP 支持

商业化 / 专业版(即将推出)

cdpilot CLI 将永远是免费且开源的 (MIT)。

未来的付费服务:

  • cdpilot cloud — 远程浏览器实例,无需本地浏览器

  • 团队仪表板 — 共享会话、审计日志、使用分析

  • 优先支持 — 为企业集成提供直接帮助

安全性

  • 隔离的浏览器配置文件 — cdpilot 在 ~/.cdpilot/profile 中运行,与您的日常浏览器分开。您的 Cookie、密码和历史记录永远不会暴露。

  • 无任意文件访问 — MCP 截图文件名经过清理,并限制在截图目录内。路径遍历被阻止。

  • 安全的 CSS 选择器 — 传递给 querySelector 的所有选择器都经过 JSON 转义,以防止注入。

  • 无网络暴露 — CDP 仅监听 127.0.0.1。默认情况下无法进行远程连接。

  • 无依赖项 — 零 npm/Python 运行时依赖意味着零供应链攻击面。

发现漏洞?请直接通过电子邮件联系维护者,而不是公开提交 issue。

路线图

这是唯一内置测试断言的浏览器 MCP。以下是我们已经发布和即将推出的功能:

已发布

  • [x] 60+ CLI 命令(导航、点击、填写、截图、PDF、控制台、网络...)

  • [x] 用于 AI 代理集成的 MCP 服务器 (Claude Code, Cursor 等)

  • [x] 10 个内置测试断言 — assert, assert-url, assert-title, assert-count, assert-value, assert-attr, assert-visible/hidden, wait-for, check (批量), screenshot-diff

  • [x] 无障碍树快照 (a11y-snapshot) — 带有 @ref 引用的结构化数据,比截图减少 500 倍 token 消耗

  • [x] Token 高效截图 — 元素级裁剪(小 13 倍)、JPEG 质量控制、格式选择

  • [x] 视觉回退 (describe) — 一次调用即可获取 a11y + 截图 + 文本

  • [x] 带注释的截图 — 交互元素上的 @N 徽章覆盖

  • [x] 自动等待 — 基于 MutationObserver,5 秒自动元素等待

  • [x] 批量命令 — 通过 stdin 管道传输 JSON 数组以进行多步自动化

  • [x] 视觉反馈系统(持续的绿色光晕、光标、涟漪、按键显示)

  • [x] AI 控制警告提示(用户在自动化期间交互时发出红色警告)

  • [x] 多项目浏览器隔离(每个项目拥有自己的端口 + 配置文件)

  • [x] 预检向导(首次运行时自动安装依赖项)

  • [x] 持久化 MCP 光晕(在整个 AI 会话期间保持显示,类似于 Claude 的橙色光晕)

  • [x] DevExtension 系统(无需浏览器商店的原生 JS 注入)

  • [x] 智能命令smart-click, smart-fill, smart-select — 通过可见文本交互,无需 CSS 选择器,无需 LLM

  • [x] 数据提取 (extract) — 文本、JSON 或列表格式的结构化 DOM 数据

  • [x] 页面观察 (observe) — 列出所有带有可用操作的交互元素

  • [x] 脚本运行器 (run) — 执行带有成功/失败报告的 .cdp 脚本文件

即将推出

  • [ ] iframe 和 Shadow DOM 支持 — 与 iframe 和 shadow root 内部的元素交互

  • [ ] 会话录制与回放 — 录制浏览器会话并确定性地回放它们

  • [ ] 隐身模式 (专业版) — 类人鼠标/打字、反指纹、验证码解决

  • [ ] cdpilot Cloud — 托管浏览器会话 API,REST + WebSocket MCP 端点

  • [ ] Chrome 扩展 — 无需 CLI 即可从任何浏览器使用 cdpilot

  • [ ] 性能审计 — 通过 CDP Performance 域获取核心 Web 指标 (LCP, CLS, INP)

  • [ ] WCAG 无障碍审计 — 自动化的 a11y 合规性报告

  • [ ] Claude Code Skill 模式 — 除了 MCP 之外,作为 .claude/skills/ 技能运行

有想法吗?提交 issue 或提交 PR!

贡献

git clone https://github.com/mehmetnadir/cdpilot.git
cd cdpilot
npm install
npm test

欢迎提交 PR!请先阅读 CONTRIBUTING.md

许可证

MIT — 随心所欲。


Related MCP Connectors

Related MCP Servers

  • A
    license
    Not graded
    quality
    A
    maintenance
    Reliable, scalable browser infrastructure for AI agents. Route, pool, and failover across any browser provider. 8 built-in browser tools using raw Chrome CDP - navigate, screenshot, snapshot, interact, evaluate. Zero-config with auto Chrome detection & concurrent sessions support
    518 npm
    10
    MIT
  • A
    license
    Not graded
    quality
    A
    maintenance
    single-binary MCP server that gives AI agents a browser. 66 tools for navigation, form filling, data extraction, screenshots, and DOM diffing — built on pure Chrome DevTools Protocol.
    13
    MIT
  • A
    license
    Not graded
    quality
    C
    maintenance
    Lightweight browser automation server for AI agents, enabling fast (10-25ms per action), structured observations and semantic selectors with zero token overhead.
    6
    Apache 2.0
  • A
    license
    Not graded
    quality
    C
    maintenance
    Enables AI agents to scrape web pages, fill forms, take screenshots, and extract structured data via Chrome DevTools Protocol with zero external dependencies.
    MIT