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.
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
Quick Start
Prerequisites
Installation
- Clone the repository
- Install dependencies
- Set up environment
- Test the installation
Claude Desktop Integration
- Find your UV path
- Configure Claude DesktopEdit
~/Library/Application Support/Claude/claude_desktop_config.json
: - Restart Claude DesktopCompletely 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:
Technical analysis:
Deep research:
Tool Specifications
Tool | Model | Use Case | Response Time | Features |
---|---|---|---|---|
perplexity_small | sonar-pro | Quick facts, basic queries | ~3-10 seconds | Fast, reliable |
perplexity_medium | sonar-reasoning-pro | Technical explanations | ~10-30 seconds | Enhanced reasoning |
perplexity_large | sonar-deep-research | Comprehensive research | ~5-30 minutes | Deep analysis, high quality |
Response Format
All tools return clean, structured responses:
Development
Project Structure
Running Tests
Test individual tools to validate API integration:
Development Setup
- Install development dependencies
- Run the MCP server locally (for debugging)
- Check code quality
Configuration
Environment Variables
Variable | Required | Description |
---|---|---|
PERPLEXITY_API_KEY | Yes | Your Perplexity API key from settings page |
Tool Configuration
The tools are configured in config.py
:
Troubleshooting
Common Issues
Import Errors
- Ensure you're running from the project root directory
- Check that UV is using the correct virtual environment
API Key Issues
- Verify your
.env
file exists and contains the API key - Check that the API key is valid on Perplexity's settings page
Claude Desktop Connection Issues
- Verify the UV path in your configuration:
which uv
- Ensure 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_large
can take 10-30 minutes for complex queries- Use
perplexity_small
orperplexity_medium
for faster responses - Consider the complexity of your query when choosing tools
Debug Mode
Enable verbose logging by running the server directly:
Test Individual Components
Contributing
- Fork the repository
- Create a feature branch:
git checkout -b feature-name
- Make 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.md
for any architectural changes - Test 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>
sections - Simplified 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.
This server cannot be installed
Integrates Perplexity AI's search-enhanced language models with Claude Desktop, providing three tools with different complexity levels for quick fact-checking, technical analysis, and deep research.
Related MCP Servers
- AsecurityAlicenseAqualityA server facilitating web search functionality by utilizing Perplexity AI's API, designed to integrate with the Claude desktop client for enhanced search queries.Last updated -1205PythonMIT License
- AsecurityAlicenseAqualityEnables intelligent code analysis and debugging through the Perplexity AI's API, offering detailed error analysis, pattern detection, and comprehensive solutions, with integration support for the Claude desktop client.Last updated -169611JavaScriptMIT License
- AsecurityAlicenseAqualityFacilitates web search capabilities using Perplexity's API, allowing users to retrieve search results through Claude's interface.Last updated -13JavaScriptMIT License
- AsecurityAlicenseAqualityA custom MCP tool that integrates Perplexity AI's API with Claude Desktop, allowing Claude to perform web-based research and provide answers with citations.Last updated -14JavaScriptMIT License