LCBro 是一款强大的浏览器自动化 MCP 服务器,支持 Playwright 和 Chrome DevTools Protocol (CDP)。它提供智能预处理、全面的日志记录和远程浏览器管理功能,专注于优化 LLM 请求成本,减少上下文使用。
# 直接使用,无需安装
npx lcbro --help
# 启动服务器
npx lcbro
# 启用 CDP 支持
npx lcbro --cdp-enabled
# 通过 npm 全局安装
npm install -g lcbro
# 验证安装
lcbro --version
# 启动服务器
lcbro
// Claude Desktop: ~/.claude/claude_desktop_config.json
{
"mcpServers": {
"lcbro": {
"command": "npx",
"args": ["-y", "lcbro"]
}
}
}
// Cursor IDE: ~/.cursor/mcp.json
{
"mcpServers": {
"lcbro": {
"command": "npx",
"args": ["-y", "lcbro"]
}
}
}
# 全局安装
npm install -g lcbro
# 验证安装
lcbro --version
# 克隆并安装
git clone https://github.com/lcbro/lcbro.git
cd lcbro
npm install
npm run build
npm start
# 使用 Docker 运行
docker run -p 3000:3000 lcbro:latest
# 导航并提取内容
npx lcbro navigate --url "https://example.com"
npx lcbro extract --format text
# 启用 CDP 支持
npx lcbro --cdp-enabled --port 3001
# 自定义日志目录
npx lcbro --logs-dir "/custom/logs" --log-level debug
{
"mcpServers": {
"lcbro": {
"command": "npx",
"args": ["-y", "lcbro"]
}
}
}
LCBro 使用 YAML 配置文件,并支持 CLI 覆盖。可以创建 config/default.yaml 文件或使用 CLI 选项:
server:
host: "localhost"
port: 3000
browser:
engine: playwright # playwright | cdp
headless: true
defaultTimeoutMs: 30000
maxContexts: 8
storageDir: /data/profiles
llm:
defaultModel: "ollama:llama3.1"
maxOutputTokens: 2000
temperature: 0
host: "localhost"
port: 11434
janPort: 1337
autoPreprocess: true
security:
allowDomains: ["example.com", "gov.br"]
blockPrivateNetworks: true
# 服务器设置
lcbro --port 3001 --host 0.0.0.0
# CDP 浏览器支持
lcbro --cdp-enabled --cdp-port 9222
# 远程 CDP 服务器
lcbro --remote-url https://cdp.example.com:9222 --remote-ssl-mode enabled
# 日志配置
lcbro --log-level debug --logs-dir /tmp/lcbro-logs
LCBro 提供了全面的命令行界面:
# 启动服务器
lcbro
# 显示帮助
lcbro --help
# 显示当前配置
lcbro config
# 使用 CDP 启动浏览器
lcbro browser:launch -b chrome -p 9222
# 管理日志文件
lcbro logs --command summary
# 测试远程 CDP 连接
lcbro test:remote -u https://cdp.example.com:9222
LCBro 支持通过环境变量进行配置:
# 本地 LLMs(推荐)
#### Ollama(免费,无需 API 密钥)
```bash
# 安装 Ollama
curl -fsSL https://ollama.ai/install.sh | sh
# 拉取模型
ollama pull llama3.1
# 配置 LCBro
export LLM_HOST=localhost
export LLM_PORT=11434
export LLM_DEFAULT_MODEL=ollama:llama3.1
# 为 JAN AI 配置 LCBro
export LLM_HOST=localhost
export LLM_JAN_PORT=1337
export LLM_DEFAULT_MODEL=jan:llama-3.1-8b
# OpenAI
export OPENAI_API_KEY=your_api_key_here
# Anthropic
export ANTHROPIC_API_KEY=your_api_key_here
# 启用 CDP 支持
export BROWSER_ENGINE=cdp
# CDP 服务器设置
export CDP_HOST=localhost
export CDP_PORT=9222
# 远程 CDP 服务器
export CDP_REMOTE_URL=https://cdp.example.com:9222
export CDP_REMOTE_SSL_MODE=enabled
export CDP_REMOTE_API_KEY=your_api_key
LCBro 在将数据发送到 LLMs 之前会自动清理和优化数据:
# 启用智能预处理
lcbro --auto-preprocess
# 配置预处理阈值
lcbro --preprocessing-threshold-html 5000
lcbro --preprocessing-threshold-text 8000
# 使用 CDP 启动浏览器
lcbro browser:launch -b chrome -p 9222 -n 3
# 连接到远程 CDP 服务器
lcbro --remote-url https://cdp.example.com:9222
# 测试远程连接
lcbro test:remote -u https://cdp.example.com:9222
# 查看日志摘要
lcbro logs --command summary
# 清理旧日志
lcbro logs --command cleanup --age 30
# 压缩日志文件
lcbro logs --command compress
LCBro 提供以下 MCP 工具:
navigate_open - 在浏览器上下文中打开新 URLnavigate_goto - 在现有上下文中导航到 URLinteract_click - 通过选择器、文本或角色点击元素interact_type - 在输入字段中输入文本interact_wait - 等待条件(选择器、网络空闲、URL 更改)extract_content - 以各种格式提取页面内容extract_table - 以 JSON 格式提取表格数据extract_attributes - 从元素中提取属性extract_screenshot - 对页面或元素进行截图session_auth - 执行身份验证序列session_manage - 管理浏览器会话和上下文llm_transform - 使用 LLM 和自定义指令转换数据llm_analyze - 使用 LLM 预处理分析内容| 属性 | 详情 |
|---|---|
| 包大小 | 压缩后 147.7 kB,解压后 759.7 kB |
| 启动时间 | < 2 秒 |
| 内存使用 | 典型情况下 < 100 MB |
| 并发会话 | 最多 8 个浏览器上下文 |
| 支持的浏览器 | Chrome、Chromium、Edge(CDP)、Playwright 浏览器 |
| Node.js 版本 | 18.x、20.x、22.x |
| 操作系统 | Windows、macOS、Linux |
| 管道 | 状态 | 描述 |
|---|---|---|
| CI/CD | 主要构建、测试和部署管道 | |
| Docker | 容器构建和多平台测试 | |
| Release | 自动发布和 npm 发布 | |
| Nightly | 扩展测试和性能基准测试 |
📋 查看所有工作流 → | 🚀 查看管道运行 →
npm install
npm run install:browsers
# 构建项目
npm run build
# 运行测试
npm test
# 运行端到端测试
npm run test:e2e
# 在本地运行 CI 管道
make ci
本项目采用 MIT 许可证 - 详情请参阅 LICENSE 文件。
git checkout -b feature/amazing-feature)git commit -m 'Add amazing feature')git push origin feature/amazing-feature)