困惑彗星MCP
](https://www.npmjs.com/package/perplexity-comet-mcp)  ](https://nodejs.org)   
一个生产级MCP(模型上下文协议)服务器,将Claude Code与Perplexity的Comet浏览器连接起来,用于自主网页浏览、研究和多标签工作流管理。
______________________________________________________________________
为什么困惑彗星MCP?
| 方法 | 限制 |
|---|---|
| 搜索API | 静态文本,无交互,无登录支持 |
| 浏览器自动化 | 单代理模型压倒了上下文,分散了焦点 |
| 困惑彗星MCP | Claude编码,而Comet自主处理浏览 |
这是一个显著增强的fork 汉兹利/彗星mcp Windows支持、智能完成检测、强大的连接处理和完整的标签管理。
______________________________________________________________________
特性
核心能力
- 自主Web浏览 -Comet导航、点击、键入和提取数据,而Claude则专注于编码
- 深度研究模式 -利用困惑的研究能力进行全面分析
- 登录墙处理 -通过真实的浏览器会话访问经过身份验证的内容
- 动态内容 -完整的JavaScript渲染和交互支持
增强功能(此分叉中的新功能)
| 特性 | 描述 |
|---|---|
| Windows/WSL支持 | 与Windows和WSL环境完全兼容 |
| 选项卡管理 | 使用保护功能跟踪、切换和关闭浏览器选项卡 |
| 智能完成 | 检测响应完成情况,无固定超时 |
| 自动重新连接 | 从连接中断中指数级回退恢复 |
| 一次性可靠性 | 操作前健康检查,以确保执行一致 |
| 代理自动触发 | 根据自然提示自动触发浏览器操作 |
______________________________________________________________________
与原版比较
| 功能 | 原始 | 增强 |
|---|---|---|
| 平台支持 | macOS | Windows、WSL、macOS |
| 可用工具 | 6 | 8(+comet_abs,+comet_pload) |
| 完成检测 | 固定超时 | 基于稳定性 |
| 连接恢复 | 无 | 通过回退自动重新连接 |
| 选项卡管理 | 无 | 完全注册表和控制 |
| 健康监测 | 无 | 缓存的健康检查 |
| 最后标签保护 | 无 | 防止浏览器崩溃 |
______________________________________________________________________
安装
先决条件
- Node.js 18或更高版本
- 困惑彗星浏览器 安装
- Claude Code或兼容的MCP客户端
通过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代码
添加到您的Claude Code MCP设置中(~/.claude/settings.json 或VS代码设置):
{
"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"]
}
}
}______________________________________________________________________
工具参考
come_connect
建立与Comet浏览器的连接。如果未运行,则自动启动。
Parameters: None
Returns: Connection status message例子:
> comet_connect
Comet started with debug port 9223
Connected to Perplexity (cleaned 2 old tabs)______________________________________________________________________
comes_ask
向Comet发送提示并等待完整的响应。自动触发URL和面向操作的请求的代理浏览。
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"______________________________________________________________________
come_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______________________________________________________________________
come_stop
如果当前代理任务偏离轨道,请停止它。
Parameters: None
Returns: Confirmation message______________________________________________________________________
comes_creenshot
捕获当前浏览器视图的屏幕截图。
Parameters: None
Returns: PNG image data______________________________________________________________________
come_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://、困惑UI)会自动过滤
______________________________________________________________________
come_mode
为不同的用例切换困惑搜索模式。
Parameters:
- mode (optional): "search", "research", "labs", or "learn"
Returns: Current mode or confirmation of switch| 模式 | 用例 |
|---|---|
| 搜索 | 快速网络搜索 |
| 研究 | 深入、全面的分析 |
| 实验室 | 数据分析和可视化 |
| 学习 | 教育解释 |
______________________________________________________________________
come_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发布图像的工作流程:
- 导航到帖子创建页面(例如Reddit、Twitter)
- 使用
comet_upload checkOnly=true查找文件输入 - 使用
comet_upload filePath="..." selector="..."附加文件 - 继续提交表单
______________________________________________________________________
建筑
┌─────────────────┐ MCP Protocol ┌──────────────────┐
│ Claude Code │ ◄──────────────────► │ Perplexity │
│ (Your IDE) │ │ Comet MCP │
└─────────────────┘ └────────┬─────────┘
│
Chrome DevTools
Protocol
│
┌────────▼─────────┐
│ Comet Browser │
│ (Perplexity) │
└──────────────────┘
│
┌────────▼─────────┐
│ External │
│ Websites │
└──────────────────┘关键组件
| 组件 | 目的 |
|---|---|
index.ts | MCP服务器和工具处理程序 |
cdp-client.ts | 带有重新连接逻辑的Chrome DevTools协议客户端 |
comet-ai.ts | 困惑互动、及时提交、响应提取 |
types.ts | 选项卡、状态和CDP类型的TypeScript接口 |
______________________________________________________________________
配置
环境变量
| 变量 | 描述 | 默认值 |
|---|---|---|
COMET_PATH | Comet可执行文件的自定义路径 | 自动检测到 |
COMET_PORT | CDP调试端口 | 9223 |
自定义彗星路径
# 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
解决:
- 确保安装了Comet浏览器
- 关闭所有现有的Comet实例
- 跑
comet_connect使用正确的标志自动启动
______________________________________________________________________
问题: WebSocket connection closed 在长期任务中
解决方案: 此版本自动处理重新连接。如果持续存在,请增加超时时间:
comet_ask prompt="..." timeout=180000______________________________________________________________________
Windows特定问题
问题: ECONNRESET Windows上的错误
解决方案: 此版本包括基于PowerShell的获取解决方法。确保:
- PowerShell在PATH中可用
- 没有防火墙阻止本地主机:9223
______________________________________________________________________
问题: 在Windows上找不到Comet
解决方案: 设置自定义路径:
set COMET_PATH=%LOCALAPPDATA%\Perplexity\Comet\Application\comet.exe______________________________________________________________________
WSL特定问题
问题: WSL cannot connect to Windows localhost:9223
说明: 默认情况下,WSL2使用单独的网络命名空间。MCP使用Chrome DevTools协议(CDP),该协议要求WebSocket连接到Windows本地主机。
解决方案: 启用WSL镜像网络:
- 创建或编辑
%USERPROFILE%\.wslconfig(例如。,C:\Users\YourName\.wslconfig):
[wsl2]
networkingMode=mirrored- 重新启动WSL:
wsl --shutdown- 请打开一个新的WSL终端,然后重试。
备选方案: 从Windows PowerShell而不是WSL运行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______________________________________________________________________
贡献
欢迎捐款。请阅读 贡献.md 在提交pull请求之前。
开发指南
- 保持TypeScript严格模式合规性
- 为新功能添加测试
- 更新API变更文档
- 遵循现有代码样式
______________________________________________________________________
归因
RapierCraft的主要增强功能
- Windows和WSL平台支持
- 标签管理系统(comet_tabs工具)
- 智能完成检测
- 通过指数回退自动重新连接
- 健康检查缓存
- 代理提示自动转换
- 最后标签保护
- 内部选项卡筛选
______________________________________________________________________
许可证
MIT许可证-请参阅 许可证 了解详情。
______________________________________________________________________
链接
______________________________________________________________________
由精密制造 RapierCraft
