Perplexity MCP Server

Perplexity MCP Server

Exposes Perplexity AI's search and synthesis capabilities through MCP, enabling Claude Desktop and other MCP clients to search the web, synthesize sources, and get cited answers.

Category
访问服务器

README

Perplexity MCP Server

Exposes Perplexity AI's search and synthesis capabilities through the Model Context Protocol (MCP), enabling Claude Desktop and other MCP clients to search the web, synthesize sources, and get cited answers.

Claude Desktop
    ↓ stdio
Perplexity MCP Server
    ├── perplexity_ask       → Ask a question, get answer + sources
    ├── perplexity_search    → In-depth web search
    ├── set_cookies          → Set Perplexity cookies (JSON / Netscape format)
    ├── list_models          → List available models
    └── reset_conversation   → Reset conversation context
    ↓
PerplexityClient (curl_cffi → Chrome impersonation → Cloudflare bypass)
    ↓
Perplexity.ai internal API (SSE)

Installation

pip install -r requirements.txt

Requires Python 3.10+. Only two dependencies:

  • curl_cffi — TLS fingerprint impersonation (Chrome 120)
  • mcp — Model Context Protocol SDK

Getting Cookies

This MCP server uses Perplexity's internal API, which requires valid session cookies. Choose one of the following methods:

Method 1: Browser Export (Recommended)

  1. Log in to Perplexity.ai in Chrome
  2. Open DevTools → Application → Cookies → www.perplexity.ai
  3. Export all cookies as JSON
  4. Save to cookies/perplexity_cookies.json

Method 2: Playwright (Automated)

pip install playwright
playwright install chromium
python get_cookies.py
# Browser opens → log in to Perplexity → press Enter in terminal

For headless mode: python get_cookies.py --headless

Method 3: Netscape Format

Export cookies from any browser in Netscape format and save to cookies/perplexity_cookies.txt. The server reads them automatically.

Method 4: Environment Variable

export PERPLEXITY_COOKIES_JSON='{"cookie_name": "value", ...}'

Method 5: MCP Tool (Runtime)

If you already have cookie values (e.g., from another AI agent), use the set_cookies tool at runtime. It accepts both JSON and Netscape formats:

{
  "cookies_data": "{\"__Secure-next-auth.session-token\": \"...\", \"cf_clearance\": \"...\"}"
}

or Netscape format:

{
  "cookies_data": ".perplexity.ai\ttrue\t/\ttrue\t1787873851\tcookie_name\tcookie_value"
}

This is especially useful when an AI agent possesses cookie values and needs to configure the MCP server without filesystem access.

Usage

Claude Desktop

Add to your claude_desktop_config.json:

{
  "mcpServers": {
    "perplexity": {
      "command": "python",
      "args": ["C:/full/path/to/mcp_server.py"]
    }
  }
}

Cursor / VS Code

Add to .cursor/mcp.json or VS Code MCP settings:

{
  "mcpServers": {
    "perplexity": {
      "command": "python",
      "args": ["C:/full/path/to/mcp_server.py"]
    }
  }
}

Direct Testing

# Start the MCP server
python mcp_server.py

# In another terminal, test with MCP Inspector
npx @modelcontextprotocol/inspector python mcp_server.py

Tools

perplexity_ask

Ask a question. Perplexity searches the web and returns a cited answer.

Parameter Type Default Description
message string required Question or topic
model string "auto" Model: gpt-4o, claude-4.5-sonnet, o3-mini, deepseek-r1, ...
search_focus enum "internet" "internet" or "writing"
sources string[] ["web"] Sources: web, scholar, social, edgar

perplexity_search

In-depth web search. An alias for perplexity_ask with different default parameters focused on search.

Parameter Type Default Description
query string required Search query
search_focus enum "internet" "internet" or "writing"
sources string[] ["web"] Source types: web, scholar, social, edgar
model string "auto" Model preference

set_cookies

Set Perplexity cookies at runtime via MCP. Accepts JSON objects or Netscape-format cookie strings.

Parameter Type Default Description
cookies_data string required Cookie data — JSON ({"name":"value"}) or Netscape format (tab-separated)
session_id string "default" Session ID

list_models

Lists all available models with their Perplexity internal IDs and use-case descriptions.

reset_conversation

Resets conversation history and starts a fresh context.

Parameter Type Default Description
session_id string "default" Session ID

Supported Models

Name Perplexity ID Use Case
gpt-5 gpt5 Balanced, general purpose
gpt-5-thinking gpt5_thinking Complex reasoning, broad sources (~28)
gpt-4o gpt4o Multimodal
gpt-4.5 gpt45 General purpose
o3 o3 Advanced reasoning, math
o3-pro o3pro Highest reasoning
o3-mini o3mini Fast reasoning, code
o4-mini o4mini Broad sources (~28), balanced
o1 o1 Step-by-step reasoning
claude-4.5-sonnet claude45sonnet Detailed analysis, coding
claude-4.5-sonnet-thinking claude45sonnetthinking Complex reasoning
claude-4-opus claude40opus Security-focused
claude-4.1-opus claude41opusthinking Latest Opus, advanced reasoning
grok-4 grok4 Latest news, breaking stories
gemini-2.5-pro gemini30pro Multimodal, 1M+ token context
deepseek-r1 r1 Price/performance, open source
sonar-pro pplx_pro Fast, concise answers
sonar-deep-research o3pro_research Deep research
perplexity-reasoning pplx_reasoning Balanced, efficient

Full details: call the list_models tool.

Notes

  • Cookie expiry: Cookies expire over time. If Perplexity logs you out or returns errors, re-export fresh cookies.
  • Guest mode: The server works without cookies but will fall back to the turbo model only. Authentication significantly expands model availability.
  • Multi-turn conversations: Supported via session_id. Context is maintained server-side through backend_uuid, read_write_token, and thread_url_slug.
  • Reasoning models: Models like deepseek-r1, o3, gpt-5-thinking, claude-4.5-sonnet-thinking emit a separate reasoning/thinking stream that is prepended to the response.
  • Security: Cookie files in cookies/ are gitignored by default. Never commit live credentials to version control.

推荐服务器

Baidu Map

Baidu Map

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

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

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

官方
精选
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

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

官方
精选
本地
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

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

官方
精选
本地
TypeScript
VeyraX

VeyraX

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

官方
精选
本地
Kagi MCP Server

Kagi MCP Server

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

官方
精选
Python
graphlit-mcp-server

graphlit-mcp-server

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

官方
精选
TypeScript
mcp-server-qdrant

mcp-server-qdrant

这个仓库展示了如何为向量搜索引擎 Qdrant 创建一个 MCP (Managed Control Plane) 服务器的示例。

官方
精选
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

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

官方
精选