Provides web search capabilities using Perplexity's API with automatic model selection based on query intent, supporting various Perplexity models like sonar, sonar-pro, sonar-reasoning, sonar-reasoning-pro, and sonar-deep-research
Perplexity MCP 服务器
MCP 服务器使用 Perplexity 的 API 提供网络搜索功能,并根据查询意图自动选择模型。
先决条件
- Node.js(v14 或更高版本)
- Perplexity API 密钥(在https://www.perplexity.ai/settings/api获取)
- 克劳德桌面应用程序
安装
通过 Git 安装
- 克隆此存储库:
- 安装依赖项:
- 构建服务器:
配置
- 从https://www.perplexity.ai/settings/api获取您的 Perplexity API 密钥
- 将服务器添加到 Claude 的配置文件中,地址为
~/Library/Application Support/Claude/claude_desktop_config.json
:
将/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 搜索工具查找并返回相关信息。服务器会根据你的查询意图自动选择最合适的模型。
如果出于某种原因它决定不使用搜索工具,您可以通过在提示前加上“搜索网络”来强制解决问题。
智能模型选择
服务器会根据您的查询自动选择最合适的 Perplexity 模型:
- 使用“深入研究”、“全面”或“深入”等研究导向的术语来触发声纳深入研究
- 使用“解决”、“弄清楚”或“复杂问题”等推理术语来触发 sonar-reasoning-pro
- 使用“快速”、“简短”或“基本”等简单术语来触发轻量级声纳模型
- 为了实现平衡的性能,一般搜索词默认使用 sonar-pro
每个搜索响应都包含有关使用哪种模型以及原因的信息。
域名过滤
此服务器支持域名过滤,方便您定制搜索体验。您可以使用以下命令允许或屏蔽特定域名:
- 添加允许的域:“使用 domain_filter 工具允许 wikipedia.org”
- 添加被阻止的域名:“使用 domain_filter 工具阻止 pinterest.com”
- 查看当前过滤器:“使用 list_filters 工具”(显示域和新近度过滤器)
- 清除所有过滤器:“使用 clear_filters 工具”(清除域和新近度过滤器)
注意:Perplexity API 最多支持 3 个域名,并会优先处理允许的域名。域名过滤功能需要支持此功能的 Perplexity API 层级。
使用流程示例:
- “使用 domain_filter 工具允许 wikipedia.org”
- “使用 domain_filter 工具允许 arxiv.org”
- “使用 list_filters 工具”(验证您的设置)
- “搜索量子计算进展”(结果将优先考虑 wikipedia.org 和 arxiv.org)
最近过滤
您可以使用最近过滤器将搜索结果限制在特定的时间范围内:
- 设置最近过滤器:“使用带有过滤器=小时的 recency_filter 工具”(选项:小时、天、周、月)
- 禁用最近过滤器:“使用带有 filter=none 的 recency_filter 工具”
这对于时事或突发新闻等时间敏感的查询特别有用。
模型选择控制
虽然自动模型选择在大多数情况下都能很好地发挥作用,但您可以手动控制使用哪种模型:
- 查看模型信息:“使用model_info工具”
- 设置特定模型:“使用 model_info 工具和 model=sonar-deep-research”
- 恢复自动选择:将模型设置回默认模型
使用示例:
- “使用 model_info 工具”(查看可用模型和当前状态)
- “使用 model_info 工具和 model=sonar-reasoning-pro”(强制使用推理模型)
- “寻找勾股定理的数学证明”(将使用 sonar-reasoning-pro)
- “使用 model_info 工具和 model=sonar-pro”(返回自动选择)
发展
修改服务器:
- 编辑
src/index.ts
- 使用
npm run build
重建 - 重新启动 Claude 以加载更改
执照
麻省理工学院
You must be authenticated.
remote-capable server
The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.
MCP 服务器使 Claude 能够使用 Perplexity 的 API 执行网络搜索,并根据查询意图进行智能模型选择,并支持域和新近度过滤。
Related Resources
Related MCP Servers
- AsecurityAlicenseAqualityA server facilitating web search functionality by utilizing Perplexity AI's API, designed to integrate with the Claude desktop client for enhanced search queries.Last updated -194PythonMIT License
- AsecurityAlicenseAqualityFacilitates web search capabilities using Perplexity's API, allowing users to retrieve search results through Claude's interface.Last updated -12JavaScriptMIT License
- AsecurityAlicenseAqualityAn MCP server integrating Perplexity AI's API to offer advanced search capabilities with support for multiple models and result configuration.Last updated -11JavaScriptMIT License
- -securityFlicense-qualityAllows Claude or other MCP-compatible AI assistants to search the web and get up-to-date information using the Perplexity API, with features for filtering results by time period.Last updated -8Python