Perplexity MCP Server

Perplexity MCP Server

Integrates with Perplexity's API to provide web search and AI-powered answers with citations. Offers a three-tier research workflow: search for sources, ask for grounded AI answers, and ask_more for deeper analysis using advanced models.

Category
Visit Server

README

Perplexity MCP Server

A FastMCP server that integrates with Perplexity's API to provide web search and grounded AI answers.

Features

Three-Tier Research Workflow

  1. search - Ground yourself first

    • Find relevant sources before asking questions
    • Returns URLs, titles, and snippets
    • Use this when you don't know about a topic
  2. ask - Get AI answers (DEFAULT)

    • AI-synthesized answers with web grounding
    • Uses the sonar model (fast and cost-effective)
    • Includes citations and optional images/related questions
  3. ask_more - Dig deeper

    • More comprehensive analysis for complex questions
    • Uses the sonar-pro model (more capable but pricier)
    • Use when ask doesn't provide sufficient depth

Prerequisites

Local Setup

1. Install Dependencies

Using uv (recommended):

uv pip install -e .

Or using pip:

pip install -e .

2. Configure API Key

Copy the example environment file:

cp .env.example .env

Edit .env and add your Perplexity API key:

PERPLEXITY_API_KEY=your_api_key_here

3. Run the Server

Test the server locally:

uv run fastmcp run server.py

Or with the fastmcp CLI:

fastmcp run server.py

4. Install in Claude Desktop

Install the server for use with Claude Desktop:

fastmcp install claude-code server.py

Or manually add to your Claude Desktop config (~/Library/Application Support/Claude/claude_desktop_config.json on macOS):

{
  "mcpServers": {
    "perplexity": {
      "command": "uv",
      "args": ["run", "fastmcp", "run", "/absolute/path/to/server.py"],
      "env": {
        "PERPLEXITY_API_KEY": "your_api_key_here"
      }
    }
  }
}

Cloud Deployment (FastMCP Cloud)

Deploy to fastmcp.cloud for easy hosting:

1. Push to GitHub

git init
git add .
git commit -m "Initial commit"
git remote add origin https://github.com/yourusername/perplexity-mcp.git
git push -u origin main

2. Deploy on FastMCP Cloud

  1. Visit fastmcp.cloud
  2. Sign in with GitHub
  3. Create a new project and connect your repo
  4. Configure:
    • Entrypoint: server.py
    • Environment Variables: Add PERPLEXITY_API_KEY
  5. Deploy!

Your server will be available at https://your-project-name.fastmcp.app/mcp

FastMCP Cloud automatically:

  • ✅ Detects dependencies from pyproject.toml
  • ✅ Deploys on every push to main
  • ✅ Creates preview deployments for PRs
  • ✅ Handles HTTP transport and authentication

Tool Usage Guide

Research Workflow Example

1. Don't know about a topic? → Use search()
   search("latest AI research papers on transformers")

2. Found sources? → Use ask() to understand
   ask("What are the key innovations in transformer models?")

3. Need more depth? → Use ask_more()
   ask_more("Explain the mathematical foundations of attention mechanisms in transformers")

Tool Parameters

search(query, max_results=10, recency=None, domain_filter=None)

  • query: Search query string
  • max_results: Number of results (default: 10)
  • recency: Filter by time - "day", "week", "month", or "year"
  • domain_filter: Include/exclude domains
    • Include: ["wikipedia.org", "github.com"]
    • Exclude: ["-reddit.com", "-pinterest.com"]

ask(query, reasoning_effort="medium", ...)

  • query: Question to ask
  • reasoning_effort: "low", "medium" (default), or "high"
  • search_mode: "web" (default), "academic", or "sec"
  • recency: Time filter
  • domain_filter: Domain filter
  • return_images: Include images (default: False)
  • return_related_questions: Include follow-up questions (default: False)

ask_more(query, reasoning_effort="medium", ...)

Same parameters as ask(), but uses the more powerful sonar-pro model.

Cost Optimization

  • Start with search: Free/cheap way to find sources
  • Default to ask: Uses sonar (cost-effective)
  • Escalate to ask_more: Only when needed (more expensive)

Development

Project Structure

perplexity-mcp/
├── server.py           # Main FastMCP server
├── pyproject.toml      # Dependencies
├── .env.example        # Environment template
└── README.md          # This file

Inspect the Server

See what FastMCP Cloud will see:

fastmcp inspect server.py

API Reference

This server uses two Perplexity API endpoints:

  • Search API (/search) - Returns ranked search results
  • Chat Completions API (/chat/completions) - Returns AI-generated answers

Supported models:

  • sonar - Fast, cost-effective
  • sonar-pro - More comprehensive

Troubleshooting

API Key Issues

If you get authentication errors:

  1. Verify your API key at https://www.perplexity.ai/settings/api
  2. Check that PERPLEXITY_API_KEY is set correctly
  3. Make sure there are no extra spaces or quotes

Timeout Errors

If requests timeout:

  • The default timeout is 30s for search, 60s for chat
  • Complex questions may take longer
  • Consider using reasoning_effort="low" for faster responses

Local Testing

Test individual tools:

uv run fastmcp dev server.py

This opens an interactive development interface.

License

MIT

Contributing

Contributions welcome! Please open an issue or PR.

Links

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
E2B

E2B

Using MCP to run code via e2b.

Official
Featured