Perplexity MCP Server
Integrates Perplexity AI's search and research capabilities into Claude Code, enabling web-grounded answers, deep research, code review, and more with real-time citations.
README
Perplexity MCP Server
MCP server that brings Perplexity to Claude Code — AI-powered web search, deep research, reasoning, brainstorming, code review, explanations, and file analysis. All with real-time web grounding and citations. Supports Sonar, Sonar Pro, Sonar Reasoning Pro, and Sonar Deep Research models.
Quick Start
Step 1: Get Your API Key
- Go to Perplexity API Settings
- Create an account or sign in
- Generate an API key
- Copy the key (you'll need it in Step 3)
Step 2: Install Prerequisites
- Node.js 18+ - Download here
- Claude Code CLI - Installation guide
Step 3: Install the MCP Server
3.1 Clone the repository
git clone https://github.com/wynandw87/claude-code-perplexity-mcp.git
cd claude-code-perplexity-mcp
3.2 Install dependencies
macOS / Linux / Windows:
npm install
Note: Dependencies are installed and the server is built automatically in one step.
3.3 Register with Claude Code
Choose your install scope:
| Scope | Flag | Who can use it |
|---|---|---|
| User (recommended) | -s user |
You, in any project |
| Project | -s project |
Anyone who clones this repo |
| Local | -s local |
Only in current directory |
Replace YOUR_API_KEY with your actual Perplexity API key, and use the full path to dist/index.js.
Tip: To get the full path, run this from the cloned directory:
- macOS/Linux:
echo "$(pwd)/dist/index.js"- Windows:
echo %cd%\dist\index.js
macOS / Linux:
claude mcp add -s user Perplexity -e PERPLEXITY_API_KEY=YOUR_API_KEY -- node /full/path/to/dist/index.js
Windows (CMD):
claude mcp add -s user Perplexity -e "PERPLEXITY_API_KEY=YOUR_API_KEY" -- node "C:\full\path\to\dist\index.js"
Windows (PowerShell):
claude mcp add -s user Perplexity -e "PERPLEXITY_API_KEY=YOUR_API_KEY" '--' node "C:\full\path\to\dist\index.js"
Alternative: Use Setup Scripts
The setup scripts handle dependency installation, building, and registration automatically.
macOS / Linux:
chmod +x setup.sh
./setup.sh YOUR_API_KEY
Windows (PowerShell):
.\setup.ps1 -ApiKey YOUR_API_KEY
Or use the npm helper (if API key is set in environment):
export PERPLEXITY_API_KEY=YOUR_API_KEY
npm run install:claude
Step 4: Restart Claude Code
Close and reopen Claude Code for the changes to take effect.
Step 5: Verify Installation
claude mcp list
You should see Perplexity listed with a Connected status.
Features
Search & Research
- Web Search (
search_web) - AI-powered web search with domain filtering, recency filtering, and detailed citations - Deep Research (
deep_research) - Exhaustive multi-step research using sonar-deep-research - Reasoning + Search (
search_with_reasoning) - Step-by-step reasoning combined with live web search - Raw Search (
search) - Ranked search results with titles, URLs, and snippets
Text & Analysis
- General Queries (
ask) - Web-grounded Q&A with automatic citations - Brainstorming (
brainstorm) - Creative ideation informed by real-time web data - Code Review (
code_review) - Code analysis with web-grounded best practices - Explanations (
explain) - Clear concept explanations with web-grounded accuracy
Files
- File Upload (
upload_file) - Upload documents and images for analysis (text files, images)
Usage
Once installed, use trigger phrases to invoke Perplexity:
| Trigger | Tool | Example |
|---|---|---|
use perplexity, ask perplexity |
Ask | "ask perplexity about quantum computing" |
perplexity search, perplexity web search |
Web Search | "perplexity search: latest React 19 features" |
perplexity research, perplexity deep research |
Deep Research | "perplexity deep research on Rust vs Go for microservices" |
perplexity reason, perplexity think |
Reasoning | "perplexity reason about RSC vs traditional SSR performance" |
perplexity raw search, perplexity search results |
Raw Search | "perplexity raw search for MCP server TypeScript examples" |
perplexity review, have perplexity review |
Code Review | "perplexity review this function for security" |
perplexity brainstorm, perplexity ideas |
Brainstorm | "perplexity brainstorm ideas for authentication" |
perplexity explain |
Explain | "perplexity explain how WebSockets work" |
perplexity upload file |
Upload File | "perplexity upload ./report.py and review it" |
Or ask naturally:
- "Ask Perplexity what the latest best practices are for Next.js"
- "Have Perplexity review this code for security issues"
- "Brainstorm with Perplexity about scaling strategies"
- "Perplexity search the web for the latest news on AI"
- "Do a deep research with Perplexity on the state of WebAssembly"
- "Perplexity reason through the tradeoffs of microservices vs monolith"
- "Upload this CSV to Perplexity and ask it to summarize the data"
Tool Reference
ask
Query Perplexity with web-grounded answers and citations.
Parameters:
prompt(string, required) - The question or instructionmodel(string, optional) - Model identifier (defaults tosonar-pro)search(boolean, optional) - Enable web search grounding (default:true)
search_web
Search the web with domain and recency filtering. Best-in-class AI search.
Parameters:
query(string, required) - The search query or questionallowed_domains(string[], optional) - Only include results from these domains (max 5)excluded_domains(string[], optional) - Exclude these domains from search (max 5)recency(string, optional) -"hour","day","week","month"detail(string, optional) - Search depth:"low","medium","high"
deep_research
Conduct exhaustive, multi-step research on a topic. May take 30-60+ seconds.
Parameters:
query(string, required) - The research question or topic to investigate
search_with_reasoning
Step-by-step reasoning combined with live web search.
Parameters:
prompt(string, required) - The question or problem requiring deep reasoningallowed_domains(string[], optional) - Only include results from these domains (max 5)recency(string, optional) -"hour","day","week","month"
search
Get raw ranked search results without AI synthesis.
Parameters:
query(string, required) - The search querymax_results(integer, optional) - Number of results (1-50, default: 10)domain_filter(string[], optional) - Filter to these domains only (max 5)recency(string, optional) -"hour","day","week","month"
code_review
Code review with web-grounded current best practices.
Parameters:
code(string, required) - The code to reviewfocus(string, optional) - Specific focus area (e.g., "security", "performance")
brainstorm
Brainstorming informed by real-time web data and current trends.
Parameters:
topic(string, required) - The subject to brainstorm aboutcontext(string, optional) - Additional context
explain
Clear explanations with web-grounded accuracy.
Parameters:
concept(string, required) - What to explain
upload_file
Upload a document or image for analysis.
Parameters:
file_path(string, required) - Absolute path to the file to uploadquery(string, optional) - Question to ask about the file immediately after uploadmodel(string, optional) - Model identifier (defaults tosonar-pro)
Supports text files (.txt, .md, .py, .js, .ts, .csv, .json, etc.) and images (.png, .jpg, .gif, .webp).
Supported Models
| Model | Best For |
|---|---|
sonar |
Quick queries, summaries — fast and cost-effective |
sonar-pro |
Default — complex queries, citations, multi-step reasoning |
sonar-reasoning-pro |
Multi-step reasoning with live web search |
sonar-deep-research |
Exhaustive research, comprehensive reports |
All models have 128K context windows and real-time web grounding.
Configuration
Environment Variables
| Variable | Required | Default | Description |
|---|---|---|---|
PERPLEXITY_API_KEY |
Yes | — | Perplexity API key |
PERPLEXITY_DEFAULT_MODEL |
No | sonar-pro |
Default model for text tools |
PERPLEXITY_TIMEOUT |
No | 60000 |
API timeout in ms |
How It Works
This MCP server uses the Perplexity REST API directly (Chat Completions and Search endpoints) with native fetch. No SDK dependency — just @modelcontextprotocol/sdk and zod. It connects to Claude Code via stdio transport.
Tools provided:
| Tool | API | Default Model |
|---|---|---|
ask |
Chat Completions | Configurable (sonar-pro) |
search_web |
Chat Completions + domain/recency filters | sonar-pro |
deep_research |
Chat Completions | sonar-deep-research |
search_with_reasoning |
Chat Completions | sonar-reasoning-pro |
search |
Search API | — |
code_review |
Chat Completions | sonar-pro |
brainstorm |
Chat Completions | sonar-pro |
explain |
Chat Completions | sonar |
upload_file |
Chat Completions (inline/vision) | Configurable (sonar-pro) |
Troubleshooting
Fix API Key
If you entered the wrong API key, remove and reinstall:
claude mcp remove Perplexity
Then reinstall using the command from Step 3.3 above (use the same scope you originally installed with).
MCP Server Not Showing Up
Check if the server is installed:
claude mcp list
If not listed, follow Step 3 to install it.
Server Won't Start
-
Verify your API key is valid at Perplexity API Settings
-
Check Node.js version (needs 18+):
node --version -
Ensure the server was built — if
dist/index.jsis missing, runnpm installagain
Connection Errors
- Check that
dist/index.jsexists — if not, runnpm install - Verify the path is absolute in your
claude mcp addcommand - Restart Claude Code after any configuration changes
Timeout Errors
- Deep research uses 5x base timeout — it's expected to take longer
- Reasoning and search tools use 3x base timeout
- Increase
PERPLEXITY_TIMEOUTenvironment variable for slow connections
Deep Research Takes Too Long
sonar-deep-research can take 30-60+ seconds for comprehensive research. This is normal — it's doing multi-step investigation across many sources.
View Current Configuration
claude mcp list
Contributing
Pull requests welcome! Please keep it simple and beginner-friendly.
License
MIT
Made for the Claude Code community
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。