perplexity-mcp
by: DaInfernalCoder
A Model Context Protocol (MCP) server for research and documentation assistance using Perplexity AI. Won 1st @ Cline Hackathon
📌Overview
Purpose: To provide a comprehensive research assistant tool within the Cline environment using Perplexity's Sonar Pro API, enhancing development efficiency.
Overview: The MCP-researcher Server integrates various functionalities aimed at improving the process of gathering information and managing code. It allows users to access documentation, check for deprecated code, and discover APIs seamlessly during development tasks.
Key Features:
-
Search Tool: Enables users to perform tailored search queries to gather comprehensive information on any topic, with customizable levels of detail.
-
Get Documentation: Retrieves extensive documentation and examples for specific technologies or APIs, assisting developers in following best practices effectively.
-
Find APIs: Identifies potential APIs for project integration, providing detailed analysis on features and implementation complexity.
-
Check Deprecated Code: Scans code for deprecated features, offering guidance on modern alternatives to ensure up-to-date coding practices.
Perplexity MCP Server
An intelligent research assistant powered by Perplexity's specialized AI models. It features automatic query complexity detection to route requests to the most appropriate model for optimal results. Unlike the official server, it has search capabilities for every task.
Tools
Note: The Deep Research tool may timeout with some tools like cline, but not with others like cursor due to implementation differences.
1. Search (Sonar Pro)
Quick search for simple queries and basic information lookup. Best for straightforward questions needing concise, direct answers.
const result = await use_mcp_tool({
server_name: "perplexity",
tool_name: "search",
arguments: {
query: "What is the capital of France?",
force_model: false // Optional: force using this model even if query seems complex
}
});
2. Reason (Sonar Reasoning Pro)
Handles complex, multi-step tasks requiring detailed analysis. Perfect for explanations, comparisons, and problem-solving.
const result = await use_mcp_tool({
server_name: "perplexity",
tool_name: "reason",
arguments: {
query: "Compare and contrast REST and GraphQL APIs, explaining their pros and cons",
force_model: false // Optional: force using this model even if query seems simple
}
});
3. Deep Research (Sonar Deep Research)
Conducts comprehensive research and generates detailed reports. Ideal for in-depth analysis of complex topics.
const result = await use_mcp_tool({
server_name: "perplexity",
tool_name: "deep_research",
arguments: {
query: "The impact of quantum computing on cryptography",
focus_areas: [
"Post-quantum cryptographic algorithms",
"Timeline for quantum threats",
"Practical mitigation strategies"
],
force_model: false // Optional: force using this model even if query seems simple
}
});
Intelligent Model Selection
The server automatically analyzes query complexity to route requests to the most appropriate model:
-
Simple Queries → Sonar Pro
- Basic information lookup
- Straightforward questions
- Quick facts
-
Complex Queries → Sonar Reasoning Pro
- How/why questions
- Comparisons
- Step-by-step explanations
- Problem-solving tasks
-
Research Queries → Sonar Deep Research
- In-depth analysis
- Comprehensive research
- Detailed investigations
- Multi-faceted topics
You can override automatic selection by setting force_model: true
in any tool's arguments.
Setup
Prerequisites
- Node.js (from https://nodejs.org)
- Perplexity API key (from https://www.perplexity.ai/settings/api)
- Clone the repository to your local machine
Configure MCP Settings
Add to your MCP settings file (location varies by platform):
{
"mcpServers": {
"perplexity": {
"command": "node",
"args": ["/path/to/perplexity-server/build/index.js"],
"env": {
"PERPLEXITY_API_KEY": "YOUR_API_KEY_HERE"
},
"disabled": false,
"autoApprove": []
}
}
}
Alternatively, use NPX to avoid installing it locally (recommended for macOS):
{
"mcpServers": {
"perplexity": {
"command": "npx",
"args": [
"-y",
"perplexity-mcp"
],
"env": {
"PERPLEXITY_API_KEY": "your_api_key"
}
}
}
}