mishamyrt/perplexity-web-api-mcp
GitHub: mishamyrt/perplexity-web-api-mcp
一个无需 API 密钥即可在 IDE 中使用 Perplexity AI 搜索、研究和推理能力的 MCP 服务器。
Stars: 20 | Forks: 6
# Perplexity Web API MCP 服务器
MCP (Model Context Protocol) server,将 Perplexity AI 搜索、研究和推理能力作为工具暴露出来。
## 无需 API Key
此 MCP server 直接使用您的 Perplexity 账户会话 —— **无需 API key**。
Perplexity 提供单独的[付费 API](https://docs.perplexity.ai/guides/pricing),按请求计费,且与您的 Pro 订阅分开收费。使用此 MCP,您无需支付 API 访问费用 —— 您现有的 Perplexity 订阅(甚至是免费账户)就足够了。
只需从浏览器 cookies 中提取会话 tokens,即可在您的 IDE 中使用 Perplexity 搜索、研究和推理功能。
## 无 Token 模式
此 server 可以在**没有任何认证 tokens** 的情况下运行。在此模式下:
- 仅 `perplexity_search` 可用 —— `perplexity_research` 和 `perplexity_reason` 需要 tokens。
- 搜索模型固定为 `turbo`;无法设置 `PERPLEXITY_SEARCH_MODEL` 和 `PERPLEXITY_REASON_MODEL`(如果设置,server 将抛出错误)。
要使用无 token 模式,只需在配置中省略 `PERPLEXITY_SESSION_TOKEN` 和 `PERPLEXITY_CSRF_TOKEN`。
要完全访问所有工具并选择模型,请按照下方[配置](#configuration)部分的说明提供这两个 tokens。
## 需求
### 支持的平台
- macOS (arm64, x86_64)
- Linux (x86_64, aarch64)
- Windows (x86_64)
## 配置
### 获取您的 Tokens
此 server 需要 Perplexity AI 账户。您需要从浏览器 cookies 中提取两个认证 tokens:
1. 在浏览器中登录 [perplexity.ai](https://www.perplexity.ai)
2. 打开开发者工具(F12 或右键点击 → 检查)
3. 进入 Application → Cookies → `https://www.perplexity.ai`
4. 复制以下值:
- `__Secure-next-auth.session-token` → 用作 `PERPLEXITY_SESSION_TOKEN`
- `next-auth.csrf-token` → 用作 `PERPLEXITY_CSRF_TOKEN`
### 环境变量
- `PERPLEXITY_SESSION_TOKEN`(可选):Perplexity session token(`next-auth.session-token` cookie)。`perplexity_research` 和 `perplexity_reason` 必需。
- `PERPLEXITY_CSRF_TOKEN`(可选):Perplexity CSRF token(`next-auth.csrf-token` cookie)。`perplexity_research` 和 `perplexity_reason` 必需。
- `PERPLEXITY_SEARCH_MODEL`(可选,需要 tokens):`perplexity_search` 的模型。
有效值:
- `turbo`(默认)
- `sonar`
- `gemini-3-flash`
- `gpt-5.2`
- `claude-4.6-sonnet`
- `grok-4.1`
- `PERPLEXITY_REASON_MODEL`(可选,需要 tokens):`perplexity_reason` 的模型。
有效值:
- `sonar-reasoning`(默认)
- `gemini-3-flash-thinking`
- `gemini-3.1-pro`
- `gpt-5.2-thinking`
- `claude-4.6-sonnet-thinking`
- `grok-4.1-reasoning`
- `kimi-k2.5-thinking`
### 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-mcp
```
### Cursor、Claude Desktop 和 Windsurf
对于 Cursor,我建议使用本 README 顶部的一键安装徽章。
对于手动设置,所有这些客户端都使用相同的 `mcpServers` 格式:
| 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"
}
}
}
}
```
### Zed
将以下内容添加到您的[设置文件](https://zed.dev/docs/configuring-zed.html#settings-files)的 `context_servers` 中:
```
{
"context_servers": {
"perplexity": {
"command": "npx",
"args": ["-y", "perplexity-web-api-mcp"],
"env": {
"PERPLEXITY_SESSION_TOKEN": "your-session-token",
"PERPLEXITY_CSRF_TOKEN": "your-csrf-token"
}
}
}
}
```
### VS Code
对于 VS Code,我建议使用本 README 顶部的一键安装徽章,或者手动设置添加到 `.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-mcp
```
### 其他 MCP Clients
大多数客户端都可以在其配置文件中手动配置使用 `mcpServers` 包装器(如 Cursor)。如果您的客户端无法工作,请查看其文档以获取正确的包装器格式。
## 可用工具
### `perplexity_search`
使用非推理模型进行快速网页搜索。默认使用 Perplexity 的 turbo 模型(`turbo`),但可以通过 `PERPLEXITY_SEARCH_MODEL` 配置。
**最适合:** 快速问题、日常搜索以及受益于网页上下文的对话式查询。
**参数:**
- `query`(必需):搜索查询或问题
- `sources`(可选):来源数组 - `"web"`、`"scholar"`、`"social"`。默认为 `["web"]`
- `language`(可选):语言代码,例如 `"en-US"`。默认为 `"en-US"`
### `perplexity_reason`
高级推理和问题解决。默认使用 Perplexity 的 `sonar-reasoning` 模型,但可以通过 `PERPLEXITY_REASON_MODEL` 配置。
**最适合:** 逻辑问题、复杂分析、决策制定以及需要逐步推理的任务。
**参数:** 与 `perplexity_search` 相同。
### `perplexity_research`
使用 Perplexity 的 sonar-deep-research(`pplx_alpha`)模型进行深入、全面的研究。
**最适合:** 需要详细调查的复杂主题、全面报告和深入分析。提供带引用的详尽分析。
**参数:** 与 `perplexity_search` 相同。
## 响应格式
所有工具返回包含以下内容的 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
标签:AI搜索, Cookie利用, CSRF Token, Cursor 集成, DNS解析, MCP Server, MITM代理, Model Context Protocol, NPM 包, Perplexity AI, SOC Prime, Tokenless, TypeScript, VS Code 扩展, 云资产清单, 人工智能, 会话劫持, 免费使用, 大模型工具, 安全插件, 开发工具, 开源项目, 无API密钥, 浏览器自动化, 用户模式Hook绕过, 绕过付费, 逆向工程, 通知系统