Skip to main content

MCP Server for the Perplexity API.

Project description

Perplexity MCP Server

MCP Server for the Perplexity API.

smithery badge PyPI 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

Installation

Prerequisites

Automated Installation

We provide automated installation scripts that will:

  1. Install uvx if not present
  2. Download and install mcp-starter
  3. Guide you through creating the configuration file
Windows Installation
  1. Download the install.ps1 script
  2. Open PowerShell as Administrator
  3. Allow script execution and run:
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser -Force
.\install.ps1

The script will:

  • Check for required dependencies (curl, PowerShell)
  • Install uvx if not present
  • Install mcp-starter to %USERPROFILE%\.local\bin
  • Create a configuration file at %USERPROFILE%\.config\mcp-starter\config.json
  • Prompt for your Perplexity API key and model preferences
Unix Installation (Linux/MacOS)
  1. Download the install.sh script
  2. Open Terminal
  3. Navigate to the directory containing the script
  4. Make the script executable and run it:
chmod +x install.sh  # Only needed if downloaded directly from browser
./install.sh

The script will:

  • Check for required dependencies (curl)
  • Install uvx if not present
  • Install mcp-starter to $HOME/.local/bin
  • Create a configuration file at $HOME/.config/mcp-starter/config.json
  • Prompt for your Perplexity API key and model preferences

Configure your MCP Client

To use this MCP server, you need to configure your MCP client to connect to it. The configuration method will vary depending on your specific client.

Below is an example configuration in JSON format:

"mcpServers": {
  "mcp-perplexity": {
    "command": "uvx",
    "args": [
      "mcp-perplexity"
    ],
    "env": {
      "PERPLEXITY_API_KEY": "your-perplexity-api-key",
      "PERPLEXITY_MODEL": "sonar-pro",
      "PERPLEXITY_MODEL_ASK": "sonar-pro",
      "PERPLEXITY_MODEL_CHAT": "sonar-reasoning-pro",
      "DB_PATH": "path/to/custom.db"
    }
  }
}

Important notes:

  • Replace "your-perplexity-api-key" with your actual Perplexity API key
  • Environment variables configuration:
    • PERPLEXITY_MODEL: Default model for both tools
    • PERPLEXITY_MODEL_ASK: Overrides default model for ask_perplexity tool
    • PERPLEXITY_MODEL_CHAT: Overrides default model for chat_perplexity tool
    • DB_PATH: Custom path for SQLite chat history database (default: chats.db)
  • Consult the Perplexity model docs for available models
  • Use the mcp-starter script to easily add this MCP server to Cursor IDE.

Using Smithery CLI

Smithery is a CLI tool that allows you to easily add MCP servers to your Cursor IDE.

Replace the values of the configuration object with your own values.

npx -y @smithery/cli@latest run @daniel-lxs/mcp-perplexity --config "{\"perplexityApiKey\":\"abc\",\"perplexityModel\":\"sonar-pro\", \"modelAsk\":\"sonar-pro\", \"modelChat\":\"sonar-reasoning-pro\", \"dbPath\":\"path/to/custom.db\"}"
  • perplexityApiKey: PERPLEXITY_API_KEY
  • perplexityModel: PERPLEXITY_MODEL
  • modelAsk: PERPLEXITY_MODEL_ASK
  • modelChat: PERPLEXITY_MODEL_CHAT
  • dbPath: DB_PATH

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mcp_perplexity-0.4.0.tar.gz (20.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mcp_perplexity-0.4.0-py3-none-any.whl (10.5 kB view details)

Uploaded Python 3

File details

Details for the file mcp_perplexity-0.4.0.tar.gz.

File metadata

  • Download URL: mcp_perplexity-0.4.0.tar.gz
  • Upload date:
  • Size: 20.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for mcp_perplexity-0.4.0.tar.gz
Algorithm Hash digest
SHA256 45a93102617d50d0609801a27925a6fa4b03db5f9fecb0e01680f0ca52cf905e
MD5 00a8f4af9efb8645c022483fd9321c80
BLAKE2b-256 903eacc7f34706105c8351c22cde5860fa0fcc0a04bb136bbc231c11a1d73235

See more details on using hashes here.

Provenance

The following attestation bundles were made for mcp_perplexity-0.4.0.tar.gz:

Publisher: pypi-publish.yml on daniel-lxs/mcp-perplexity

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mcp_perplexity-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: mcp_perplexity-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 10.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for mcp_perplexity-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 97558238bc75915f732ad08542cf5ea94285a838d20fad657ff088a7ab68d212
MD5 096e2132aae4875c30693d6544d2ebfb
BLAKE2b-256 afff2e8e7bb928e647904a5b383e03c7b29d3a01d5922779ca2bce3462038745

See more details on using hashes here.

Provenance

The following attestation bundles were made for mcp_perplexity-0.4.0-py3-none-any.whl:

Publisher: pypi-publish.yml on daniel-lxs/mcp-perplexity

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page