MCP HubMCP Hub
jsonallen

perplexity-mcp

by: jsonallen

A Model Context Protocol (MCP) server that provides web search functionality using Perplexity AI's API.

123created 27/12/2024
Visit
API
search

📌Overview

Purpose: To provide an MCP server that enables web search functionality using Perplexity AI's API for enhanced information retrieval.

Overview: The Perplexity MCP server integrates with the Anthropic Claude desktop client, allowing users to perform web searches effortlessly. By leveraging the API from Perplexity AI, it effectively facilitates real-time access to updated information, enabling users to query the web for recent developments in specified domains.

Key Features:

  • Web Search Functionality: Users can execute web searches through the perplexity_search_web command by providing a search query. This feature is critical for seeking out the latest information across various topics.

  • Recency Filtering: The tool allows users to filter search results based on recency (last 24 hours, last week, etc.), enhancing the relevance of the retrieved data according to the user's needs.


Perplexity MCP Server

A Model Context Protocol (MCP) server that provides web search functionality using Perplexity AI's API. It works with the Anthropic Claude desktop client.

Example Usage

You can use prompts like, "Search the web to find out what's new at Anthropic in the past week."

Components

Prompts

The server provides a single prompt:

  • perplexity_search_web: Search the web using Perplexity AI
    • Required: query argument for the search query
    • Optional: recency argument to filter results by time period:
      • 'day': last 24 hours
      • 'week': last 7 days
      • 'month': last 30 days (default)
      • 'year': last 365 days

Tools

The server implements one tool:

  • perplexity_search_web
    • Takes query as a required string argument
    • Optional recency parameter to filter results (day/week/month/year)
    • Returns search results from Perplexity's API

Installation

Installing via Smithery

To install Perplexity MCP for Claude Desktop automatically via Smithery:

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

Requirements

You need to install UV (Fast Python package and project manager).

# Using Homebrew on macOS
brew install uv

or

# On macOS and Linux
curl -LsSf https://astral.sh/uv/install.sh | sh

# On Windows
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"

Environment Variables

You need to set the following environment variable in your claude_desktop_config.json. Obtain an API key from Perplexity:

  • PERPLEXITY_API_KEY: Your Perplexity AI API key

Optional:

  • PERPLEXITY_MODEL: The Perplexity model to use (defaults to "sonar" if not specified). Available models include:
    • sonar-deep-research
    • sonar-reasoning-pro
    • sonar-reasoning
    • sonar-pro
    • sonar
    • r1-1776

An updated list of models is available here.

Configuring Cursor & Claude Desktop

Add this tool as an MCP server by editing the configuration file.

"perplexity-mcp": {
  "env": {
    "PERPLEXITY_API_KEY": "XXXXXXXXXXXXXXXXXXXX",
    "PERPLEXITY_MODEL": "sonar"
  },
  "command": "uvx",
  "args": [
    "perplexity-mcp"
  ]
}

File Locations

  • Cursor:

    • MacOS: /Users/your-username/.cursor/mcp.json
    • Windows: C:\Users\your-username\.cursor\mcp.json
  • Claude Desktop:

    • MacOS: ~/Library/Application Support/Claude/claude_desktop_config.json
    • Windows: %APPDATA%/Claude/claude_desktop_config.json

To verify the server is working, open the Claude client and use a prompt such as "search the web for news about OpenAI in the past week." You should see a confirmation alert for tool usage. Click "Allow for this chat."