Perplexity-MCP搜索服务
一个MCP服务器,使Claude能够通过Perplexity的API执行网络搜索,基于查询意图进行智能模型选择,并支持领域和时间过滤。
可用工具 (6 个)
该服务在 MCP 协议中暴露的工具,AI 可按需调用
search 1 个参数 需填 1 项
Search the web using Perplexity AI
必填参数:query
domain_filter 2 个参数 需填 2 项
Add a domain to allow or block in search results (max 3 domains per type)
必填参数:domain、action
recency_filter 1 个参数 需填 1 项
Set the time recency for search results
必填参数:filter
clear_filters
Clear all domain filters
该工具无需必填参数,直接调用即可
list_filters
List all current domain filters
该工具无需必填参数,直接调用即可
model_info 1 个参数
Get information about available models and optionally set a specific model
该工具无需必填参数,直接调用即可
服务介绍
Perplexity MCP 服务器
一个使用 Perplexity 的 API 提供网络搜索功能的 MCP 服务器,并根据查询意图自动选择模型。
先决条件
- Node.js (v14 或更高版本)
- 一个 Perplexity API 密钥(在 https://www.perplexity.ai/settings/api 获取)
- Claude 桌面应用程序
安装
通过 Git 安装
-
克隆此仓库:
git clone https://github.com/RossH121/perplexity-mcp.git cd perplexity-mcp -
安装依赖项:
npm install -
构建服务器:
npm run build
配置
-
从 https://www.perplexity.ai/settings/api 获取你的 Perplexity API 密钥
-
将服务器添加到 Claude 的配置文件
~/Library/Application Support/Claude/claude_desktop_config.json中:
{
"mcpServers": {
"perplexity-server": {
"command": "node",
"args": [
"/absolute/path/to/perplexity-mcp/build/index.js"
],
"env": {
"PERPLEXITY_API_KEY": "your-api-key-here",
"PERPLEXITY_MODEL": "sonar"
}
}
}
}
将 /absolute/path/to 替换为你克隆仓库的实际路径。
可用模型
该服务器现在支持基于查询意图的自动模型选择,但你也可以使用 PERPLEXITY_MODEL 环境变量指定默认模型。可用选项包括:
sonar-deep-research- 专为跨领域的广泛研究和专家级分析设计sonar-reasoning-pro- 优化用于高级逻辑推理和复杂问题解决sonar-reasoning- 适用于具有平衡性能的推理任务sonar-pro- 通用模型,具有出色的搜索能力和引用密度sonar- 快速高效,适用于直接查询
默认模型(在环境变量中指定)将作为自动模型选择的基础。
有关最新模型定价和可用性的信息,请访问:https://docs.perplexity.ai/guides/pricing
使用
在配置好服务器并重启 Claude 后,你可以简单地让 Claude 搜索信息。例如:
- "关于 SpaceX 的最新新闻是什么?"
- "搜索芝加哥最好的餐厅"
- "查找有关爵士乐历史的信息"
- "我需要对最近的人工智能发展进行深入研究分析"(使用 sonar-deep-research)
- "帮我解决这个复杂的问题"(使用 sonar-reasoning-pro)
Claude 将自动使用 Perplexity 搜索工具来查找并返回相关信息。服务器会根据你的查询意图自动选择最合适的模型。
如果出于某种原因它决定不使用搜索工具,你可以在提示前加上 "Search the web" 来强制执行。
智能模型选择
服务器会根据你的查询自动选择最合适的 Perplexity 模型:
- 使用诸如“深度研究”、“全面”或“深入”等研究导向的术语来触发 sonar-deep-research
- 使用诸如“解决”、“找出”或“复杂问题”等推理术语来触发 sonar-reasoning-pro
- 使用诸如“快速”、“简短”或“基本”等简单术语来触发轻量级 sonar 模型
- 一般的搜索词默认使用 sonar-pro 以获得平衡的性能
每个搜索响应都包括有关使用了哪个模型以及原因的信息。
域名过滤
该服务器支持域名过滤,以自定义您的搜索体验。您可以使用以下命令允许或阻止特定域名:
- 添加允许的域名: "Use the domain_filter tool to allow wikipedia.org"
- 添加阻止的域名: "Use the domain_filter tool to block pinterest.com"
- 查看当前过滤器: "Use the list_filters tool" (显示域名和时效性过滤器)
- 清除所有过滤器: "Use the clear_filters tool" (清除域名和时效性过滤器)
注意:Perplexity API 支持最多 3 个域名,并优先考虑允许的域名。域名过滤需要支持此功能的 Perplexity API 层级。
示例使用流程:
- "Use the domain_filter tool to allow wikipedia.org"
- "Use the domain_filter tool to allow arxiv.org"
- "Use the list_filters tool" (验证设置)
- "Search for quantum computing advances" (结果将优先考虑 wikipedia.org 和 arxiv.org)
时效性过滤
您可以使用时效性过滤器将搜索结果限制在特定的时间窗口内:
- 设置时效性过滤器: "Use the recency_filter tool with filter=hour" (选项: hour, day, week, month)
- 禁用时效性过滤器: "Use the recency_filter tool with filter=none"
这对于像当前事件或突发新闻这样对时间敏感的查询特别有用。
模型选择控制
虽然自动模型选择在大多数情况下工作得很好,但您可以手动控制使用哪个模型:
- 查看模型信息: "Use the model_info tool"
- 设置特定模型: "Use the model_info tool with model=sonar-deep-research"
- 返回自动选择: 将模型恢复为默认模型
示例使用:
- "Use the model_info tool" (查看可用模型和当前状态)
- "Use the model_info tool with model=sonar-reasoning-pro" (强制使用推理模型)
- "Search for a mathematical proof of the Pythagorean theorem" (将使用 sonar-reasoning-pro)
- "Use the model_info tool with model=sonar-pro" (返回自动选择)
开发
要修改服务器:
- 编辑
src/index.ts - 使用
npm run build重新构建 - 重启 Claude 以加载更改
许可证
MIT