Perplexity MCP server

Integrates with Perplexity AI's language models, enabling enhanced interactions through chat completions and single-query tools.
Back to servers
Provider
laodev1
Release date
Dec 12, 2024
Language
TypeScript
Stats
6 stars

The Perplexity MCP Server implements Anthropic's Model Context Protocol (MCP) to enable Claude to interact with Perplexity's language models. This server acts as a bridge, allowing Claude to use Perplexity AI's capabilities through tool integration for enhanced AI interactions.

Available Tools

The server provides two main tools:

perplexity_chat

Advanced chat completion tool with full message history support.

{
  "name": "perplexity_chat",
  "description": "Generate a chat completion using Perplexity AI",
  "parameters": {
    "model": "string (optional) - One of: llama-3.1-sonar-small-128k-online, llama-3.1-sonar-large-128k-online, llama-3.1-sonar-huge-128k-online",
    "messages": "array of {role, content} objects - The conversation history",
    "temperature": "number (optional) - Sampling temperature between 0-2"
  }
}

perplexity_ask

Simplified single-query interface for quick questions.

{
  "name": "perplexity_ask",
  "description": "Send a simple query to Perplexity AI",
  "parameters": {
    "query": "string - The question or prompt to send",
    "model": "string (optional) - One of: llama-3.1-sonar-small-128k-online, llama-3.1-sonar-large-128k-online, llama-3.1-sonar-huge-128k-online"
  }
}

Installation

Follow these steps to install the Perplexity MCP Server:

  1. Clone the repository:

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

    npm install
    
  3. Create a .env file with your Perplexity API key:

    PERPLEXITY_API_KEY=your-api-key-here
    
  4. Build the project:

    npm run build
    

Claude Desktop Configuration

To integrate this server with Claude Desktop, update your claude_desktop_config.json file:

{
  "mcpServers": {
    "perplexity": {
      "command": "node",
      "args": ["path\\to\\perplexity-mcp-server\\dist\\index.js"],
      "env": {
        "PERPLEXITY_API_KEY": "YOUR_PERPLEXITY_API_KEY"
      }
    }
  }
}

The configuration file is typically located at:

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

Troubleshooting

If you encounter issues with the server:

Server Not Found

  • Verify the path in claude_desktop_config.json is correct
  • Ensure the server is built (npm run build)
  • Check if Node.js is in your PATH

Authentication Errors

  • Verify your Perplexity API key in the .env file
  • Check if the API key has the required permissions

Tool Execution Errors

  • Verify the tool parameters match the schema
  • Check network connectivity
  • Review server logs for detailed error messages

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