Sponsored by Deepsite.site

Mcp Perplexity

Created By
daniel-lxs9 months ago
Content

Perplexity Chat MCP Server

The Perplexity MCP Server provides a Python-based interface to the Perplexity API, offering tools for querying responses, maintaining chat history, and managing conversations. It supports model configuration via environment variables and stores chat data locally. Built with Python and setuptools, it's designed for integration with development environments.

The MCP Server is desined to mimick how users interact with the Perplexity Chat on their browser by allowing your models to ask questions, continue conversations, and list all your chats.

smithery badge Release and Publish

Components

Tools

  • ask_perplexity: Request expert programming assistance through Perplexity. Focuses on coding solutions, error debugging, and technical explanations. Returns responses with source citations and alternative suggestions.
  • chat_perplexity: Maintains ongoing conversations with Perplexity AI. Creates new chats or continues existing ones with full history context. Returns chat ID for future continuation.
  • list_chats_perplexity: Lists all available chat conversations with Perplexity AI. Returns chat IDs, titles, and creation dates (displayed in relative time format, e.g., "5 minutes ago", "2 days ago"). Results are paginated with 50 chats per page.
  • read_chat_perplexity: Retrieves the complete conversation history for a specific chat. Returns the full chat history with all messages and their timestamps. No API calls are made to Perplexity - this only reads from local storage.

Key Features

  • Model Configuration via Environment Variable: Allows you to specify the Perplexity model using the PERPLEXITY_MODEL environment variable for flexible model selection.

    You can also specify PERPLEXITY_MODEL_ASK and PERPLEXITY_MODEL_CHAT to use different models for the ask_perplexity and chat_perplexity tools, respectively.

    These will override PERPLEXITY_MODEL. You can check which models are available on the Perplexity documentation.

  • Persistent Chat History: The chat_perplexity tool maintains ongoing conversations with Perplexity AI. Creates new chats or continues existing ones with full history context. Returns chat ID for future continuation.

  • Streaming Responses with Progress Reporting: Uses progress reporting to prevent timeouts on slow responses.

Quickstart

Prerequisites

Before using this MCP server, ensure you have:

  • Python 3.10 or higher
  • uvx package manager installed

Note: Installation instructions for uvx are available here.

Configuration for All Clients

To use this MCP server, configure your client with these settings (configuration method varies by client):

"mcpServers": {
  "mcp-perplexity": {
    "command": "uvx",
    "args": ["mcp-perplexity"],
    "env": {
      "PERPLEXITY_API_KEY": "your-api-key",
      "PERPLEXITY_MODEL": "sonar-pro",
      "DB_PATH": "chats.db"
    }
  }
}

Environment Variables

Configure the MCP Perplexity server using the following environment variables:

VariableDescriptionDefault ValueRequired
PERPLEXITY_API_KEYYour Perplexity API keyNoneYes
PERPLEXITY_MODELDefault model for interactionssonar-proNo
PERPLEXITY_MODEL_ASKSpecific model for ask_perplexity toolUses PERPLEXITY_MODELNo
PERPLEXITY_MODEL_CHATSpecific model for chat_perplexity toolUses PERPLEXITY_MODELNo
DB_PATHPath to store chat history databasechats.dbNo
WEB_UI_ENABLEDEnable or disable web UIfalseNo
WEB_UI_PORTPort for web UI8050No
WEB_UI_HOSTHost for web UI127.0.0.1No
DEBUG_LOGSEnable detailed loggingfalseNo

Using Smithery CLI

npx -y @smithery/cli@latest run @daniel-lxs/mcp-perplexity --config "{\"perplexityApiKey\":\"pplx-abc\",\"perplexityModel\":\"sonar-pro\"}"

Usage

ask_perplexity

The ask_perplexity tool is used for specific questions, this tool doesn't maintain a chat history, every request is a new chat.

The tool will return a response from Perplexity AI using the PERPLEXITY_MODEL_ASK model if specified, otherwise it will use the PERPLEXITY_MODEL model.

chat_perplexity

The chat_perplexity tool is used for ongoing conversations, this tool maintains a chat history. A chat is identified by a chat ID, this ID is returned by the tool when a new chat is created. Chat IDs look like this: wild-horse-12.

This tool is useful for debugging, research, and any other task that requires a chat history.

The tool will return a response from Perplexity AI using the PERPLEXITY_MODEL_CHAT model if specified, otherwise it will use the PERPLEXITY_MODEL model.

list_chats_perplexity

Lists all available chat conversations. It returns a paginated list of chats, showing the chat ID, title, and creation time (in relative format). You can specify the page number using the page argument (defaults to 1, with 50 chats per page).

read_chat_perplexity

Retrieves the complete conversation history for a given chat_id. This tool returns all messages in the chat, including timestamps and roles (user or assistant). This tool does not make any API calls to Perplexity; it only reads from the local database.

Web UI

The MCP Perplexity server now includes a web interface for easier interaction and management of chats.

Features

  • Interactive chat interface
  • Chat history management
  • Real-time message display

Screenshots

Chat List View

image

Chat Interface

image

Accessing the Web UI

When WEB_UI_ENABLED is set to true, the web UI will be available at http://WEB_UI_HOST:WEB_UI_PORT.

By default, this is http://127.0.0.1:8050.

Development

This project uses setuptools for development and builds. To get started:

  1. Create a virtual environment:

    python -m venv .venv
    source .venv/bin/activate  # On Linux/macOS
    # or
    .venv\Scripts\activate  # On Windows
    
  2. Install the project in editable mode with all dependencies:

    pip install -e .
    
  3. Build the project:

    python -m build
    

The virtual environment will contain all required dependencies for development.

Contributing

This project is open to contributions. Please see the CONTRIBUTING.md file for more information.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Server Config

{
  "mcpServers": {
    "mcp-perplexity": {
      "command": "uvx",
      "args": [
        "mcp-perplexity"
      ],
      "env": {
        "PERPLEXITY_API_KEY": "your-api-key",
        "PERPLEXITY_MODEL": "sonar-pro",
        "DB_PATH": "chats.db"
      }
    }
  }
}
Recommend Servers
TraeBuild with Free GPT-4.1 & Claude 3.7. Fully MCP-Ready.
WindsurfThe new purpose-built IDE to harness magic
MCP AdvisorMCP Advisor & Installation - Use the right MCP server for your needs
Serper MCP ServerA Serper MCP Server
MiniMax MCPOfficial MiniMax Model Context Protocol (MCP) server that enables interaction with powerful Text to Speech, image generation and video generation APIs.
EdgeOne Pages MCPAn MCP service designed for deploying HTML content to EdgeOne Pages and obtaining an accessible public URL.
ChatWiseThe second fastest AI chatbot™
Zhipu Web SearchZhipu Web Search MCP Server is a search engine specifically designed for large models. It integrates four search engines, allowing users to flexibly compare and switch between them. Building upon the web crawling and ranking capabilities of traditional search engines, it enhances intent recognition capabilities, returning results more suitable for large model processing (such as webpage titles, URLs, summaries, site names, site icons, etc.). This helps AI applications achieve "dynamic knowledge acquisition" and "precise scenario adaptation" capabilities.
BlenderBlenderMCP connects Blender to Claude AI through the Model Context Protocol (MCP), allowing Claude to directly interact with and control Blender. This integration enables prompt assisted 3D modeling, scene creation, and manipulation.
Tavily Mcp
Baidu Map百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Visual Studio Code - Open Source ("Code - OSS")Visual Studio Code
TimeA Model Context Protocol server that provides time and timezone conversion capabilities. This server enables LLMs to get current time information and perform timezone conversions using IANA timezone names, with automatic system timezone detection.
Jina AI MCP ToolsA Model Context Protocol (MCP) server that integrates with Jina AI Search Foundation APIs.
CursorThe AI Code Editor
Context7Context7 MCP Server -- Up-to-date code documentation for LLMs and AI code editors
Howtocook Mcp基于Anduin2017 / HowToCook (程序员在家做饭指南)的mcp server,帮你推荐菜谱、规划膳食,解决“今天吃什么“的世纪难题; Based on Anduin2017/HowToCook (Programmer's Guide to Cooking at Home), MCP Server helps you recommend recipes, plan meals, and solve the century old problem of "what to eat today"
AiimagemultistyleA Model Context Protocol (MCP) server for image generation and manipulation using fal.ai's Stable Diffusion model.
Playwright McpPlaywright MCP server
DeepChatYour AI Partner on Desktop
Amap Maps高德地图官方 MCP Server