Perplexity AI MCP server

Integrates with Perplexity AI to enable advanced search, documentation retrieval, and conversational capabilities for AI systems and developers.
Back to servers
Setup instructions
Provider
Riley Edwards
Release date
Feb 18, 2025
Language
TypeScript

This MCP server provides a simple way to access Perplexity AI's capabilities through the Model Context Protocol. It enables interactions like chatting, searching, and retrieving documentation with Perplexity AI through a standardized interface.

Installation

To set up the Perplexity AI MCP server:

  1. Install Node.js and npm on your system if not already installed

  2. Clone the repository to your local machine:

    git clone https://github.com/username/perplexity-mcp-server.git
    cd perplexity-mcp-server
    
  3. Install dependencies:

    npm install
    
  4. Configure your API key as an environment variable:

    export PERPLEXITY_API_KEY=your_api_key_here
    

    For Windows Command Prompt:

    set PERPLEXITY_API_KEY=your_api_key_here
    

    For Windows PowerShell:

    $env:PERPLEXITY_API_KEY="your_api_key_here"
    
  5. Start the server:

    npm start
    

Usage

The server provides multiple tools for interacting with Perplexity AI through the MCP interface.

Available Tools

  • Chat: Converse with Perplexity AI
  • Search: Perform web searches using Perplexity AI
  • Documentation: Retrieve documentation through Perplexity AI

Example MCP Client Usage

To interact with the server from an MCP client:

import { MCPClient } from '@modelcontextprotocol/client';

// Connect to the server
const client = new MCPClient('http://localhost:3000');

// Use the chat tool
const chatResponse = await client.runTool('chat', {
  message: 'Hello, can you help me understand quantum computing?'
});

// Use the search tool
const searchResponse = await client.runTool('search', {
  query: 'latest developments in AI'
});

console.log(chatResponse);
console.log(searchResponse);

Error Handling

The server includes built-in error handling for API failures. If you encounter issues with the Perplexity AI API, the server will return appropriate error messages rather than crashing.

Troubleshooting

If you encounter problems:

  • API Key Issues: Ensure your Perplexity API key is correctly set as an environment variable
  • Connection Problems: Verify the server is running and accessible
  • Response Errors: Check the server logs for details about API failures or other issues

For persistent problems, try restarting the server or checking your internet connection.

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-ai" '{"command":"npx","args":["-y","perplexity-mcp-server"]}'

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-ai": {
            "command": "npx",
            "args": [
                "-y",
                "perplexity-mcp-server"
            ]
        }
    }
}

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-ai": {
            "command": "npx",
            "args": [
                "-y",
                "perplexity-mcp-server"
            ]
        }
    }
}

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