Skip to content

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

1 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

Repository files navigation

Perplexity Search

A search tool for LLMs that connects to the Perplexity API, providing up-to-date information with powerful filtering options and MCP integration.

Features

  • 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

Installation

git clone https://github.com/fredrikangelsen/perplexity-search.git
cd perplexity-search
uv tool install --editable .

Usage

Running the MCP Server

# 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 info

Using with LLMs

The search tool provides the following MCP tools:

1. perplexity_search

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
)

Technical Implementation Details

Logging

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 server

Get the current log file location with:

perplexity-search info

API Authentication

The 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 server

To get a Perplexity API key:

  1. Create an account at Perplexity AI
  2. Navigate to the API Keys section
  3. Generate a new API key

Model Selection

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)

Adding to Claude Code

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
claude

The -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.

Resources

License

MIT License

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages