perplexity mcp
An MCP server that enables Claude to perform web searches using Perplexity's API with intelligent model selection based on query intent and support for domain and recency filtering.
An MCP server that enables Claude to perform web searches using Perplexity's API with intelligent model selection based on query intent and support for domain and recency filtering.
An MCP server that provides web search capabilities using Perplexity's API with automatic model selection based on query intent.
Clone this repository:
git clone https://github.com/RossH121/perplexity-mcp.git
cd perplexity-mcp
Install dependencies:
npm install
Build the server:
npm run build
Get your Perplexity API key from https://www.perplexity.ai/settings/api
Add the server to Claude's config file at ~/Library/Application Support/Claude/claude_desktop_config.json
:
{
"mcpServers": {
"perplexity-server": {
"command": "node",
"args": [
"/absolute/path/to/perplexity-mcp/build/index.js"
],
"env": {
"PERPLEXITY_API_KEY": "your-api-key-here",
"PERPLEXITY_MODEL": "sonar"
}
}
}
}
Replace /absolute/path/to
with the actual path to where you cloned the repository.
The server now supports automatic model selection based on query intent, but you can also specify a default model using the PERPLEXITY_MODEL
environment variable. Available options:
sonar-deep-research
- Specialized for extensive research and expert-level analysis across domainssonar-reasoning-pro
- Optimized for advanced logical reasoning and complex problem-solvingsonar-reasoning
- Designed for reasoning tasks with balanced performancesonar-pro
- General-purpose model with excellent search capabilities and citation densitysonar
- Fast and efficient for straightforward queriesThe default model (specified in the environment variable) will be used as the baseline for automatic model selection.
For up-to-date model pricing and availability, visit: https://docs.perplexity.ai/guides/pricing
After configuring the server and restarting Claude, you can simply ask Claude to search for information. For example:
Claude will automatically use the Perplexity search tool to find and return relevant information. The server will automatically select the most appropriate model based on your query's intent.
If for whatever reason it decides not to use the search tool, you can force the issue by prepending your prompt with "Search the web".
The server automatically selects the most appropriate Perplexity model based on your query:
Each search response includes information about which model was used and why.
This server supports domain filtering to customize your search experience. You can allow or block specific domains using these commands:
Note: Perplexity API supports up to 3 domains total with priority given to allowed domains. Domain filtering requires a Perplexity API tier that supports this feature.
Example usage flow: 1. "Use the domain_filter tool to allow wikipedia.org" 2. "Use the domain_filter tool to allow arxiv.org" 3. "Use the list_filters tool" (to verify your settings) 4. "Search for quantum computing advances" (results will prioritize wikipedia.org and arxiv.org)
You can limit search results to a specific time window using the recency filter:
This is particularly useful for time-sensitive queries like current events or breaking news.
While the automatic model selection works well for most cases, you can manually control which model is used:
Example usage: 1. "Use the model_info tool" (to see available models and current status) 2. "Use the model_info tool with model=sonar-reasoning-pro" (to force using reasoning model) 3. "Search for a mathematical proof of the Pythagorean theorem" (will use sonar-reasoning-pro) 4. "Use the model_info tool with model=sonar-pro" (to return to automatic selection)
To modify the server:
src/index.ts
npm run build
MIT
[
{
"description": "Search the web using Perplexity AI",
"inputSchema": {
"properties": {
"query": {
"description": "The search query",
"type": "string"
}
},
"required": [
"query"
],
"type": "object"
},
"name": "search"
},
{
"description": "Add a domain to allow or block in search results (max 3 domains per type)",
"inputSchema": {
"properties": {
"action": {
"description": "Whether to allow or block this domain",
"enum": [
"allow",
"block"
],
"type": "string"
},
"domain": {
"description": "Domain name without http:// or https:// (example: wikipedia.org)",
"type": "string"
}
},
"required": [
"domain",
"action"
],
"type": "object"
},
"name": "domain_filter"
},
{
"description": "Set the time recency for search results",
"inputSchema": {
"properties": {
"filter": {
"description": "Time window for search results (none to disable filtering)",
"enum": [
"hour",
"day",
"week",
"month",
"none"
],
"type": "string"
}
},
"required": [
"filter"
],
"type": "object"
},
"name": "recency_filter"
},
{
"description": "Clear all domain filters",
"inputSchema": {
"properties": {},
"type": "object"
},
"name": "clear_filters"
},
{
"description": "List all current domain filters",
"inputSchema": {
"properties": {},
"type": "object"
},
"name": "list_filters"
},
{
"description": "Get information about available models and optionally set a specific model",
"inputSchema": {
"properties": {
"model": {
"description": "Optional: Set a specific model instead of using automatic selection",
"enum": [
"sonar-deep-research",
"sonar-reasoning-pro",
"sonar-reasoning",
"sonar-pro",
"sonar"
],
"type": "string"
}
},
"type": "object"
},
"name": "model_info"
}
]