MCP server exposing Perplexity AI search, research, and reasoning tools
npm install perplexity-web-api-mcp
src="https://img.shields.io/npm/v/perplexity-web-api-mcp?style=for-the-badge&logo=npm&logoColor=white&color=CB3837"
alt="NPM Version" />
MCP (Model Context Protocol) server that exposes Perplexity AI search, research, and reasoning capabilities as tools.
This MCP server uses your Perplexity account session directly — no API key needed.
Perplexity offers a separate paid API with per-request pricing that is charged independently from your Pro subscription. With this MCP, you don't need to pay for API access — your existing Perplexity subscription (or even a free account) is enough.
Simply extract the session tokens from your browser cookies, and you're ready to use Perplexity search, research, and reasoning in your IDE.
- macOS
- Linux
- ~~Windows~~ (not supported yet)
- x86_64
- aarch64
This server requires a Perplexity AI account. You need to extract two authentication tokens from your browser cookies:
- PERPLEXITY_SESSION_TOKEN - The next-auth.session-token cookie value
- PERPLEXITY_CSRF_TOKEN - The next-auth.csrf-token cookie value
#### Getting Your Tokens
1. Log in to perplexity.ai in your browser
2. Open Developer Tools (F12 or right-click → Inspect)
3. Go to Application → Cookies → https://www.perplexity.ai
4. Copy the values of:
- next-auth.session-token → use as PERPLEXITY_SESSION_TOKEN
- next-auth.csrf-token → use as PERPLEXITY_CSRF_TOKEN
``bash`
claude mcp add perplexity --env PERPLEXITY_SESSION_TOKEN="your-session-token" --env PERPLEXITY_CSRF_TOKEN="your-csrf-token" -- npx -y perplexity-web-api-mcp
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_config.json
| Claude Desktop | |~/.codeium/windsurf/mcp_config.json
| Windsurf | |
`json`
{
"mcpServers": {
"perplexity": {
"command": "npx",
"args": ["-y", "perplexity-web-api-mcp"],
"env": {
"PERPLEXITY_SESSION_TOKEN": "your-session-token",
"PERPLEXITY_CSRF_TOKEN": "your-csrf-token"
}
}
}
}
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:
`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"
}
}
}
}
`bash`
codex mcp add perplexity --env PERPLEXITY_SESSION_TOKEN="your-session-token" --env PERPLEXITY_CSRF_TOKEN="your-csrf-token" -- npx -y perplexity-web-api-mcp
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.
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"
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
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
All tools return a JSON response with:
`json``
{
"answer": "The generated answer text...",
"web_results": [
{
"name": "Source name",
"url": "https://example.com",
"snippet": "Source snippet"
}
],
"follow_up": {
"backend_uuid": "uuid-for-follow-up-queries",
"attachments": []
}
}
MIT