- Home
- MCP servers
- Perplexity Chat
Perplexity Chat
- python
67
GitHub Stars
python
Language
6 months ago
First Indexed
2 months ago
Catalog Refreshed
Documentation & install
Readme and setup notes from the catalogue, plus a client-ready config you can copy for your MCP host.
The Perplexity Chat MCP Server provides a Python-based interface to the Perplexity API, enabling you to query responses, maintain chat history, and manage conversations locally. It is designed to be integrated into development environments and to replicate how you interact with Perplexity Chat in a browser, including maintaining ongoing chats and listing all conversations.
How to use
You interact with the Perplexity MCP Server through an MCP client. Use the chat_perplexity tool to start and continue conversations, use the ask_perplexity tool for single-turn questions, and use list_chats_perplexity to view existing chats. The chat_perplexity tool keeps a complete history, returning a chat ID you reuse for future messages.
Start a new MCP session by running the MCP server via the configured runtime. The recommended setup uses the uvx runtime to execute the server package, with environment variables to supply your Perplexity API key, model preferences, and a local database for chat history.
{
"mcpServers": {
"mcp-perplexity": {
"command": "uvx",
"args": ["mcp-perplexity"],
"env": {
"PERPLEXITY_API_KEY": "your-api-key",
"PERPLEXITY_MODEL": "sonar-pro",
"DB_PATH": "chats.db"
}
}
}
}
How to install
Prerequisites you need before running the server: Python 3.10 or higher and the uvx package manager.
Install and run the MCP server using the following steps. Copy these commands exactly as shown.
# Create and activate a virtual environment
python -m venv .venv
source .venv/bin/activate # On Linux/macOS
# or
.venv\Scripts\activate # On Windows
# Install the project in editable mode (dev dependencies included)
pip install -e .
# Build the project if required
python -m build
# Start the MCP server using the configured runtime
# This uses uvx to run the mcp-perplexity package as shown in the example config
npx -y @smithery/cli@latest run @daniel-lxs/mcp-perplexity --config "{\"perplexityApiKey\":\"pplx-abc\",\"perplexityModel\":\"sonar-pro\"}"
Configuration and usage details
Environment variables configure how the server talks to Perplexity and where chat history is stored. The key variables are:
- PERPLEXITY_API_KEY: Your Perplexity API key (required)
- PERPLEXITY_MODEL: Default model for interactions (optional, default sonar-pro)
- PERPLEXITY_MODEL_ASK: Model for ask_perplexity (optional)
- PERPLEXITY_MODEL_CHAT: Model for chat_perplexity (optional)
- DB_PATH: Path to the local chat history database (optional, default chats.db)
- WEB_UI_ENABLED: Enable the web UI (optional)
- WEB_UI_PORT: Port for the web UI (optional)
- WEB_UI_HOST: Host for the web UI (optional)
- DEBUG_LOGS: Enable detailed logging (optional)
You can configure a client to use the following MCP server entry to run via the uvx-based runtime. The example below shows the environment variables that you supply to the server.
"mcpServers": {
"mcp-perplexity": {
"command": "uvx",
"args": ["mcp-perplexity"],
"env": {
"PERPLEXITY_API_KEY": "your-api-key",
"PERPLEXITY_MODEL": "sonar-pro",
"DB_PATH": "chats.db"
}
}
}
Web UI
You can enable a web interface to interact with chats. When WEB_UI_ENABLED is true, the interface is available at the host and port you set, for example http://127.0.0.1:8050 by default.
Development
This server is built with Python and setuptools. To contribute or develop locally, set up a virtual environment, install dependencies, and use the standard build and install steps.
python -m venv .venv
source .venv/bin/activate # Linux/macOS
.\venv\Scripts\activate # Windows
pip install -e .
python -m build
Available 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. Returns chat IDs, titles, and creation dates. Results are paginated with 50 chats per page.
read_chat_perplexity
Retrieves the complete conversation history for a specific chat. Returns the full history with timestamps. Reads from local storage only.