io.github.RapierCraft/perplexity-comet-mcp

编码与调试

by rapiercraft

连接 Claude Code 与 Perplexity Comet,支持自主网页浏览和标签页管理。

什么是 io.github.RapierCraft/perplexity-comet-mcp

连接 Claude Code 与 Perplexity Comet,支持自主网页浏览和标签页管理。

README

Perplexity Comet MCP

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

A production-grade MCP (Model Context Protocol) server that bridges Claude Code with Perplexity's Comet browser for autonomous web browsing, research, and multi-tab workflow management.


Why Perplexity Comet MCP?

ApproachLimitation
Search APIsStatic text, no interaction, no login support
Browser AutomationSingle-agent model overwhelms context, fragments focus
Perplexity Comet MCPClaude codes while Comet handles browsing autonomously

This is a significantly enhanced fork of hanzili/comet-mcp with Windows support, smart completion detection, robust connection handling, and full tab management.


Features

Core Capabilities

  • Autonomous Web Browsing - Comet navigates, clicks, types, and extracts data while Claude focuses on coding
  • Deep Research Mode - Leverage Perplexity's research capabilities for comprehensive analysis
  • Login Wall Handling - Access authenticated content through real browser sessions
  • Dynamic Content - Full JavaScript rendering and interaction support

Enhanced Features (New in This Fork)

FeatureDescription
Windows/WSL SupportFull compatibility with Windows and WSL environments
Tab ManagementTrack, switch, and close browser tabs with protection
Smart CompletionDetect response completion without fixed timeouts
Auto-ReconnectExponential backoff recovery from connection drops
One-Shot ReliabilityPre-operation health checks for consistent execution
Agentic Auto-TriggerAutomatically triggers browser actions from natural prompts

Comparison with Original

CapabilityOriginalEnhanced
Platform SupportmacOSWindows, WSL, macOS
Available Tools68 (+comet_tabs, +comet_upload)
Completion DetectionFixed timeoutStability-based
Connection RecoveryNoneAuto-reconnect with backoff
Tab ManagementNoneFull registry and control
Health MonitoringNoneCached health checks
Last Tab ProtectionNonePrevents browser crash

Installation

Prerequisites

Install via npm

bash
npm install -g perplexity-comet-mcp

Install from Source

bash
git clone https://github.com/RapierCraft/perplexity-comet-mcp.git
cd perplexity-comet-mcp
npm install
npm run build

Configure Claude Code

Add to your Claude Code MCP settings (~/.claude/settings.json or VS Code settings):

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

Windows Users: Use the full Windows path:

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

Tools Reference

comet_connect

Establish connection to Comet browser. Auto-launches if not running.

code
Parameters: None
Returns: Connection status message

Example:

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

comet_ask

Send a prompt to Comet and wait for the complete response. Automatically triggers agentic browsing for URLs and action-oriented requests.

code
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

Examples:

code
# 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

Check status and progress of ongoing tasks. Returns the response if completed.

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

Example:

code
> 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

Halt the current agentic task if it goes off track.

code
Parameters: None
Returns: Confirmation message

comet_screenshot

Capture a screenshot of the current browser view.

code
Parameters: None
Returns: PNG image data

comet_tabs

View and manage browser tabs. Essential for multi-tab workflows.

code
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

Examples:

code
# 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

Tab Protection:

  • Cannot close the last external browsing tab (prevents Comet crash)
  • Internal tabs (chrome://, Perplexity UI) are automatically filtered

comet_mode

Switch Perplexity search modes for different use cases.

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

Returns: Current mode or confirmation of switch
ModeUse Case
searchQuick web searches
researchDeep, comprehensive analysis
labsData analytics and visualization
learnEducational explanations

comet_upload

Upload files to file input elements on web pages. Essential for posting images to social media, attaching files to forms, or uploading documents.

code
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

Examples:

code
# 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

Workflow for posting images:

  1. Navigate to the post creation page (e.g., Reddit, Twitter)
  2. Use comet_upload checkOnly=true to find file inputs
  3. Use comet_upload filePath="..." selector="..." to attach the file
  4. Continue with form submission

Architecture

code
┌─────────────────┐     MCP Protocol      ┌──────────────────┐
│   Claude Code   │ ◄──────────────────► │  Perplexity      │
│   (Your IDE)    │                       │  Comet MCP       │
└─────────────────┘                       └────────┬─────────┘
                                                   │
                                          Chrome DevTools
                                            Protocol
                                                   │
                                          ┌────────▼─────────┐
                                          │  Comet Browser   │
                                          │  (Perplexity)    │
                                          └──────────────────┘
                                                   │
                                          ┌────────▼─────────┐
                                          │   External       │
                                          │   Websites       │
                                          └──────────────────┘

Key Components

ComponentPurpose
index.tsMCP server and tool handlers
cdp-client.tsChrome DevTools Protocol client with reconnection logic
comet-ai.tsPerplexity interaction, prompt submission, response extraction
types.tsTypeScript interfaces for tabs, state, and CDP types

Configuration

Environment Variables

VariableDescriptionDefault
COMET_PATHCustom path to Comet executableAuto-detected
COMET_PORTCDP debugging port9223

Custom Comet Path

bash
# Windows
set COMET_PATH=C:\Custom\Path\comet.exe

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

Troubleshooting

Connection Issues

Problem: Error: Failed to list targets: ECONNREFUSED

Solutions:

  1. Ensure Comet browser is installed
  2. Close any existing Comet instances
  3. Run comet_connect to auto-start with correct flags

Problem: WebSocket connection closed during long tasks

Solution: This version handles reconnection automatically. If persistent, increase timeout:

code
comet_ask prompt="..." timeout=180000

Windows-Specific Issues

Problem: ECONNRESET errors on Windows

Solution: This version includes PowerShell-based fetch workarounds. Ensure:

  1. PowerShell is available in PATH
  2. No firewall blocking localhost:9223

Problem: Comet not found on Windows

Solution: Set custom path:

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

WSL-Specific Issues

Problem: WSL cannot connect to Windows localhost:9223

Explanation: WSL2 uses a separate network namespace by default. The MCP uses Chrome DevTools Protocol (CDP) which requires WebSocket connections to Windows localhost.

Solution: Enable WSL mirrored networking:

  1. Create or edit %USERPROFILE%\.wslconfig (e.g., C:\Users\YourName\.wslconfig):
ini
[wsl2]
networkingMode=mirrored
  1. Restart WSL:
powershell
wsl --shutdown
  1. Open a new WSL terminal and try again.

Alternative: Run Claude Code from Windows PowerShell instead of WSL.


Problem: UNC paths are not supported warnings

Explanation: This is a benign warning from PowerShell when launched from WSL. The MCP handles this automatically.


Tab Management Issues

Problem: Cannot close - this is the only browsing tab

Explanation: This is intentional protection. Comet requires at least one external tab. Open another tab first, then close the unwanted one.


Development

Build from Source

bash
git clone https://github.com/RapierCraft/perplexity-comet-mcp.git
cd perplexity-comet-mcp
npm install
npm run build

Run in Development

bash
npm run dev

Run Tests

bash
npm test

Project Structure

code
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

Contributions are welcome. Please read CONTRIBUTING.md before submitting a pull request.

Development Guidelines

  1. Maintain TypeScript strict mode compliance
  2. Add tests for new features
  3. Update documentation for API changes
  4. Follow existing code style

Attribution

This project is an enhanced fork of comet-mcp by hanzili.

Key Enhancements by RapierCraft

  • Windows and WSL platform support
  • Tab management system (comet_tabs tool)
  • Smart completion detection
  • Auto-reconnect with exponential backoff
  • Health check caching
  • Agentic prompt auto-transformation
  • Last tab protection
  • Internal tab filtering

License

MIT License - see LICENSE for details.


Links


Built with precision by RapierCraft

常见问题

io.github.RapierCraft/perplexity-comet-mcp 是什么?

连接 Claude Code 与 Perplexity Comet,支持自主网页浏览和标签页管理。

相关 Skills

前端设计

by anthropics

Universal
热门

面向组件、页面、海报和 Web 应用开发,按鲜明视觉方向生成可直接落地的前端代码与高质感 UI,适合做 landing page、Dashboard 或美化现有界面,避开千篇一律的 AI 审美。

想把页面做得既能上线又有设计感,就用前端设计:组件到整站都能产出,难得的是能避开千篇一律的 AI 味。

编码与调试
未扫描152.6k

网页应用测试

by anthropics

Universal
热门

用 Playwright 为本地 Web 应用编写自动化测试,支持启动开发服务器、校验前端交互、排查 UI 异常、抓取截图与浏览器日志,适合调试动态页面和回归验证。

借助 Playwright 一站式验证本地 Web 应用前端功能,调 UI 时还能同步查看日志和截图,定位问题更快。

编码与调试
未扫描152.6k

网页构建器

by anthropics

Universal
热门

面向复杂 claude.ai HTML artifact 开发,快速初始化 React + Tailwind CSS + shadcn/ui 项目并打包为单文件 HTML,适合需要状态管理、路由或多组件交互的页面。

在 claude.ai 里做复杂网页 Artifact 很省心,多组件、状态和路由都能顺手搭起来,React、Tailwind 与 shadcn/ui 组合效率高、成品也更精致。

编码与调试
未扫描152.6k

相关 MCP Server

GitHub

编辑精选

by GitHub

热门

GitHub 是 MCP 官方参考服务器,让 Claude 直接读写你的代码仓库和 Issues。

这个参考服务器解决了开发者想让 AI 安全访问 GitHub 数据的问题,适合需要自动化代码审查或 Issue 管理的团队。但注意它只是参考实现,生产环境得自己加固安全。

编码与调试
87.4k

by Context7

热门

Context7 是实时拉取最新文档和代码示例的智能助手,让你告别过时资料。

它能解决开发者查找文档时信息滞后的问题,特别适合快速上手新库或跟进更新。不过,依赖外部源可能导致偶尔的数据延迟,建议结合官方文档使用。

编码与调试
57.7k

by tldraw

热门

tldraw 是让 AI 助手直接在无限画布上绘图和协作的 MCP 服务器。

这解决了 AI 只能输出文本、无法视觉化协作的痛点——想象让 Claude 帮你画流程图或白板讨论。最适合需要快速原型设计或头脑风暴的开发者。不过,目前它只是个基础连接器,你得自己搭建画布应用才能发挥全部潜力。

编码与调试
48.0k

评论