Perplexity Web 搜索 MCP 服务器
一个简单的 MCP(模型上下文协议)服务器,使用 Perplexity API 提供网页搜索功能。该服务器允许 Claude 或其他兼容 MCP 的 AI 助手搜索网页并获取最新信息。
特征
- 使用 Perplexity 强大的搜索功能搜索网络
- 获得包含来源和引文的全面搜索结果
- 按时间段(日、周、月、年)过滤结果
- 包含一个可立即使用的网页搜索提示模板
- 支持从环境变量或.env 文件加载 API 密钥
安装
- 克隆此存储库
- 安装依赖项:或者
配置
您可以使用 Perplexity API 密钥设置PERPLEXITY_API_KEY
环境变量:
或者,您可以在项目根目录中创建一个包含以下内容的.env
文件:
提供了一个示例.env.example
文件以供参考。
获取 Perplexity API 密钥:
- 访问Perplexity API 设置
- 如果您没有帐户,请创建一个
- 生成 API 密钥
用法
运行服务器
测试服务器
您可以使用附带的测试脚本来测试服务器功能,而无需运行完整的 MCP 服务器:
--recency
的选项有:天、周、月(默认)、年
与 Claude Desktop 一起使用
- 编辑您的 Claude Desktop 配置文件:
- 在 macOS 上:
~/Library/Application\ Support/Claude/claude_desktop_config.json
- 在 Windows 上:
%APPDATA%/Claude/claude_desktop_config.json
- 在 macOS 上:
- 添加以下配置:
- 重启Claude桌面
克劳德的示例提示
- “在网上搜索有关人工智能的最新消息”
- “使用 Perplexity 查找过去一周发布的有关气候变化的信息”
- “搜索过去一个月有关量子计算的最新研究论文”
API 参考
工具: search_web(query: str, recency: str = "month") -> str
使用 Perplexity API 搜索网络并返回结果。
参数:
query
:搜索查询字符串recency
:按时间段过滤结果 - “天”、“周”、“月”(默认)或“年”
**返回:**包含以下内容的综合文本响应:
- 搜索结果的详细摘要
- 发现的关键事实和信息
- 带有 URL 的来源以供验证
- 任何有冲突的信息(如有)
提示: web_search_prompt(query: str, recency: str = "month") -> str
创建使用 Perplexity 搜索网络的提示模板。
参数:
query
:搜索查询recency
:时间段过滤器 - ‘天’、‘周’、‘月’(默认)或‘年’
**返回:**格式化的提示字符串,指示 AI 执行以下操作:
- 搜索指定查询
- 关注特定时间段内的结果
- 总结主要发现
- 突出重要事实
- 提及相互矛盾的信息
- 引用来源并附链接
执照
麻省理工学院
Related MCP Servers
- 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
- AsecurityFlicenseAqualityThis server provides access to the Perplexity AI API, enabling interaction through chatting, searching, and documentation retrieval within MCP-based systems.Last updated -52JavaScript
- AsecurityFlicenseAqualityProvides a standardized way to integrate Perplexity AI's features like chat, search, and documentation access into MCP-based systems.Last updated -5JavaScript
- AsecurityAlicenseAqualityA custom MCP tool that integrates Perplexity AI's API with Claude Desktop, allowing Claude to perform web-based research and provide answers with citations.Last updated -12JavaScriptMIT License