perplexity-web-api-mcp
v0.2.1
Published
MCP server exposing Perplexity AI search, research, and reasoning tools
Readme
Perplexity Web API MCP Server
MCP (Model Context Protocol) server that exposes Perplexity AI search, research, and reasoning capabilities as tools.
Requirements
Supported Platforms
- macOS
- Linux
- ~~Windows~~ (not supported yet)
Supported Architectures
- x86_64
- aarch64
Configuration
User Tokens
This server requires a Perplexity AI account. You need to extract two authentication tokens from your browser cookies:
PERPLEXITY_SESSION_TOKEN- Thenext-auth.session-tokencookie valuePERPLEXITY_CSRF_TOKEN- Thenext-auth.csrf-tokencookie value
Getting Your Tokens
- Log in to perplexity.ai in your browser
- Open Developer Tools (F12 or right-click → Inspect)
- Go to Application → Cookies →
https://www.perplexity.ai - Copy the values of:
next-auth.session-token→ use asPERPLEXITY_SESSION_TOKENnext-auth.csrf-token→ use asPERPLEXITY_CSRF_TOKEN
Claude Code
claude mcp add perplexity --env PERPLEXITY_SESSION_TOKEN="your-session-token" --env PERPLEXITY_CSRF_TOKEN="your-csrf-token" -- npx -y perplexity-web-api-mcpCursor, Claude Desktop & Windsurf
I recommend using the one-click install badge at the top of this README for Cursor.
For manual setup, all these clients use the same mcpServers format:
| Client | Config File |
|--------|-------------|
| Cursor | ~/.cursor/mcp.json |
| Claude Desktop | claude_desktop_config.json |
| Windsurf | ~/.codeium/windsurf/mcp_config.json |
{
"mcpServers": {
"perplexity": {
"command": "npx",
"args": ["-y", "perplexity-web-api-mcp"],
"env": {
"PERPLEXITY_SESSION_TOKEN": "your-session-token",
"PERPLEXITY_CSRF_TOKEN": "your-csrf-token"
}
}
}
}VS Code
I recommend using the one-click install badge at the top of this README for VS Code, or for manual setup, add to .vscode/mcp.json:
{
"servers": {
"perplexity": {
"type": "stdio",
"command": "npx",
"args": ["-y", "perplexity-web-api-mcp"],
"env": {
"PERPLEXITY_SESSION_TOKEN": "your-session-token",
"PERPLEXITY_CSRF_TOKEN": "your-csrf-token"
}
}
}
}Codex
codex mcp add perplexity --env PERPLEXITY_SESSION_TOKEN="your-session-token" --env PERPLEXITY_CSRF_TOKEN="your-csrf-token" -- npx -y perplexity-web-api-mcpOther MCP Clients
Most clients can be manually configured to use the mcpServers wrapper in their configuration file (like Cursor). If your client doesn't work, check its documentation for the correct wrapper format.
Available Tools
perplexity_search
Quick web search using Perplexity's turbo model.
Best for: Quick questions, everyday searches, and conversational queries that benefit from web context.
Parameters:
query(required): The search query or questionsources(optional): Array of sources -"web","scholar","social". Defaults to["web"]language(optional): Language code, e.g.,"en-US". Defaults to"en-US"
perplexity_research
Deep, comprehensive research using Perplexity's sonar-deep-research (pplx_alpha) model.
Best for: Complex topics requiring detailed investigation, comprehensive reports, and in-depth analysis. Provides thorough analysis with citations.
Parameters: Same as perplexity_search
perplexity_reason
Advanced reasoning and problem-solving using Perplexity's sonar-reasoning-pro (pplx_reasoning) model.
Best for: Logical problems, complex analysis, decision-making, and tasks requiring step-by-step reasoning.
Parameters: Same as perplexity_search
Response Format
All tools return a JSON response with:
{
"answer": "The generated answer text...",
"chunks": [
// Citation/source chunks from Perplexity
],
"follow_up": {
"backend_uuid": "uuid-for-follow-up-queries",
"attachments": []
}
}License
MIT
