mcpField
P
perplexity-comet-mcp

perplexity-comet-mcp

本地服务
github.com/RapierCraft浏览器自动化5318 周前更新

关于 perplexity-comet-mcp

perplexity-comet-mcp 是一个 MCP 服务,用于将 Claude Code 与 Perplexity Comet 浏览器连接起来,由 Comet 自主完成网页浏览、研究和多标签页工作流。它是 hanzili/comet-mcp 的增强分支,新增 Windows 与 WSL 支持及标签页管理。

主要功能

  1. 01自主网页浏览与数据提取
  2. 02Deep Research 研究模式
  3. 03标签页跟踪、切换与关闭
  4. 04基于稳定性的响应完成检测
  5. 05连接断开后自动指数退避重连
  6. 06支持 Windows、WSL 与 macOS

适用场景

  1. 01在编码过程中由 Comet 查询资料或抓取网页数据
  2. 02访问需要登录的网页内容
  3. 03在多标签页工作流中管理浏览器标签页
  4. 04向社交媒体或表单上传文件

MCP 相关

该项目是一个 MCP 服务,向 MCP 客户端(如 Claude Code)暴露 comet_connect、comet_ask、comet_poll、comet_tabs、comet_upload 等工具,并通过 Chrome DevTools Protocol 控制 Comet 浏览器。

配置

本地服务的配置在各客户端中通用,复制后粘贴到客户端的 MCP 配置文件即可。

mcp.json · 通用配置
{
"mcpServers": {
"rapiercraft-perplexity-comet": {
"command": "npx",
"args": [
"-y",
"perplexity-comet-mcp"
],
"env": {
"COMET_PATH": "<COMET_PATH>",
"COMET_PORT": "<COMET_PORT>"
}
}
}
}
启动命令npx -y perplexity-comet-mcp
需要配置的环境变量
COMET_PATHCustom path to Comet browser executable (optional)
COMET_PORTChrome DevTools Protocol port (default: 9223)

本地服务需要在你的电脑上安装运行环境(如 Node.js 18+)。各客户端的配置文件位置不同,请参考客户端文档。

安装包
npmperplexity-comet-mcp2.5.0

工具

8

收录的工具列表 · 更新于 2 周前

此工具无需参数。

详细介绍

Perplexity Comet MCP

npm version License: MIT Node.js Version TypeScript MCP Compatible Platform

生产级 MCP(Model Context Protocol)服务,可将 Claude Code 与 Perplexity 的 Comet 浏览器连接起来,实现自主网页浏览、研究和多标签页工作流管理。


为什么选择 Perplexity Comet MCP?

方式局限
搜索 API内容是静态文本,无法交互,也不支持登录
浏览器自动化单 Agent 模型会占用大量上下文,分散注意力
Perplexity Comet MCPClaude 编码时,Comet 自主处理浏览任务

这是 hanzili/comet-mcp 的增强分支,新增了 Windows 支持、智能完成检测、稳健的连接处理和完整的标签页管理。


功能

核心能力
  • 自主网页浏览 - Comet 负责导航、点击、输入和提取数据,让 Claude 专注于编码
  • 深度研究模式 - 利用 Perplexity 的研究能力进行全面分析
  • 登录墙处理 - 通过真实浏览器会话访问需登录的内容
  • 动态内容 - 完全支持 JavaScript 渲染和交互
增强功能(此分支新增)
功能描述
Windows/WSL 支持完全兼容 Windows 和 WSL 环境
标签页管理跟踪、切换和关闭浏览器标签页,并提供保护
智能完成检测无需固定超时即可检测响应是否完成
自动重连连接中断后通过指数退避机制恢复
单次执行可靠性操作前进行健康检查,确保执行稳定
Agent 式自动触发根据自然语言提示自动触发浏览器操作

与原版比较

能力原版增强版
平台支持macOSWindows、WSL、macOS
可用工具68(+comet_tabs、+comet_upload)
完成检测固定超时基于稳定性
连接恢复无带退避机制的自动重连
标签页管理无完整的注册表和控制功能
健康监控无缓存健康检查
最后一个标签页保护无防止浏览器崩溃

安装

先决条件
通过 npm 安装
npm install -g perplexity-comet-mcp
从源代码安装
git clone https://github.com/RapierCraft/perplexity-comet-mcp.git
cd perplexity-comet-mcp
npm install
npm run build
配置 Claude Code

将以下内容添加到 Claude Code MCP 设置(~/.claude/settings.json 或 VS Code 设置):

{
  "mcpServers": {
    "comet-bridge": {
      "command": "node",
      "args": ["/path/to/perplexity-comet-mcp/dist/index.js"]
    }
  }
}

**Windows 用户:**请使用完整的 Windows 路径:

{
  "mcpServers": {
    "comet-bridge": {
      "command": "node",
      "args": ["C:\\Users\\YourName\\perplexity-comet-mcp\\dist\\index.js"]
    }
  }
}

工具参考

comet_connect

建立与 Comet 浏览器的连接。如果浏览器尚未运行,则自动启动。

Parameters: None
Returns: Connection status message

示例:

> comet_connect
Comet started with debug port 9223
Connected to Perplexity (cleaned 2 old tabs)

comet_ask

向 Comet 发送提示词并等待完整响应。遇到 URL 和以操作为导向的请求时,会自动触发 Agent 式浏览。

Parameters:
  - prompt (required): Question or task for Comet
  - newChat (optional): Start fresh conversation (default: false)
  - timeout (optional): Max wait time in ms (default: 120000)

Returns: Complete response text

示例:

# Simple research query
> comet_ask "What are the latest features in Python 3.12?"

# Agentic browsing (auto-triggered)
> comet_ask "Go to github.com/trending and list top Python repos"

# Site-specific data extraction
> comet_ask "Check the price of iPhone 15 on amazon.com"

comet_poll

检查正在进行的任务的状态和进度。任务完成后返回响应。

Parameters: None
Returns: Status (IDLE/WORKING/COMPLETED), steps taken, or final response

示例:

> comet_poll
Status: WORKING
Browsing: https://github.com/trending
Current: Scrolling page

Steps:
  - Preparing to assist you
  - Navigating to github.com
  - Clicking on Trending
  - Scrolling page

comet_stop

如果当前 Agent 式任务偏离方向,则停止该任务。

Parameters: None
Returns: Confirmation message

comet_screenshot

截取当前浏览器视图的屏幕截图。

Parameters: None
Returns: PNG image data

comet_tabs

查看和管理浏览器标签页。适用于多标签页工作流。

Parameters:
  - action (optional): "list" (default), "switch", or "close"
  - domain (optional): Domain to match (e.g., "github.com")
  - tabId (optional): Specific tab ID

Returns: Tab listing or action confirmation

示例:

# List all external tabs
> comet_tabs
2 browsing tab(s) open:
  - AGENT-BROWSING: github.com [ACTIVE]
    URL: https://github.com/trending
  - AGENT-BROWSING: stackoverflow.com
    URL: https://stackoverflow.com/questions

# Switch to a tab
> comet_tabs action="switch" domain="stackoverflow.com"
Switched to stackoverflow.com (https://stackoverflow.com/questions)

# Close a tab (protected if last tab)
> comet_tabs action="close" domain="github.com"
Closed github.com

标签页保护:

  • 无法关闭最后一个外部浏览标签页(防止 Comet 崩溃)
  • 内部标签页(chrome://、Perplexity UI)会自动过滤

comet_mode

切换 Perplexity 搜索模式,以满足不同使用场景。

Parameters:
  - mode (optional): "search", "research", "labs", or "learn"

Returns: Current mode or confirmation of switch
模式使用场景
search快速网页搜索
research深入、全面的分析
labs数据分析与可视化
learn教育类讲解

comet_upload

将文件上传到网页上的文件输入元素。适用于在社交媒体上发布图片、在表单中附加文件或上传文档。

Parameters:
  - filePath (required): Absolute path to the file to upload
  - selector (optional): CSS selector for specific file input
  - checkOnly (optional): If true, only checks what file inputs exist

Returns: Success message or error with available inputs

示例:

# Upload an image to the first file input found
> comet_upload filePath="/home/user/screenshot.png"
File uploaded successfully: /home/user/screenshot.png

# Check what file inputs exist on the page
> comet_upload filePath="dummy" checkOnly=true
Found 2 file input(s) on the page:
  1. #image-upload
  2. input[name="attachment"]

# Upload to a specific input
> comet_upload filePath="/home/user/doc.pdf" selector="#attachment-input"
File uploaded successfully: /home/user/doc.pdf

发布图片的工作流:

  1. 导航到帖子创建页面(例如 Reddit、Twitter)
  2. 使用 comet_upload checkOnly=true 查找文件输入元素
  3. 使用 comet_upload filePath="..." selector="..." 附加文件
  4. 继续提交表单

架构

┌─────────────────┐     MCP Protocol      ┌──────────────────┐
│   Claude Code   │ ◄──────────────────► │  Perplexity      │
│   (Your IDE)    │                       │  Comet MCP       │
└─────────────────┘                       └────────┬─────────┘
                                                   │
                                          Chrome DevTools
                                            Protocol
                                                   │
                                          ┌────────▼─────────┐
                                          │  Comet Browser   │
                                          │  (Perplexity)    │
                                          └──────────────────┘
                                                   │
                                          ┌────────▼─────────┐
                                          │   External       │
                                          │   Websites       │
                                          └──────────────────┘
核心组件
组件用途
index.tsMCP 服务和工具处理程序
cdp-client.ts带有重连逻辑的 Chrome DevTools Protocol 客户端
comet-ai.tsPerplexity 交互、提示词提交、响应提取
types.ts标签页、状态和 CDP 类型的 TypeScript 接口

配置

环境变量
变量描述默认值
COMET_PATHComet 可执行文件的自定义路径自动检测
COMET_PORTCDP 调试端口9223
自定义 Comet 路径
# Windows
set COMET_PATH=C:\Custom\Path\comet.exe

# macOS/Linux
export COMET_PATH=/custom/path/to/Comet.app/Contents/MacOS/Comet

故障排除

连接问题

问题: Error: Failed to list targets: ECONNREFUSED

解决方案:

  1. 确保已安装 Comet 浏览器
  2. 关闭所有现有的 Comet 实例
  3. 运行 comet_connect,使用正确的标志自动启动

问题: 长时间运行的任务期间出现 WebSocket connection closed

解决方案: 此版本会自动处理重连。如果问题持续存在,请增加超时时间:

comet_ask prompt="..." timeout=180000

Windows 特定问题

问题: Windows 上出现 ECONNRESET 错误

解决方案: 此版本包含基于 PowerShell 的 fetch 变通方案。请确保:

  1. PATH 中有 PowerShell
  2. 防火墙未阻止 localhost:9223

问题: Windows 上找不到 Comet

解决方案: 设置自定义路径:

set COMET_PATH=%LOCALAPPDATA%\Perplexity\Comet\Application\comet.exe

WSL 特定问题

问题: WSL cannot connect to Windows localhost:9223

说明: 默认情况下,WSL2 使用独立的网络命名空间。MCP 使用 Chrome DevTools Protocol(CDP),需要通过 WebSocket 连接到 Windows localhost。

解决方案: 启用 WSL 镜像网络:

  1. 创建或编辑 %USERPROFILE%\.wslconfig(例如,C:\Users\YourName\.wslconfig):
[wsl2]
networkingMode=mirrored
  1. 重启 WSL:
wsl --shutdown
  1. 打开新的 WSL 终端并重试。

替代方案: 改为从 Windows PowerShell 运行 Claude Code。


问题: 出现 UNC paths are not supported 警告

说明: 这是从 WSL 启动 PowerShell 时出现的无害警告。MCP 会自动处理。


标签页管理问题

问题: Cannot close - this is the only browsing tab

说明: 这是有意设置的保护措施。Comet 至少需要一个外部标签页。请先打开另一个标签页,再关闭不需要的标签页。


开发

从源代码构建
git clone https://github.com/RapierCraft/perplexity-comet-mcp.git
cd perplexity-comet-mcp
npm install
npm run build
在开发环境中运行
npm run dev
运行测试
npm test
项目结构
perplexity-comet-mcp/
├── src/
│   ├── index.ts        # MCP server entry point
│   ├── cdp-client.ts   # CDP connection management
│   ├── comet-ai.ts     # AI interaction logic
│   └── types.ts        # TypeScript definitions
├── dist/               # Compiled JavaScript
├── package.json
├── tsconfig.json
└── README.md

贡献

欢迎贡献。提交拉取请求前,请阅读 CONTRIBUTING.md。

开发指南
  1. 确保符合 TypeScript 严格模式
  2. 为新功能添加测试
  3. 更新 API 变更的文档
  4. 遵循现有代码风格

归属

本项目是由 hanzili 开发的 comet-mcp 的增强分支。

RapierCraft 的主要增强
  • 支持 Windows 和 WSL 平台
  • 标签页管理系统(comet_tabs 工具)
  • 智能完成检测
  • 指数退避自动重新连接
  • 健康检查缓存
  • Agent 提示词自动转换
  • 保护最后一个标签页
  • 过滤内部标签页

许可证

MIT 许可证——详情请参阅 LICENSE。


链接


由 RapierCraft 精心打造

评论

支持 Markdown

第一次接触 MCP?

从协议是什么,到在客户端里装上第一个服务,这几条回答覆盖了大多数入门问题。

一个开放协议,规定了 AI 应用如何以统一方式连接外部工具与数据源。客户端负责与模型对话,MCP 服务负责提供工具、资源和提示模板,两者通过标准消息通信,同一个服务可以被不同客户端复用。