Perplexity Web Search
STDIOMCP server providing web search functionality using Perplexity API for AI assistants.
MCP server providing web search functionality using Perplexity API for AI assistants.
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.
pip install -e .
or
uv pip install -e .
You can set the PERPLEXITY_API_KEY
environment variable with your Perplexity API key:
export PERPLEXITY_API_KEY="your-api-key-here"
Alternatively, you can create a .env
file in the project root with the following content:
PERPLEXITY_API_KEY=your-api-key-here
A sample .env.example
file is provided for reference.
To get a Perplexity API key:
python server.py
You can test the server functionality without running the full MCP server using the included test script:
python test_server.py "your search query here" --recency month
Options for --recency
are: day, week, month (default), year
Edit your Claude Desktop configuration file:
~/Library/Application\ Support/Claude/claude_desktop_config.json
%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
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:
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:
MIT