A search tool for LLMs that connects to the Perplexity API, providing up-to-date information with powerful filtering options and MCP integration.
- Perplexity API Integration: Access current information from the web
- Advanced Filtering: Filter results by recency and domains
- Source Attribution: Proper citation of information sources
- Model Selection: Use different Perplexity models for different needs
- MCP Integration: Standardized interface for LLMs via Model Context Protocol
git clone https://github.com/fredrikangelsen/perplexity-search.git
cd perplexity-search
uv tool install --editable .# Run the server with default settings
perplexity-search server
# With custom API key
perplexity-search server --api-key YOUR_API_KEY
# With specific model selection
perplexity-search server --model sonar-reasoning-pro
# With verbose logging
perplexity-search -v server
# View tool information and log file location
perplexity-search infoThe search tool provides the following MCP tools:
Search the web for up-to-date information using Perplexity API.
perplexity_search(
query="latest developments in fusion energy",
search_recency_filter="week", # Optional: "hour", "day", "week", "month"
domain_filter=["nature.com", "science.org"] # Optional: limit to specific domains
)The tool stores logs in platform-specific standard locations:
- Linux:
~/.local/share/perplexity-search/logs/perplexity_search.log - macOS:
~/Library/Logs/perplexity-search/perplexity_search.log - Windows:
%LOCALAPPDATA%\perplexity-search\logs\perplexity_search.log
Enable verbose logging with the -v flag:
perplexity-search -v serverGet the current log file location with:
perplexity-search infoThe tool needs a Perplexity API key to function, which is provided as an argument when registering the tool with Claude Code:
# Register with API key (recommended approach)
claude mcp add perplexity-search \
-e PERPLEXITY_API_KEY=your_key_here \
-- perplexity-search serverTo get a Perplexity API key:
- Create an account at Perplexity AI
- Navigate to the API Keys section
- Generate a new API key
The Perplexity API offers several models with different capabilities:
- sonar: Default model (128k context)
- sonar-pro: Higher capacity model (200k context, 8k output limit)
- sonar-reasoning: Includes chain-of-thought in responses (128k context)
- sonar-reasoning-pro: Pro version with CoT reasoning (128k context, 8k output limit)
- sonar-deep-research: For comprehensive research (128k context)
- r1-1776: Offline chat model (no search subsystem, 128k context)
You can add perplexity-search as an MCP server to Claude Code:
# Start by installing the tool
git clone https://github.com/fredrikangelsen/perplexity-search.git
cd perplexity-search
uv tool install --editable .
# Add the MCP server to Claude Code
# Basic usage - note: requires PERPLEXITY_API_KEY in environment
claude mcp add perplexity-search -- perplexity-search server
# Recommended: With API key (note the -- separator is required)
claude mcp add perplexity-search \
-e PERPLEXITY_API_KEY=your_key_here \
-- perplexity-search server
# With global installation and custom model
# -s global Store config globally (all projects)
# -e PERPLEXITY_API_KEY= Set environment variable for API key
# -- perplexity-search server Command to run (note the -- separator)
# --model Select specific Perplexity model
# --temperature Optional: Lower temperature for precision
# --max-tokens Optional: Increase token limit
claude mcp add perplexity-search \
-s global \
-e PERPLEXITY_API_KEY=your_key_here \
-- perplexity-search server \
--model sonar-reasoning-pro \
--temperature 0.1 \
--max-tokens 2048
# Verify it was added correctly
claude mcp list
# Use Claude Code with the search tool
claudeThe -s global flag stores the configuration globally rather than just for the current project.
Once added, Claude will have access to web search capabilities through the perplexity_search tool.
- Claude Code: Set up Model Context Protocol (MCP)
- Model Context Protocol: Server Quickstart
- Perplexity API: Getting Started
- Perplexity API: Chat Completions Reference
MIT License