Perplexity Search MCP server

Enhances Claude with intelligent web search capabilities through Perplexity API, automatically selecting optimal models based on query intent while supporting customizable domain and recency filtering.
Back to servers
Setup instructions
Provider
Ross H
Release date
Mar 07, 2025
Language
TypeScript

This MCP server provides web search capabilities through Perplexity's API, offering automatic model selection based on your query intent. It analyzes what you're asking for and chooses the most appropriate Perplexity model to deliver better search results.

Prerequisites

  • Node.js (v14 or higher)
  • A Perplexity API key
  • Claude Desktop App

Installation

Installing via Git

  1. Clone the repository:

    git clone https://github.com/RossH121/perplexity-mcp.git
    cd perplexity-mcp
    
  2. Install dependencies:

    npm install
    
  3. Build the server:

    npm run build
    

Configuration

  1. Get your Perplexity API key from Perplexity's settings page

  2. 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"
          }
        }
      }
    }
    

    Be sure to replace /absolute/path/to with the actual path to where you cloned the repository.

Available Models

The server supports automatic model selection based on query intent, but you can specify a default model using the PERPLEXITY_MODEL environment variable:

  • sonar-deep-research - For extensive research and expert-level analysis
  • sonar-reasoning-pro - For advanced logical reasoning and complex problem-solving
  • sonar-reasoning - For reasoning tasks with balanced performance
  • sonar-pro - General-purpose model with excellent search capabilities
  • sonar - Fast and efficient for straightforward queries

For current model pricing and availability, visit: Perplexity Pricing

Usage

After configuring the server and restarting Claude, simply ask questions that require web search:

  • "What's the latest news about SpaceX?"
  • "Search for the best restaurants in Chicago"
  • "Find information about the history of jazz music"
  • "I need a deep research analysis of recent AI developments"
  • "Help me reason through this complex problem"

If Claude doesn't automatically use the search tool, try prepending "Search the web" to your prompt.

Intelligent Model Selection

The server automatically selects the most appropriate Perplexity model based on your query:

  • Use terms like "deep research," "comprehensive," or "in-depth" to trigger sonar-deep-research
  • Use terms like "solve," "figure out," or "complex problem" to trigger sonar-reasoning-pro
  • Use terms like "quick," "brief," or "basic" to trigger the lightweight sonar model
  • General search terms default to sonar-pro for balanced performance

Each search response includes information about which model was used and why.

Domain Filtering

You can customize your search experience by allowing or blocking specific domains:

  • Add allowed domain: "Use the domain_filter tool to allow wikipedia.org"
  • Add blocked domain: "Use the domain_filter tool to block pinterest.com"
  • View current filters: "Use the list_filters tool"
  • Clear all filters: "Use the clear_filters tool"

Note: Perplexity API supports up to 3 domains total with priority given to allowed domains.

Recency Filtering

Limit search results to a specific time window:

  • Set recency filter: "Use the recency_filter tool with filter=hour" (options: hour, day, week, month)
  • Disable recency filter: "Use the recency_filter tool with filter=none"

This is particularly useful for time-sensitive queries like current events.

Model Selection Control

Manually control which model is used:

  • View model information: "Use the model_info tool"
  • Set a specific model: "Use the model_info tool with model=sonar-deep-research"
  • Return to automatic selection: Set the model back to the default model

Example workflow:

  1. "Use the model_info tool" (to see available models)
  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)

How to install this MCP server

For Claude Code

To add this MCP server to Claude Code, run this command in your terminal:

claude mcp add-json "perplexity-server" '{"command":"node","args":["/absolute/path/to/perplexity-mcp/build/index.js"],"env":{"PERPLEXITY_API_KEY":"your-api-key-here","PERPLEXITY_MODEL":"sonar"}}'

See the official Claude Code MCP documentation for more details.

For Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "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"
            }
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.

For Claude Desktop

To add this MCP server to Claude Desktop:

1. Find your configuration file:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • Linux: ~/.config/Claude/claude_desktop_config.json

2. Add this to your configuration file:

{
    "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"
            }
        }
    }
}

3. Restart Claude Desktop for the changes to take effect

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later