How wysh3/perplexity-mcp-zerver works
Project Type and Purpose
• This is a Node.js/TypeScript-based server implementation that serves as an MCP (Model Context Protocol) server.
• Its main purpose is to provide AI-powered research capabilities by interacting with the Perplexity website (via Puppeteer for browser automation), delivering tools like search, documentation retrieval, API discovery, deprecation analysis, URL content extraction, and chat functionality.
• The server is designed to be integrated with MCP clients (e.g., VS Code extensions or desktop applications like Claude Desktop) through a configuration file.
File Structure
• Top-level files such as .gitignore, LICENSE.md, README.md, package.json, and tsconfig.json set up the project environment.
• The core logic is found in the “src” directory with a single entry point (index.ts). This indicates that most functionality is likely imported or internally defined within this file or as additional modules (even if they are not split into separate directories, the different tools as explained in the README suggest modular functionality).
• There are no separate front-end or extensive multi-layer directories; the design is modular within one core server file.
Key Components
• Client/Integration Layer:
• MCP Clients (e.g., VS Code extension (Cline/RooCode), Claude Desktop) that call the server.
• Server Core:
• The entry point (index.ts) that initializes the server.
• An internal routing and command processing layer that receives MCP requests and maps them to the relevant tool.
• Tools/Modules:
• Search Module: Handles various search requests (brief, normal, detailed) interacting with Perplexity’s web interface.
• Documentation Retrieval Module (“get_documentation”): Fetches documentation and examples.
• API Finder Module (“find_apis”): Queries for APIs using provided requirements.
• Code Analysis Module (“check_deprecated_code”): Analyzes code for deprecated features.
• URL Content Extraction Module (“extract_url_content”): Uses Puppeteer combined with Mozilla’s Readability to obtain structured JSON output.
• Chat Module (“chat_perplexity”): Manages chat sessions and maintains a persistent chat history stored in a local file (chat_history.db).
• External Services and Integrations:
• Perplexity Website: The external website that is queried via browser automation.
• Puppeteer: The tool for controlling headless Chromium instances.
• Local Chat History File: Represents the persistence store (chat_history.db) for chat conversations.
Relationships and Interactions
• MCP Clients make requests that are routed into the server’s main entry point.
• The server interprets these requests and forwards them to the appropriate internal module.
• The Chat module both receives user requests and writes/reads its state from the local chat_history.db.
• Once the modules complete their operations, the results are sent back up to the client in a structured response (typically a stringified JSON object).
Architectural Patterns and Technologies
• Use of a centralized server process (the Node.js application) that routes commands based on the MCP request – a common Command pattern.
• Use of Puppeteer for external interactions.
• That the project leans on modularity (each “tool” or command acts as a separate responsibility even if all code is bundled in a small codebase).
• Mention the TypeScript-first implementation, reinforcing type safety in communication between the components.