Skip to main content

Add your description here

Project description

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

  1. Clone this repository
  2. 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:

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:

  1. Visit Perplexity API Settings
  2. Create an account if you don't have one
  3. Generate an API key

Usage

Running the server

python server.py

Testing the server

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

Using with Claude Desktop

  1. Edit your Claude Desktop configuration file:

    • On macOS: ~/Library/Application\ Support/Claude/claude_desktop_config.json
    • On Windows: %APPDATA%/Claude/claude_desktop_config.json
  2. Add the following configuration:

    {
      "perplexity-mcp": {
        "env": {
          "PERPLEXITY_API_KEY": "your-api-key-here"
        },
        "command": "python",
        "args": [
          "/path/to/server.py"
        ]
      }
    }
    
  3. 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 string
  • recency: Filter results by time period - 'day', 'week', 'month' (default), or 'year'

Returns: A comprehensive text response containing:

  1. A detailed summary of the search results
  2. Key facts and information found
  3. Sources with URLs for verification
  4. 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 query
  • recency: Time period filter - 'day', 'week', 'month' (default), or 'year'

Returns: A formatted prompt string that instructs the AI to:

  1. Search for the specified query
  2. Focus on results from the specified time period
  3. Summarize key findings
  4. Highlight important facts
  5. Mention conflicting information
  6. Cite sources with links

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

iflow_mcp_perplexity_mcp-0.1.0.tar.gz (3.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

iflow_mcp_perplexity_mcp-0.1.0-py3-none-any.whl (4.5 kB view details)

Uploaded Python 3

File details

Details for the file iflow_mcp_perplexity_mcp-0.1.0.tar.gz.

File metadata

File hashes

Hashes for iflow_mcp_perplexity_mcp-0.1.0.tar.gz
Algorithm Hash digest
SHA256 4b441b96f786eae9265facfac7cc38532affe23aaf4e5b25c29f4e73315b512e
MD5 5855d78dc701c6404e8111b4fd7477fb
BLAKE2b-256 2577f45a210eddcd5018731e2bacd602988335006356efbf4429c12185c976d0

See more details on using hashes here.

File details

Details for the file iflow_mcp_perplexity_mcp-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for iflow_mcp_perplexity_mcp-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 65530121051fb37e93fca2b96d6e2d2d03bd27dd971bdfa36c7beae3407cf310
MD5 caaeceb53046bbd972bc9416c09df1cc
BLAKE2b-256 93ceed359023ac86f99cf5e3e8a014b6e9469eaad6b29ff110208db60edc0d2f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page