使用说明
项目简介
本项目 'perplexity-tool' 是一个基于 Model Context Protocol (MCP) 的服务器实现,它将 Perplexity AI 的强大搜索功能集成为了一个 工具 (Tool),使得支持 MCP 协议的 LLM 客户端(如 Claude Desktop)能够调用 Perplexity AI 进行网络搜索和信息查询。通过此工具,LLM 可以扩展其知识库,获取最新的网络信息,并为用户提供更准确、更全面的答案,且答案可以附带来源引用。
主要功能点
- 联网搜索: 允许 LLM 客户端通过 Perplexity AI 访问和搜索互联网信息。
- 信息检索: 帮助 LLM 客户端检索特定主题或问题的信息,以增强其回答问题的能力。
- 引用支持: Perplexity AI 返回的搜索结果包含来源引用,工具可以将这些引用信息返回给 LLM 客户端,提高回答的可信度。
- 可配置参数: 支持设置搜索参数,如温度 (temperature)、最大token数 (max_tokens)、搜索领域过滤 (search_domain_filter) 和搜索时间范围过滤 (search_recency_filter) 等,以更精细地控制搜索行为。
安装步骤
- 安装 Git 和 Node.js: 请根据您的操作系统(Mac 或 Windows)按照 README.md 文件中的 "Prerequisites Installation" 章节指引安装 Git 和 Node.js。
- 克隆仓库: 打开终端或命令提示符,执行以下命令克隆仓库到本地:
git clone https://github.com/letsbuildagent/perplexity-tool cd perplexity-tool - 安装依赖: 在仓库目录下,执行以下命令安装项目依赖:
npm install - 配置 Perplexity API Key:
- 获取 API Key: 访问 Perplexity AI 开发者平台 获取您的 API Key。
- 配置 API Key: 您可以选择以下两种方式配置 API Key:
- 方式一 (快速配置): 编辑 'server.js' 文件,将 'const PERPLEXITY_API_KEY = "YOUR-API-KEY-HERE";' 这一行中的 '"YOUR-API-KEY-HERE"' 替换为您实际的 API Key。
- 方式二 (推荐配置):
- 在仓库根目录下创建 '.env' 文件。
- 在 '.env' 文件中添加一行: 'PERPLEXITY_API_KEY=您的API密钥' (将 '您的API密钥' 替换为您的实际 API Key)。
- 执行 'npm install dotenv' 安装 dotenv 依赖。
- 确保 'server.js' 文件中已包含 'import 'dotenv/config'' 这一行。
- 配置 Claude Desktop:
- 打开 Claude Desktop 的配置文件 'claude_desktop_config.json'。 该文件通常位于 '~/Library/Application Support/Claude/' (Mac) 或 '%APPDATA%/Claude/' (Windows) 目录下。
- 在 'claude_desktop_config.json' 文件中,找到 '"mcpServers"' 部分(如果不存在则创建),添加以下配置信息:
注意: 请将 '/path/to/perplexity-tool' 替换为您克隆的 'perplexity-tool' 仓库在您电脑上的完整路径。例如,如果您将仓库克隆到了 '/Users/yourusername/Documents/perplexity-tool',则应将 '/path/to/perplexity-tool' 替换为 '/Users/yourusername/Documents/perplexity-tool'。{ "mcpServers": { "perplexity-tool": { "command": "node", "args": [ "/path/to/perplexity-tool/server.js" // 将 "/path/to/perplexity-tool" 替换为您的仓库实际路径 ] } } }
- 重启 Claude Desktop: 完成配置后,重启 Claude Desktop 使配置生效。
基本使用方法
配置完成后,您可以在 Claude Desktop 中使用以下指令来调用 Perplexity Tool 进行搜索:
- 'Ask Perplexity about recent developments in AI' (让 Perplexity 搜索最近人工智能的发展)
- 'Use Perplexity to research the history of quantum computing' (使用 Perplexity 研究量子计算的历史)
- 'Search Perplexity for information about climate change, focusing on the last month' (使用 Perplexity 搜索关于气候变化的信息,重点关注最近一个月)
您还可以通过在指令中添加参数来控制搜索行为,例如:
- 'Ask Perplexity about recent developments in AI temperature 0.5' (设置温度参数为 0.5)
- 'Search Perplexity for information about climate change, focusing on the last month search_recency_filter week' (设置时间范围过滤为最近一周)
支持的参数: 'temperature', 'max_tokens', 'search_domain_filter', 'search_recency_filter'。 具体参数的含义和用法请参考 README.md 文件中的 "Advanced Options" 章节。
信息
分类
网页与API