Perplexity MCP Server
Use your existing Perplexity Pro subscription with AI coding tools - no API costs required. Integrates with Claude Code, Cursor, Windsurf, and other MCP clients.
Perplexity Web Wrapper
Unofficial Python Wrapper & MCP Server for Perplexity AI
A Python wrapper and MCP (Model Context Protocol) server for Perplexity AI that integrates with Claude Code, Cursor, Windsurf, and Codex CLI. Provides web search capabilities through Perplexity's interface.
Features
- MCP Server - Full Model Context Protocol support
- Python Wrapper - Clean Python API for Perplexity
- Multiple Modes - Auto, Pro, Reasoning, Deep Research
- Model Selection - Choose specific models per mode
- Follow-up Support - Continue conversations with context
- Thread Management - List and retrieve conversation threads
- IDE Integration - Works with Claude Code, Cursor, Windsurf
Installation
From PyPI
pip install perplexity-web-wrapper
From Source
git clone https://github.com/balakumardev/perplexity-web-wrapper.git
cd perplexity-web-wrapper
pip install -e .
Configuration
Environment Variables
# Required: Perplexity session cookie
export PERPLEXITY_COOKIE="your_session_cookie"
Getting Your Cookie
- Log in to perplexity.ai
- Open Developer Tools (F12)
- Go to Application > Cookies
- Copy the session cookie value
Usage
Python API
from perplexity_web_wrapper import PerplexityClient
client = PerplexityClient()
# Simple search
result = client.search("What is the capital of France?")
print(result.answer)
# Pro mode with specific model
result = client.search(
"Explain quantum computing",
mode="pro",
model="claude 3.7 sonnet"
)
# Deep research
result = client.search(
"Comprehensive analysis of renewable energy trends 2025",
mode="deep_research"
)
# Follow-up question
follow_up = client.follow_up(
"Can you elaborate on solar energy?",
backend_uuid=result.backend_uuid
)
MCP Server
Add to your MCP configuration:
{
"mcpServers": {
"perplexity": {
"command": "perplexity-mcp",
"env": {
"PERPLEXITY_COOKIE": "your_session_cookie"
}
}
}
}
Search Modes
| Mode | Description | Use Case |
|---|---|---|
auto |
Automatic mode selection | General queries |
pro |
Enhanced search | Technical questions |
reasoning |
Step-by-step reasoning | Complex problems |
deep_research |
Comprehensive research | In-depth analysis |
Available Models
Pro Mode
sonargpt-4.5gpt-4oclaude 3.7 sonnetgemini 2.0 flashgrok-2
Reasoning Mode
r1o3-miniclaude 3.7 sonnet
MCP Tools
| Tool | Description |
|---|---|
search |
Perform web search with Perplexity |
follow_up |
Continue a conversation |
list_threads |
List saved conversation threads |
get_thread |
Retrieve specific thread details |
API Reference
search(query, mode, model, sources, answer_only, language, incognito)
| Parameter | Type | Default | Description |
|---|---|---|---|
query |
str | required | Search query |
mode |
str | "auto" |
Search mode |
model |
str | None |
Specific model |
sources |
list | ["web"] |
Source types |
answer_only |
bool | True |
Return only answer |
language |
str | "en-US" |
Response language |
incognito |
bool | False |
Incognito mode |
follow_up(query, backend_uuid, mode, model, answer_only)
Continue a conversation using the backend_uuid from a previous response.
Tech Stack
- Language: Python 3.8+
- Protocol: MCP (Model Context Protocol)
- HTTP: aiohttp for async requests
- CLI: Click for command-line interface
IDE Integration
Claude Code
# Add to ~/.claude/mcp.json
Cursor
Configure in Cursor settings under MCP Servers.
Windsurf
Add to Windsurf's MCP configuration file.
Contributing
Contributions welcome! Please open issues or submit pull requests.
Disclaimer
This is an unofficial wrapper. Use responsibly and in accordance with Perplexity's terms of service.
License
This project is open source. See the repository for license details.