Supports loading API keys from .env files, providing a secure way to configure the server without hardcoding sensitive information.
Includes specific configuration instructions for Claude Desktop on macOS, detailing the path to the configuration file.
Provides web search functionality through Perplexity's API, allowing for comprehensive search results with sources and citations, and filtering by time period (day, week, month, year).
Uses Python for server implementation, with specific commands for running and testing the server functionality.
Perplexity Web Search MCP Server
A simple MCP (Model Context Protocol) server that provides web search functionality using the Perplexity API. This server allows Claude or other MCP-compatible AI assistants to search the web and get up-to-date information.
Features
Search the web with Perplexity's powerful search capabilities
Get comprehensive search results with sources and citations
Filter results by time period (day, week, month, year)
Includes a ready-to-use prompt template for web searches
Supports loading API key from environment variables or .env file
Installation
Clone this repository
Install dependencies:
pip install -e .or
uv pip install -e .
Configuration
You can set the PERPLEXITY_API_KEY
environment variable with your Perplexity API key:
Alternatively, you can create a .env
file in the project root with the following content:
A sample .env.example
file is provided for reference.
To get a Perplexity API key:
Visit Perplexity API Settings
Create an account if you don't have one
Generate an API key
Usage
Running the server
Testing the server
You can test the server functionality without running the full MCP server using the included test script:
Options for --recency
are: day, week, month (default), year
Using with Claude Desktop
Edit your Claude Desktop configuration file:
On macOS:
~/Library/Application\ Support/Claude/claude_desktop_config.json
On Windows:
%APPDATA%/Claude/claude_desktop_config.json
Add the following configuration:
{ "perplexity-mcp": { "env": { "PERPLEXITY_API_KEY": "your-api-key-here" }, "command": "python", "args": [ "/path/to/server.py" ] } }Restart Claude Desktop
Example Prompts for Claude
"Search the web for the latest news about artificial intelligence"
"Use Perplexity to find information about climate change published in the past week"
"Search for recent research papers on quantum computing from the past month"
API Reference
Tool: search_web(query: str, recency: str = "month") -> str
Search the web using Perplexity API and return results.
Parameters:
query
: The search query stringrecency
: Filter results by time period - 'day', 'week', 'month' (default), or 'year'
Returns: A comprehensive text response containing:
A detailed summary of the search results
Key facts and information found
Sources with URLs for verification
Any conflicting information if present
Prompt: web_search_prompt(query: str, recency: str = "month") -> str
Creates a prompt template for searching the web with Perplexity.
Parameters:
query
: The search queryrecency
: Time period filter - 'day', 'week', 'month' (default), or 'year'
Returns: A formatted prompt string that instructs the AI to:
Search for the specified query
Focus on results from the specified time period
Summarize key findings
Highlight important facts
Mention conflicting information
Cite sources with links
License
MIT
This server cannot be installed
remote-capable server
The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.
Allows Claude or other MCP-compatible AI assistants to search the web and get up-to-date information using the Perplexity API, with features for filtering results by time period.
Related Resources
Related MCP Servers
- AsecurityAlicenseAqualityA server facilitating web search functionality by utilizing Perplexity AI's API, designed to integrate with the Claude desktop client for enhanced search queries.Last updated -251MIT License
- AsecurityAlicenseAqualityFacilitates web search capabilities using Perplexity's API, allowing users to retrieve search results through Claude's interface.Last updated -4MIT License
- AsecurityAlicenseAqualityAn MCP server integrating Perplexity AI's API to offer advanced search capabilities with support for multiple models and result configuration.Last updated -4271MIT License
- AsecurityAlicenseAqualityA custom MCP tool that integrates Perplexity AI's API with Claude Desktop, allowing Claude to perform web-based research and provide answers with citations.Last updated -14MIT License