Token导航 LogoToken导航

MCP Server · 浏览器工具

Cdp CLI

提供命令行访问Chrome DevTools协议的功能,用于自动化浏览器交互、调试网页应用和检查网络流量。

未说明官方级别未说明来源级核验工具 0
浏览器自动化命令行工具TypeScript

快速开始

公开资料没有提供安装命令,按仓库或官方文档接入。
作者 / 组织
myers
提供方
myers

工具数量

0

来源目录标注

资源数量

0

来源目录标注

提示词数量

0

来源目录标注

GitHub Star

43

仓库热度

收录来源

1 个

MCP World

选型结论

Cdp CLI 属于浏览器工具类 MCP Server,公开资料标注 0 个工具,通过传输方式未标注接入,客户端适配情况以官方文档为准,没有现成的安装命令;接入前要先准备 会话凭据。

分类

浏览器工具

传输方式

未说明

认证方式

会话凭据

部署方式

公开资料未说明

安装与配置

公开目录没有给出安装命令,需要按仓库 README安装;下面按同类条目的通用流程说明。

公开命令不是通用的启动方式,拼不出可靠配置示例;请在客户端 MCP 配置里按官方文档填写 command 和 args。

上手步骤

  1. 1

    先确认运行方式

    公开资料没有标注传输方式,先看仓库 README,确认是本地进程还是远程地址。

  2. 2

    获取服务

    公开目录没有给出安装命令,按仓库 README里的步骤安装或获取服务。

  3. 3

    写入客户端配置

    在客户端的 MCP 配置里填启动命令和参数,保存后完全退出客户端再打开,让新配置生效。

  4. 4

    验证是否可用

    连接成功后客户端会列出 0 个工具,随便调一个只读工具确认能返回结果。

接入前确认

不要直接授予不必要的文件、网络或账号权限;先核对安装命令和配置内容。

公开资料仍需确认:安装命令

详细介绍

Chrome DevTools命令行界面

Chrome DevTools Protocol(CDP)的命令行界面,针对具有NDJSON输出格式的LLM代理进行了优化。

概述

cdp-cli 提供对所有Chrome DevTools Protocol功能的CLI访问,使其易于自动化浏览器交互、调试web应用程序和检查网络流量——所有这些都可以通过命令行使用grep/tail友好的输出。

新功能

--inspect 用于控制台输出

完全展开控制台消息中的嵌套对象和数组,而不是看到 Object 或 Array(12):

# Without --inspect
cdp-cli console "MyPage"
"Config: {options: Object, values: Array(5)}"

# With --inspect - see actual values
cdp-cli console "MyPage" --inspect
"Config: {options: {debug: true, level: 3}, values: [1, 2, 3, 4, 5]}"

--user-gesture 对于单击命令

启用WebXR、全屏和其他需要用户交互的激活门控浏览器API:

# Standard click (uses Input.dispatchMouseEvent)
cdp-cli click "MyPage" "button#submit"

# User gesture click (uses Runtime.evaluate with userGesture: true)
# Required for WebXR session requests, fullscreen API, etc.
cdp-cli click "MyPage" "button#enter-vr" --user-gesture

安装

npm install -g @myerscarpenter/cdp-cli

快速开始

# Launch Chrome with remote debugging
cdp-cli launch

# List all open pages
cdp-cli tabs

# Navigate to a URL
cdp-cli new "https://example.com"

# Get page snapshot (accessibility tree)
cdp-cli snapshot "example"

# Click an element
cdp-cli click "example" "a"

# Take a screenshot
cdp-cli screenshot "example" screenshot.jpg

或者手动启动Chrome:

# macOS
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome \
  --remote-debugging-port=9222

# Linux
google-chrome --remote-debugging-port=9222

# Windows
chrome.exe --remote-debugging-port=9222

输出格式:NDJSON

所有列表命令输出 换行符分隔的JSON(NDJSON) -每行一个完整的JSON对象。此格式为:

  • LLM友好:易于编程解析
  • Grep兼容:使用标准Unix工具进行筛选
  • 可流式传输的:增量处理大型数据集

NDJSON输出示例

$ cdp-cli tabs
{"id":"A1B2C3","title":"GitHub","url":"https://github.com","type":"page"}
{"id":"D4E5F6","title":"Google","url":"https://google.com","type":"page"}

$ cdp-cli console "example"
{"type":"log","timestamp":1698234567890,"text":"Page loaded","source":"console-api"}
{"type":"error","timestamp":1698234568123,"text":"TypeError: Cannot read...","source":"exception","line":42,"url":"https://example.com/app.js"}

$ cdp-cli network "example" | grep '"type":"fetch"'
{"url":"https://api.example.com/data","method":"GET","status":200,"type":"fetch","size":4567}

命令

页面管理

标签页 -列出所有打开的浏览器页面

cdp-cli tabs

新 -创建新页面/选项卡

cdp-cli new "https://example.com"
cdp-cli new  # Empty page

去 -导航页面(URL、后退、前进、重新加载)

cdp-cli go "example" "https://github.com"
cdp-cli go "example" back
cdp-cli go "example" forward
cdp-cli go "example" reload

关闭 -关闭页面

cdp-cli close "example"
cdp-cli close A1B2C3

调试

控制台 -列出控制台消息(默认情况下输出最小,针对LLM令牌节省进行了优化)

# Minimal output (bare strings, last 10 messages)
cdp-cli console "example"
"Page loaded"
"API call successful"

# Show more messages
cdp-cli console "example" --tail 50

# Show all messages (no limit)
cdp-cli console "example" --all
# or
cdp-cli console "example" --tail -1

# Note: When truncated, stderr shows: "(N messages skipped. Use --tail M or --all to see more)"
# This warning is visible to both humans and LLM agents

# Include message type (switches to object format)
cdp-cli console "example" --with-type
{"text":"Page loaded","type":"log","source":"console-api"}
{"text":"Error: failed","type":"error","source":"exception","line":42,"url":"app.js"}

# Include timestamp
cdp-cli console "example" --with-timestamp
{"text":"Page loaded","timestamp":1698234567890}

# Include source location (url, line number for exceptions)
cdp-cli console "example" --with-source
{"text":"Error: undefined","url":"https://example.com/app.js","line":42}

# Verbose mode - all fields (shortcut for all three flags)
cdp-cli console "example" --verbose
# or
cdp-cli console "example" -v
{"text":"Error: undefined","type":"error","source":"exception","timestamp":1698234567890,"url":"app.js","line":42}

# Expand nested objects/arrays (instead of "Object" or "Array(N)")
cdp-cli console "example" --inspect
# or
cdp-cli console "example" -i

# Filter by type (still outputs bare strings by default)
cdp-cli console "example" --type error

# Collect for longer duration (2 seconds)
cdp-cli console "example" --duration 2

快照 -获取页面内容快照

# Accessibility tree (default) - great for LLM element identification!
cdp-cli snapshot "example"

# Text content only
cdp-cli snapshot "example" --format text

# DOM tree (JSON)
cdp-cli snapshot "example" --format dom

评估 -评估JavaScript表达式

cdp-cli eval "example" "document.title"
cdp-cli eval "example" "window.location.href"
cdp-cli eval "example" "Array.from(document.querySelectorAll('h1')).map(h => h.textContent)"

截图 -截图

# Save to file
cdp-cli screenshot "example" --output screenshot.jpg

# Different formats
cdp-cli screenshot "example" --output screenshot.png --format png

# Output base64 (NDJSON)
cdp-cli screenshot "example"

网络检查

网络 -列出网络请求(默认收集0.1秒)

# Collect requests (default 0.1 seconds)
cdp-cli network "example"

# Collect for longer duration (5 seconds)
cdp-cli network "example" --duration 5

# Filter by type
cdp-cli network "example" --type fetch
cdp-cli network "example" --type xhr

# Combine duration and filtering
cdp-cli network "example" --duration 5 --type fetch

输入自动化

点击 -通过CSS选择器单击元素

cdp-cli click "example" "button#submit"
cdp-cli click "example" "a.link" --double

# Use --user-gesture for WebXR, fullscreen, and other activation-gated APIs
cdp-cli click "example" "button#enter-vr" --user-gesture
cdp-cli click "example" "button#fullscreen" -g  # short flag

填充 -填写输入元素

cdp-cli fill "example" "user@example.com" "input#email"
cdp-cli fill "example" "secret123" "input[name='password']"

钥匙 -按键盘键

cdp-cli key "example" enter
cdp-cli key "example" tab
cdp-cli key "example" escape

LLM使用模式

模式1:检查和交互

# 1. List pages to find target
cdp-cli tabs | grep "example"

# 2. Get accessibility tree to understand page structure
cdp-cli snapshot "example" --format ax > page-structure.json

# 3. Parse structure (LLM can identify element selectors)
# 4. Interact with elements
cdp-cli fill "example" "query" "input#search"
cdp-cli click "example" "button[type='submit']"

# 5. Capture result
cdp-cli screenshot "example" --output result.jpg

模式2:调试Web应用程序

# 1. Navigate to app
cdp-cli new "http://localhost:3000"

# 2. Monitor console for errors (increase duration for continuous monitoring)
cdp-cli console "localhost" --duration 10 --type error

# 3. Inspect failed network requests
cdp-cli network "localhost" --duration 5 | grep '"status":4'

模式3:自动化测试

# 1. Open test page
cdp-cli new "http://localhost:8080/test.html"

# 2. Fill form
cdp-cli fill "test" "testuser" "input#username"
cdp-cli fill "test" "testpass" "input#password"
cdp-cli click "test" "button#login"

# 3. Wait and verify
sleep 2
cdp-cli eval "test" "document.querySelector('.success-message')?.textContent"

# 4. Capture evidence
cdp-cli screenshot "test" --output test-result.jpg

模式4:数据提取

# 1. Navigate to page
cdp-cli go "example" "https://example.com/data"

# 2. Extract data via JavaScript
cdp-cli eval "example" "Array.from(document.querySelectorAll('.item')).map(el => ({
  title: el.querySelector('.title').textContent,
  price: el.querySelector('.price').textContent
}))"

全局选项

  • --cdp-url -Chrome DevTools协议URL(默认值: http://localhost:9222)
  • --help -显示帮助
  • --version -显示版本

LLM代理提示

  1. 使用NDJSON解析:每一行都是一个完整的JSON对象
   const lines = output.split('\n').filter(l => l.trim());
   const objects = lines.map(l => JSON.parse(l));
  1. 利用grep进行过滤:
   cdp-cli network "example" | grep '"status":404'
   cdp-cli console "example" | grep error
  1. 使用可访问性树进行元素发现:
   cdp-cli snapshot "example" --format ax
   # Parse to find elements by role, name, etc.
   # Then construct CSS selectors for click/fill
  1. 使用Unix工具链命令:
   cdp-cli tabs | jq -r '.title'
   cdp-cli console "example" | grep error | tail -5
  1. 错误处理:所有错误均输出NDJSON "error": true
   {"error":true,"message":"Page not found: example","code":"PAGE_NOT_FOUND"}

建筑

内置:

  • TypeScript -类型安全代码
  • 纱线 -CLI参数解析
  • ws -用于CDP通信的WebSocket
  • NDJSON -LLM友好的输出格式

重复使用经过实战考验的CDP逻辑 chrome开发工具mcp.

测试

该项目包括一个使用Vitest的全面测试套件。

运行测试

# Run all tests
npm test

# Run tests in watch mode (auto-rerun on file changes)
npm run test:watch

# Run tests with coverage report
npm run test:coverage

# Run tests with interactive UI
npm run test:ui

测试结构

tests/
├── fixtures/          # Sample CDP responses and test data
│   └── cdp-responses.ts
├── mocks/             # Mock implementations
│   ├── websocket.mock.ts   # WebSocket mock for CDP
│   └── fetch.mock.ts       # Fetch mock for REST API
├── helpers.ts         # Test utilities
├── setup.ts           # Test environment setup
└── unit/              # Unit tests
    ├── output.test.ts       # Output formatting tests
    ├── context.test.ts      # CDPContext tests
    └── commands/            # Command tests
        ├── pages.test.ts
        ├── debug.test.ts
        ├── network.test.ts
        └── input.test.ts

测试覆盖率

当前覆盖范围:

  • 输出格式化:100%(10次测试)
  • CDP上下文:~95%(23次测试)
  • 页面命令:约90%(11次测试)
  • 总体:80%以上的行、函数和语句

编写新测试

测试使用模拟的WebSocket和fetch,因此 不需要运行Chrome实例:

import { describe, it, expect, beforeEach } from 'vitest';
import { CDPContext } from '../src/context.js';
import { installMockFetch } from './mocks/fetch.mock.js';

describe('My Test', () => {
  beforeEach(() => {
    installMockFetch(); // Mock CDP REST API
  });

  it('should test something', async () => {
    const context = new CDPContext();
    const pages = await context.getPages();
    expect(pages).toHaveLength(3);
  });
});

持续集成

测试在每次提交和拉取请求时自动运行(如果配置了CI)。

许可证

麻省理工学院

相关项目

______________________________________________________________________

专为LLM代理商打造 -每个命令都输出结构化、可解析、grep友好的数据。

工具与能力

工具数量

0

资源数量

0

提示词数量

0

能力标签

浏览器自动化TypeScript本地部署网页调试网络检查命令行工具LLM集成

数量来自来源目录的标注,具体工具清单以官方文档为准。

典型使用场景

自动操作网页

打开页面、点击、填表,把浏览器动作交给模型执行。

抓结构化数据

把页面内容整理成表格或 JSON,省掉手工复制粘贴。

走一遍关键流程

按步骤检查页面是否正常,回归时少漏环节。

选择建议

值得选的地方

  • 只提供 0 个工具,职责集中,接入后不容易误操作。
  • 公开说明写得比较完整,接入前能看清能力边界。

先想清楚的地方

  • 公开资料没有可直接复制的安装命令,第一次接入要自己找入口。
  • 需要自备会话凭据,没有凭据没法直接试。
  • 公开摘要偏短,具体能力和限制要回到仓库确认。

更适合

  • 需要在浏览器工具场景里让模型直接调用外部能力的人。
  • 愿意照着官方文档一步步配环境的人。

不太适合

  • 暂时拿不到会话凭据的人。
  • 希望一条命令就装好、不想看文档的人。
  • 需要厂商级 SLA 和技术支持的生产环境。

同类对比

5 个同类
MCP Server工具数传输方式安装命令收录来源最后核验
Cdp CLI

MCP World · 本页

0未说明未标注1 个2026-05-17
Fetch 9a2682de

MCP.so

1SSE有3 个2026-05-17
Browser 738d52bc

MCP World

0stdio有1 个2026-05-17
Playwright MCP Server

MCP.so

21stdio有4 个2026-05-17
Skyvern MCP

MCP World

0stdio有2 个2026-05-17

按同分类和工具数量挑出最接近的几条,字段以各自详情页为准。

常见问题

5 条

Cdp CLI 怎么安装?

公开目录没有给出可以直接复制的安装命令,需要按仓库 README里的步骤安装;装好后写进客户端的 MCP 配置再重启。

Cdp CLI 怎么在 Claude Desktop、Cursor 里配置?

它是传输方式未标注,客户端配置里要写启动命令和参数,运行环境是 未标注;保存后完全退出客户端再打开,配置才会生效。

Cdp CLI 收费吗?

本站只整理公开资料,不代收费用,也没有标注具体价格。是否收费取决于服务本身和背后的接口额度,正式使用前按官方说明确认。

Cdp CLI 需要 API Key 吗?

公开资料标注的认证方式是会话凭据,也就是要先拿到凭据才能连上;凭据只填在自己本地的配置里,不要写进公开仓库。

Cdp CLI 支持哪些客户端?

公开资料没有标注具体客户端;能配置本地 MCP 命令的客户端都能接,配置方式参照官方文档。

来源信息

继续浏览同类 MCP