Perplexity MCP Server
Integrates Perplexity AI's search-enhanced language models, providing three tools with progressive complexity for different search and research needs: perplexity_small for quick factual queries, perplexity_medium for technical explanations, and perplexity_large for comprehensive research.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Perplexity MCP Server perplexity_medium to explain: How does blockchain consensus work?"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Perplexity MCP Server
A Model Context Protocol (MCP) server that integrates Perplexity AI's search-enhanced language models with Claude Desktop, providing three tools with progressive complexity for different use cases.
Features
š Three Complexity Levels
perplexity_small: Fast queries with sonar-pro modelperplexity_medium: Enhanced reasoning with sonar-reasoning-properplexity_large: Deep research with sonar-deep-research
š Optimized for Development
Clean responses (thinking tokens automatically removed)
Comprehensive error handling
Detailed logging for debugging
Built with FastMCP for reliability
š§ Modern Python Stack
UV for fast dependency management
HTTPX for modern HTTP client capabilities
Type hints throughout codebase
Comprehensive testing suite
Related MCP server: MCP-researcher Server
Quick Start
Prerequisites
Installation
Clone the repository
git clone <repository-url> cd Perplexity_MCPInstall dependencies
uv syncSet up environment
echo "PERPLEXITY_API_KEY=your_api_key_here" > .envTest the installation
uv run python tests/tests.py small
Claude Desktop Integration
Find your UV path
which uv # Example output: /Users/username/.local/bin/uvConfigure Claude Desktop
Edit
~/Library/Application Support/Claude/claude_desktop_config.json:{ "mcpServers": { "perplexity-mcp": { "command": "/Users/username/.local/bin/uv", "args": [ "--directory", "/path/to/your/Perplexity_MCP", "run", "python", "server.py" ] } } }Restart Claude Desktop
Completely quit and restart Claude Desktop to load the new MCP server.
Usage
In Claude Desktop
Once configured, you can use these tools in your conversations:
Quick factual queries:
Use perplexity_small to find: "What is the latest Python version?"Technical analysis:
Use perplexity_medium to explain: "Compare REST vs GraphQL performance characteristics"Deep research:
Use perplexity_large to research: "Comprehensive analysis of quantum computing trends in 2024"Tool Specifications
Tool | Model | Use Case | Response Time | Features |
| sonar-pro | Quick facts, basic queries | ~3-10 seconds | Fast, reliable |
| sonar-reasoning-pro | Technical explanations | ~10-30 seconds | Enhanced reasoning |
| sonar-deep-research | Comprehensive research | ~5-30 minutes | Deep analysis, high quality |
Response Format
All tools return clean, structured responses:
{
"content": "The AI response with thinking tokens removed",
"citations": ["https://source1.com", "https://source2.com"]
}Development
Project Structure
Perplexity_MCP/
āāā server.py # FastMCP server with 3 tools
āāā client.py # Perplexity API wrapper
āāā config.py # Configuration and tool settings
āāā __init__.py # Package exports
āāā pyproject.toml # UV project configuration
āāā tests/
ā āāā tests.py # Test script for individual tools
ā āāā test_logs/ # Test results and logs
āāā Notes/
āāā explanations.md # Technical deep-dives
āāā questions.txt # Development questionsRunning Tests
Test individual tools to validate API integration:
# Test each tool independently
uv run python tests/tests.py small # Test sonar-pro model
uv run python tests/tests.py medium # Test sonar-reasoning-pro
uv run python tests/tests.py large # Test sonar-deep-research (long runtime)
# Results saved to tests/test_logs/ with detailed response analysisDevelopment Setup
Install development dependencies
uv sync --all-groupsRun the MCP server locally (for debugging)
uv run python server.pyCheck code quality
uv run ruff check . uv run black .
Configuration
Environment Variables
Variable | Required | Description |
| Yes | Your Perplexity API key from settings page |
Tool Configuration
The tools are configured in config.py:
TOOL_CONFIGS = {
"small": {
"model": "sonar-pro"
},
"medium": {
"model": "sonar-reasoning-pro",
"reasoning_effort": "medium",
"web_search_options": {"search_context_size": "medium"}
},
"large": {
"model": "sonar-deep-research",
"reasoning_effort": "high",
"web_search_options": {"search_context_size": "high"}
}
}Troubleshooting
Common Issues
Import Errors
ModuleNotFoundError: No module named 'client'Ensure you're running from the project root directory
Check that UV is using the correct virtual environment
API Key Issues
Error: PERPLEXITY_API_KEY environment variable is requiredVerify your
.envfile exists and contains the API keyCheck that the API key is valid on Perplexity's settings page
Claude Desktop Connection Issues
Verify the UV path in your configuration:
which uvEnsure the project directory path is absolute and correct
Check Claude Desktop logs for specific error messages
Restart Claude Desktop completely after configuration changes
Long Response Times
perplexity_largecan take 10-30 minutes for complex queriesUse
perplexity_smallorperplexity_mediumfor faster responsesConsider the complexity of your query when choosing tools
Debug Mode
Enable verbose logging by running the server directly:
uv run python server.py
# Check stderr output for detailed logging informationTest Individual Components
# Test API connection
uv run python -c "from client import PerplexityClient; print('ā
Client OK')"
# Test configuration
uv run python -c "from config import get_api_key; print('ā
API Key OK')"
# Test server startup
timeout 10s uv run python server.py || echo "Server started successfully"Contributing
Fork the repository
Create a feature branch:
git checkout -b feature-nameMake your changes and test thoroughly
Update documentation as needed
Submit a pull request
Development Guidelines
Follow existing code style (Black formatting, type hints)
Add tests for new functionality
Update
CLAUDE.mdfor any architectural changesTest with all three Perplexity models
Ensure MCP protocol compliance (clean stdout)
Architecture
Key Design Decisions
Class-based client: Singleton pattern for efficient resource management
Thinking token removal: Automatic filtering of
<think>...</think>sectionsSimplified responses: Only content and citations for clean integration
Error isolation: No exceptions propagated to MCP layer
Logging strategy: All debug output to stderr for MCP compliance
Dependencies
mcp>=1.11.0- MCP Python SDK with FastMCPpython-dotenv>=1.1.1- Environment variable managementhttpx>=0.28.1- Modern HTTP client with timeout handling
License
MIT License - see LICENSE file for details.
Acknowledgments
Perplexity AI for the powerful search-enhanced language models
Anthropic for Claude and the MCP protocol
FastMCP for the excellent MCP framework
Support
For API issues: Perplexity Support
For MCP protocol questions: MCP Documentation
For Claude Desktop issues: Claude Support
Note: This MCP server is currently optimized for local development and personal use. Future versions may include PyPI distribution options for easier installation and sharing.
Available Tools
3 toolsperplexity_largeA
Comprehensive research with maximum depth using sonar-deep-research.
Best for: Deep research tasks, comprehensive analysis, complex multi-step reasoning,
academic research, detailed technical investigations.
Uses high reasoning effort and search context size.
WARNING: This tool may take significantly longer (potentially 10-30 minutes)
and may timeout on very complex queries.
Args:
query: The question or prompt to send to Perplexity
messages: Optional conversation context (list of {"role": "user/assistant", "content": "..."})
Returns:
Dictionary with content and citations
Inputs: query (required), messages. Returns: result
perplexity_mediumA
Enhanced reasoning with moderate search depth using sonar-reasoning-pro.
Best for: Complex questions requiring analysis, moderate research depth,
technical explanations with citations.
Uses medium reasoning effort and search context size.
Args:
query: The question or prompt to send to Perplexity
messages: Optional conversation context (list of {"role": "user/assistant", "content": "..."})
Returns:
Dictionary with content and citations
Inputs: query (required), messages. Returns: result
perplexity_smallA
Quick and reliable queries using Perplexity's sonar-pro model.
Best for: Fast factual questions, basic research, immediate answers.
Uses default parameters for optimal speed and cost-effectiveness.
Args:
query: The question or prompt to send to Perplexity
messages: Optional conversation context (list of {"role": "user/assistant", "content": "..."})
Returns:
Dictionary with content and citations
Inputs: query (required), messages. Returns: result
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelogā¦
TDQS
Scored across 3 tools
The three tools are clearly distinguished by their intended use cases and performance characteristics: 'large' for deep research with maximum depth, 'medium' for enhanced reasoning with moderate depth, and 'small' for quick factual queries. Each tool's description explicitly outlines its best applications, reasoning effort, and expected response times, leaving no ambiguity about when to select which tool.
All tool names follow a perfectly consistent pattern: 'perplexity_' prefix followed by a size descriptor ('large', 'medium', 'small'). This naming convention immediately communicates that these are variations of the same core functionality with different scales, making the tool set predictable and easy to understand.
Three tools is an ideal number for this server's purpose: providing access to Perplexity's AI models at different capability levels. Each tool serves a distinct role in the research/query workflow, from quick lookups to comprehensive analysis, and no tool feels redundant or missing for the domain.
The tool set provides complete coverage for the server's domain of Perplexity AI queries. It offers a full spectrum of query capabilities from simple to complex, with clear guidance on when to use each tool. The consistent argument structure (query + optional messages) and return format ensure agents can work seamlessly across all tools without encountering dead ends or missing functionality.
Maintenance
Related MCP Connectors
Agent personas for Claude. 16 tools, 13 personas, 3 workflows. Zero extra API cost. Free.
One workspace of tools for Claude and ChatGPT: connect 600+ apps, generate media, build tools.
Claude-powered AI tools: research, write, code, analyze, translate, debate, pitch, score, and more.
SEO research, Search Console, GA4 and PPC tools for Claude and ChatGPT.
Related MCP Servers
- AlicenseCqualityDmaintenanceA custom MCP tool that integrates Perplexity AI's API with Claude Desktop, allowing Claude to perform web-based research and provide answers with citations.16MIT
- AlicenseBqualityDmaintenanceA powerful research assistant that integrates with Cline and Claude Desktop to leverage Perplexity AI for intelligent search, documentation retrieval, API discovery, and code modernization assistance while coding.45MIT
- AlicenseNot gradedqualityDmaintenanceProvides AI-powered search, research, and reasoning capabilities through integration with Perplexity.ai, offering three specialized tools: general conversational AI, deep research with citations, and advanced reasoning.2MIT
- AlicenseAqualityDmaintenanceConnects Claude to Perplexity Comet's agentic browser for autonomous web browsing, deep research, and real-time task monitoring. Enables Claude to delegate web research tasks and receive comprehensive results through multiple browsing modes.668 npm181MIT