Skip to main content
Glama
Rohit-Seelam

Perplexity MCP Server

by Rohit-Seelam

Perplexity MCP Server

A Model Context Protocol (MCP) server that integrates Perplexity AI's search-enhanced language models with Claude Desktop, providing three tools with progressive complexity for different use cases.

Features

šŸ” Three Complexity Levels

  • perplexity_small: Fast queries with sonar-pro model

  • perplexity_medium: Enhanced reasoning with sonar-reasoning-pro

  • perplexity_large: Deep research with sonar-deep-research

šŸš€ Optimized for Development

  • Clean responses (thinking tokens automatically removed)

  • Comprehensive error handling

  • Detailed logging for debugging

  • Built with FastMCP for reliability

šŸ”§ Modern Python Stack

  • UV for fast dependency management

  • HTTPX for modern HTTP client capabilities

  • Type hints throughout codebase

  • Comprehensive testing suite

Related MCP server: MCP-researcher Server

Quick Start

Prerequisites

Installation

  1. Clone the repository

    git clone <repository-url>
    cd Perplexity_MCP
  2. Install dependencies

    uv sync
  3. Set up environment

    echo "PERPLEXITY_API_KEY=your_api_key_here" > .env
  4. Test the installation

    uv run python tests/tests.py small

Claude Desktop Integration

  1. Find your UV path

    which uv
    # Example output: /Users/username/.local/bin/uv
  2. Configure Claude Desktop

    Edit ~/Library/Application Support/Claude/claude_desktop_config.json:

    {
      "mcpServers": {
        "perplexity-mcp": {
          "command": "/Users/username/.local/bin/uv",
          "args": [
            "--directory", 
            "/path/to/your/Perplexity_MCP",
            "run",
            "python",
            "server.py"
          ]
        }
      }
    }
  3. Restart Claude Desktop

    Completely quit and restart Claude Desktop to load the new MCP server.

Usage

In Claude Desktop

Once configured, you can use these tools in your conversations:

Quick factual queries:

Use perplexity_small to find: "What is the latest Python version?"

Technical analysis:

Use perplexity_medium to explain: "Compare REST vs GraphQL performance characteristics"

Deep research:

Use perplexity_large to research: "Comprehensive analysis of quantum computing trends in 2024"

Tool Specifications

Tool

Model

Use Case

Response Time

Features

perplexity_small

sonar-pro

Quick facts, basic queries

~3-10 seconds

Fast, reliable

perplexity_medium

sonar-reasoning-pro

Technical explanations

~10-30 seconds

Enhanced reasoning

perplexity_large

sonar-deep-research

Comprehensive research

~5-30 minutes

Deep analysis, high quality

Response Format

All tools return clean, structured responses:

{
  "content": "The AI response with thinking tokens removed",
  "citations": ["https://source1.com", "https://source2.com"]
}

Development

Project Structure

Perplexity_MCP/
ā”œā”€ā”€ server.py                # FastMCP server with 3 tools
ā”œā”€ā”€ client.py                # Perplexity API wrapper  
ā”œā”€ā”€ config.py                # Configuration and tool settings
ā”œā”€ā”€ __init__.py              # Package exports
ā”œā”€ā”€ pyproject.toml           # UV project configuration
ā”œā”€ā”€ tests/
│   ā”œā”€ā”€ tests.py             # Test script for individual tools
│   └── test_logs/           # Test results and logs
└── Notes/
    ā”œā”€ā”€ explanations.md      # Technical deep-dives
    └── questions.txt        # Development questions

Running Tests

Test individual tools to validate API integration:

# Test each tool independently
uv run python tests/tests.py small    # Test sonar-pro model
uv run python tests/tests.py medium   # Test sonar-reasoning-pro
uv run python tests/tests.py large    # Test sonar-deep-research (long runtime)

# Results saved to tests/test_logs/ with detailed response analysis

Development Setup

  1. Install development dependencies

    uv sync --all-groups
  2. Run the MCP server locally (for debugging)

    uv run python server.py
  3. Check code quality

    uv run ruff check .
    uv run black .

Configuration

Environment Variables

Variable

Required

Description

PERPLEXITY_API_KEY

Yes

Your Perplexity API key from settings page

Tool Configuration

The tools are configured in config.py:

TOOL_CONFIGS = {
    "small": {
        "model": "sonar-pro"
    },
    "medium": {
        "model": "sonar-reasoning-pro", 
        "reasoning_effort": "medium",
        "web_search_options": {"search_context_size": "medium"}
    },
    "large": {
        "model": "sonar-deep-research",
        "reasoning_effort": "high",
        "web_search_options": {"search_context_size": "high"}
    }
}

Troubleshooting

Common Issues

Import Errors

ModuleNotFoundError: No module named 'client'
  • Ensure you're running from the project root directory

  • Check that UV is using the correct virtual environment

API Key Issues

Error: PERPLEXITY_API_KEY environment variable is required

Claude Desktop Connection Issues

  • Verify the UV path in your configuration: which uv

  • Ensure the project directory path is absolute and correct

  • Check Claude Desktop logs for specific error messages

  • Restart Claude Desktop completely after configuration changes

Long Response Times

  • perplexity_large can take 10-30 minutes for complex queries

  • Use perplexity_small or perplexity_medium for faster responses

  • Consider the complexity of your query when choosing tools

Debug Mode

Enable verbose logging by running the server directly:

uv run python server.py
# Check stderr output for detailed logging information

Test Individual Components

# Test API connection
uv run python -c "from client import PerplexityClient; print('āœ… Client OK')"

# Test configuration
uv run python -c "from config import get_api_key; print('āœ… API Key OK')"

# Test server startup
timeout 10s uv run python server.py || echo "Server started successfully"

Contributing

  1. Fork the repository

  2. Create a feature branch: git checkout -b feature-name

  3. Make your changes and test thoroughly

  4. Update documentation as needed

  5. Submit a pull request

Development Guidelines

  • Follow existing code style (Black formatting, type hints)

  • Add tests for new functionality

  • Update CLAUDE.md for any architectural changes

  • Test with all three Perplexity models

  • Ensure MCP protocol compliance (clean stdout)

Architecture

Key Design Decisions

  • Class-based client: Singleton pattern for efficient resource management

  • Thinking token removal: Automatic filtering of <think>...</think> sections

  • Simplified responses: Only content and citations for clean integration

  • Error isolation: No exceptions propagated to MCP layer

  • Logging strategy: All debug output to stderr for MCP compliance

Dependencies

  • mcp>=1.11.0 - MCP Python SDK with FastMCP

  • python-dotenv>=1.1.1 - Environment variable management

  • httpx>=0.28.1 - Modern HTTP client with timeout handling

License

MIT License - see LICENSE file for details.

Acknowledgments

Support


Note: This MCP server is currently optimized for local development and personal use. Future versions may include PyPI distribution options for easier installation and sharing.

Available Tools

3 tools
perplexity_largeA
Comprehensive research with maximum depth using sonar-deep-research.

Best for: Deep research tasks, comprehensive analysis, complex multi-step reasoning,
academic research, detailed technical investigations.
Uses high reasoning effort and search context size.

WARNING: This tool may take significantly longer (potentially 10-30 minutes) 
and may timeout on very complex queries.

Args:
    query: The question or prompt to send to Perplexity
    messages: Optional conversation context (list of {"role": "user/assistant", "content": "..."})

Returns:
    Dictionary with content and citations
ParametersJSON Schema
NameRequiredDescriptionDefault
queryYes
messagesNo

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

A4.9/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It effectively describes key behavioral traits: the tool 'may take significantly longer (potentially 10-30 minutes) and may timeout on very complex queries,' uses 'high reasoning effort and search context size,' and returns 'Dictionary with content and citations.' This covers execution time, resource usage, and output format without contradictions.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is well-structured and front-loaded with the core purpose, followed by usage guidelines, behavioral warnings, and parameter explanations. Every sentence adds value: the first defines the tool, the second specifies use cases, the third details behavioral traits, and the last sections document parameters and returns. There is no wasted text.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (deep research with potential timeouts), no annotations, and an output schema present (which handles return values), the description is complete. It covers purpose, usage, behavioral transparency (including critical timeout warnings), and parameter semantics, providing all necessary context for an agent to use the tool effectively.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description must compensate. It adds meaningful context for both parameters: 'query: The question or prompt to send to Perplexity' and 'messages: Optional conversation context (list of {"role": "user/assistant", "content": "..."})'. This clarifies the purpose and format of each parameter beyond the bare schema, though it doesn't provide exhaustive details like message structure constraints.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool performs 'Comprehensive research with maximum depth using sonar-deep-research' and specifies it's for 'Deep research tasks, comprehensive analysis, complex multi-step reasoning, academic research, detailed technical investigations.' This provides a specific verb (research) with clear scope and distinguishes it from sibling tools (perplexity_medium, perplexity_small) by emphasizing maximum depth and comprehensive analysis.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description explicitly states 'Best for: Deep research tasks, comprehensive analysis, complex multi-step reasoning, academic research, detailed technical investigations' and includes a WARNING about longer execution times. This provides clear guidance on when to use this tool versus alternatives (implied to be the other perplexity tools for less intensive tasks) and when not to use it (time-sensitive queries).

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

perplexity_mediumA
Enhanced reasoning with moderate search depth using sonar-reasoning-pro.

Best for: Complex questions requiring analysis, moderate research depth, 
technical explanations with citations.
Uses medium reasoning effort and search context size.

Args:
    query: The question or prompt to send to Perplexity
    messages: Optional conversation context (list of {"role": "user/assistant", "content": "..."})

Returns:
    Dictionary with content and citations
ParametersJSON Schema
NameRequiredDescriptionDefault
queryYes
messagesNo

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

A4.1/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It describes the tool's reasoning approach ('enhanced reasoning'), search characteristics ('moderate search depth'), and mentions it returns citations. However, it doesn't disclose important behavioral aspects like rate limits, authentication requirements, error conditions, or what happens with the optional messages parameter.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is well-structured and efficiently organized with clear sections: purpose statement, 'Best for' guidelines, and parameter explanations. Every sentence adds value, and the information is front-loaded with the most important details first. No wasted words or redundant information.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool has an output schema (returns dictionary with content and citations), the description doesn't need to explain return values in detail. It covers the tool's purpose, usage guidelines, and parameter semantics adequately. However, for a reasoning/search tool with no annotations, it could provide more behavioral context about limitations, performance characteristics, or error handling.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

With 0% schema description coverage, the description must compensate for the lack of parameter documentation in the schema. It provides clear explanations for both parameters: 'query: The question or prompt to send to Perplexity' and 'messages: Optional conversation context (list of {"role": "user/assistant", "content": "..."})'. This adds substantial value beyond the bare schema, though it could provide more detail about message format expectations.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool performs 'enhanced reasoning with moderate search depth using sonar-reasoning-pro' and specifies it's for 'complex questions requiring analysis, moderate research depth, technical explanations with citations.' This provides a specific verb ('reasoning') and resource ('search'), though it doesn't explicitly differentiate from siblings beyond mentioning 'moderate' depth.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description includes an explicit 'Best for:' section that lists specific use cases (complex questions requiring analysis, moderate research depth, technical explanations with citations). While it doesn't explicitly say when NOT to use it or name alternatives, the context of having sibling tools (perplexity_large, perplexity_small) combined with the 'moderate' qualifier provides clear guidance on when this specific tool is appropriate.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

perplexity_smallA
Quick and reliable queries using Perplexity's sonar-pro model.

Best for: Fast factual questions, basic research, immediate answers.
Uses default parameters for optimal speed and cost-effectiveness.

Args:
    query: The question or prompt to send to Perplexity
    messages: Optional conversation context (list of {"role": "user/assistant", "content": "..."})

Returns:
    Dictionary with content and citations
ParametersJSON Schema
NameRequiredDescriptionDefault
queryYes
messagesNo

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

A4.1/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden. It discloses behavioral traits like 'quick and reliable,' 'fast factual questions,' and 'optimal speed and cost-effectiveness,' which adds context about performance and constraints. However, it lacks details on rate limits, error handling, or authentication needs, leaving some gaps in behavioral transparency.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is well-structured and appropriately sized. It front-loads the purpose and usage guidelines, followed by clear sections for Args and Returns. Every sentence adds value without redundancy, making it efficient and easy to parse.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity (a query tool with 2 parameters), no annotations, and an output schema exists (indicating returns a dictionary with content and citations), the description is mostly complete. It covers purpose, usage, parameters, and returns, but could benefit from more behavioral details like rate limits or error cases to be fully comprehensive.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description must compensate. It adds meaning beyond the schema by explaining 'query' as 'The question or prompt to send to Perplexity' and 'messages' as 'Optional conversation context (list of {"role": "user/assistant", "content": "..."})'. This provides clear semantics for both parameters, effectively compensating for the lack of schema descriptions.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Quick and reliable queries using Perplexity's sonar-pro model.' It specifies the action (queries) and resource (Perplexity's model), but doesn't explicitly differentiate from sibling tools (perplexity_large, perplexity_medium) beyond mentioning 'small' in the name and 'optimal speed and cost-effectiveness.'

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides explicit usage guidance: 'Best for: Fast factual questions, basic research, immediate answers.' It also mentions 'Uses default parameters for optimal speed and cost-effectiveness,' which helps distinguish it from alternatives. This clearly indicates when to use this tool versus potential siblings.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

TDQS

A4.5/5.0
Disambiguation5/5

The three tools are clearly distinguished by their intended use cases and performance characteristics: 'large' for deep research with maximum depth, 'medium' for enhanced reasoning with moderate depth, and 'small' for quick factual queries. Each tool's description explicitly outlines its best applications, reasoning effort, and expected response times, leaving no ambiguity about when to select which tool.

Naming Consistency5/5

All tool names follow a perfectly consistent pattern: 'perplexity_' prefix followed by a size descriptor ('large', 'medium', 'small'). This naming convention immediately communicates that these are variations of the same core functionality with different scales, making the tool set predictable and easy to understand.

Tool Count5/5

Three tools is an ideal number for this server's purpose: providing access to Perplexity's AI models at different capability levels. Each tool serves a distinct role in the research/query workflow, from quick lookups to comprehensive analysis, and no tool feels redundant or missing for the domain.

Completeness5/5

The tool set provides complete coverage for the server's domain of Perplexity AI queries. It offers a full spectrum of query capabilities from simple to complex, with clear guidance on when to use each tool. The consistent argument structure (query + optional messages) and return format ensure agents can work seamlessly across all tools without encountering dead ends or missing functionality.

Maintenance

ActivityInactive
ResponsivenessNo issues

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Connectors

Related MCP Servers

  • A
    license
    C
    quality
    F
    maintenance
    A custom MCP tool that integrates Perplexity AI's API with Claude Desktop, allowing Claude to perform web-based research and provide answers with citations.
    1
    6
    MIT
  • A
    license
    B
    quality
    D
    maintenance
    A powerful research assistant that integrates with Cline and Claude Desktop to leverage Perplexity AI for intelligent search, documentation retrieval, API discovery, and code modernization assistance while coding.
    4
    5
    MIT
  • A
    license
    Not graded
    quality
    D
    maintenance
    Provides AI-powered search, research, and reasoning capabilities through integration with Perplexity.ai, offering three specialized tools: general conversational AI, deep research with citations, and advanced reasoning.
    13
    2
    MIT
  • A
    license
    A
    quality
    F
    maintenance
    Connects Claude to Perplexity Comet's agentic browser for autonomous web browsing, deep research, and real-time task monitoring. Enables Claude to delegate web research tasks and receive comprehensive results through multiple browsing modes.
    6
    90
    167
    MIT

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Rohit-Seelam/Perplexity_MCP'

If you have feedback or need assistance with the MCP directory API, please join our Discord server