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
访问服务器

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

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选