Back to MCP directory
publicPublicdnsLocal runtime

Perplexity Research

基于Perplexity AI的互联网研究服务

article

README

🚀 研究MCP

研究MCP是一个通过Perplexity AI实现互联网研究服务的模型完成协议(MCP),它能让用户借助该协议获取各种主题的深入且最新信息,为研究工作提供有力支持。

🚀 快速开始

研究MCP是一个提供互联网研究功能的服务,它通过MCP协议公开了一个“research”工具。该工具允许通过查询Perplexity AI的API获取深入且最新的各种主题信息。

使用前请确保满足以下要求:

  • Go 1.18或更高版本
  • Perplexity AI API密钥

具体操作步骤如下:

  1. 设置所需的环境变量(可以使用.env文件)
  2. 构建并运行服务:
go build
./ResearchMCP

示例 .env 文件

PERPLEXITY_API_KEY=your_api_key_here
PERPLEXITY_MODEL=sonar-medium-online
PERPLEXITY_TIMEOUT=120
PERPLEXITY_MAX_RETRIES=3
PERPLEXITY_INITIAL_BACKOFF=2
PERPLEXITY_MAX_BACKOFF=15

✨ 主要特性

  • 通过Perplexity AI进行互联网研究
  • 集成MCP协议以实现工具发现和调用
  • 具有降级模式的优雅错误处理
  • 通过环境变量配置
  • 结构化日志记录

📦 安装指南

服务通过环境变量进行配置,具体如下: | 变量名 | 描述 | 是否必填 | 默认值 | |--------|------|----------|-------| | PERPLEXITY_API_KEY | Perplexity AI的API密钥 | 是 | - | | PERPLEXITY_MODEL | 用于研究的模型 | 否 | sonar-medium-online | | PERPLEXITY_TIMEOUT | API请求超时时间(秒) | 否 | 90 | | PERPLEXITY_MAX_RETRIES | 最大重试次数 | 否 | 2 | | PERPLEXITY_INITIAL_BACKOFF | 初始回退时间(秒) | 否 | 1 | | PERPLEXITY_MAX_BACKOFF | 最大回退时间(秒) | 否 | 10 |

💻 使用示例

基础用法

以下是调用research工具的示例请求:

{
  "name": "research",
  "arguments": {
    "query": "量子计算的当前状态是什么?"
  }
}

示例响应如下:

{
  "content": [
    {
      "type": "text",
      "text": "关于量子计算的综合研究报告...\n\n来源:
- https://example.com/source1
- https://example.com/source2"
    }
  ]
}

📚 详细文档

API - 研究工具

名称: research

输入 schema:

{
  "type": "object",
  "properties": {
    "query": {
      "type": "string",
      "description": "研究查询或问题"
    }
  },
  "required": ["query"]
}

🔧 技术细节

项目结构

  • main.go: 应用入口点
  • config.go: 配置处理
  • logger.go: 日志基础设施
  • perplexity.go: Perplexity API集成
  • structs.go: 数据结构
  • context.go: 上下文处理

代码风格

使用提供的脚本运行格式化和检查:

./run_format.sh
./run_lint.sh

📄 许可证

该项目采用MIT许可证,详情请参阅LICENSE文件。

help

Runtime guide

cloud

Hosted runtime

Hosted servers run from a provider-managed environment. You usually connect the MCP client to the hosted endpoint or follow the provider's authorization flow, without keeping a local process alive

  1. Open provider connection page
  2. Authorize or copy endpoint
  3. Connect from your MCP client
terminal

Local runtime / other methods

Local servers run on your own machine or infrastructure. You normally copy the server_config into your MCP client, install the required package, and provide env variables from env_schema when needed

  1. Copy server_config
  2. Install required package
  3. Fill env variables and restart client