MCP server connecting Claude Code to Perplexity's Comet browser via Chrome DevTools Protocol (CDP).
Claude Code → MCP Server (index.ts) → CometAI (comet-ai.ts) → CDP Client (cdp-client.ts) → Comet Browser
comet_connect- Start/connect to Comet browsercomet_ask- Send prompt, wait for response (15s default, use poll for longer)comet_poll- Check status of long-running taskscomet_stop- Stop current taskcomet_screenshot- Capture current pagecomet_mode- Switch Perplexity modes (search/research/labs/learn)
Response extraction (comet-ai.ts:getAgentStatus):
- Takes LAST prose element (not longest) - conversation threads show newest last
- Filters out UI text (Library, Discover, etc.) and questions (ends with ?)
Follow-up detection (index.ts):
- Captures old prose count/text before sending
- Waits for NEW response (different text or more elements)
Prompt normalization:
- Strips bullet points, collapses newlines to spaces
npm run build
pgrep -f "node.*comet-mcp" | xargs kill # Restart MCPManual testing only (integration code, external DOM dependency).
- Quick queries - Simple questions (math, facts) should return within 15s
- Non-blocking - Short timeout returns "in progress", use poll to get result
- Follow-up - Second question in same chat detects NEW response correctly
- Agentic task - "Take control of browser and go to X" triggers browsing
- newChat after agentic -
newChat: trueresets CDP state after browser control - Mode switching -
comet_modechanges search/research/labs/learn
- Prompt not submitted: If response shows 0 steps + COMPLETED, prompt may not have been submitted. Retry or use newChat.
- Stale poll response: If poll returns unrelated response, the previous prompt failed. Send again.
- Research mode: Takes longer than search mode, may need multiple polls.