Perplexity Advanced MCP server

Command-line interface for interacting with Perplexity and OpenRouter APIs, supporting both simple queries and complex file attachments with easy provider switching through a containerized Docker implementation.
Back to servers
Provider
YeonGyu Kim
Release date
Feb 16, 2025
Language
Python
Package
Stats
2.3K downloads
22 stars

This MCP server provides an advanced integration for the Perplexity and OpenRouter APIs, allowing you to perform simple and complex queries with AI models. It's designed for optimal performance when handling codebases and can be easily integrated with code editors like Cline or Cursor.

Installation Options

Quick Installation via Smithery

For Claude Desktop users, the easiest installation method is via Smithery:

npx -y @smithery/cli install @code-yeongyu/perplexity-advanced-mcp --client claude

Standard Installation with uvx

To run the MCP server using uvx:

uvx perplexity-advanced-mcp -o <openrouter_api_key> # or -p <perplexity_api_key>

You can also configure API keys using environment variables:

export OPENROUTER_API_KEY="your_key_here"
# or
export PERPLEXITY_API_KEY="your_key_here"

uvx perplexity-advanced-mcp

Important notes:

  • You must provide either an OpenRouter API key OR a Perplexity API key, not both
  • Command-line arguments take precedence over environment variables

Usage Guide

Query Types

The MCP server supports two types of queries:

  • Simple Queries: Fast and cost-effective for basic questions
  • Complex Queries: More powerful for detailed analysis, supports file attachments

AI Assistant Configuration

For optimal integration with AI assistants (Cursor, Claude for Desktop), add this configuration to your project instructions:

<perplexity-advanced-mcp>
    <description>
        Perplexity is an LLM that can search the internet, gather information, and answer users' queries.

        For example, let's suppose we want to find out the latest version of Python.
        1. You would search on Google.
        2. Then read the top two or three results directly to verify.

        Perplexity does that work for you.

        To answer a user's query, Perplexity searches, opens the top search results, finds information on those websites, and then provides the answer.

        Perplexity can be used with two types of queries: simple and complex. Choosing the right query type to fulfill the user's request is most important.
    </description>
    <simple-query>
        <description>
            It's cheap and fast. However, it's not suitable for complex queries. On average, it's more than 10 times cheaper and 3 times faster than complex queries.
            Use it for simple questions such as "What is the latest version of Python?"
        </description>
        <pricing>
            $1/M input tokens
            $1/M output tokens
        </pricing>
    </simple-query>

    <complex-query>
        <description>
            It's slower and more expensive. Compared to simple queries, it's on average more than 10 times more expensive and 3 times slower.
            Use it for more complex requests like "Analyze the attached code to examine the current status of a specific library and create a migration plan."
        </description>
        <pricing>
            $1/M input tokens
            $5/M output tokens
        </pricing>
    </complex-query>

    <instruction>
        When reviewing the user's request, if you find anything unexpected, uncertain, or questionable, **and you think you can get answer from the internet**, do not hesitate to use the "ask_perplexity" tool to consult Perplexity. However, if the internet is not required to satisfy users' request, it's meaningless to ask to perplexity.
        Since Perplexity is also an LLM, prompt engineering techniques are paramount.
        Remember the basics of prompt engineering, such as providing clear instructions, sufficient context, and examples
        Include as much context and relevant files as possible to smoothly fulfill the user's request. When adding files as attachments, make sure they are absolute paths.
    </instruction>
</perplexity-advanced-mcp>

Model Configuration

The server uses specific models for different query types:

OpenRouter Models

  • Simple Queries: perplexity/sonar
  • Complex Queries: perplexity/sonar-reasoning

Perplexity Models

  • Simple Queries: sonar-pro
  • Complex Queries: sonar-reasoning-pro

Key Features

  • Multi-vendor Support: Works with both Perplexity and OpenRouter APIs
  • Query Optimization: Automatically selects the appropriate model based on query complexity
  • File Attachment Support: Include file contents as context for more precise responses
  • Enhanced Reliability: Implements robust retry mechanisms for API communications

How to add this MCP server to 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 > MCP and click "Add new global MCP server".

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

{
    "mcpServers": {
        "cursor-rules-mcp": {
            "command": "npx",
            "args": [
                "-y",
                "cursor-rules-mcp"
            ]
        }
    }
}

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 explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.

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