返回市场
困惑度-MCP-Go服务器

困惑度-MCP-Go服务器

作者:chenxilol4 星标更新:2025-03-29

项目介绍

Perplexity Search MCP 服务器

License: MIT

这是一个用 Go 实现的 Perplexity Search MCP 服务器,允许大型语言模型(LLMs)通过 Model Context Protocol (MCP) 访问 Perplexity 搜索 API。

特性

  • perplexity_search: 执行网络搜索并返回结果,包括引用
    • 参数
      • query (字符串,必需):搜索查询
      • search_recency_filter (字符串,可选):按时间过滤结果 (month, week, day, hour)
      • max_tokens (整数,可选):返回的最大标记数量
      • temperature (数字,可选,默认值:0.2):控制响应中的随机性
      • top_p (数字,可选,默认值:0.9):核心采样阈值
      • search_domain_filter (数组,可选):限制搜索结果的域名列表
      • return_images (布尔值,可选):在结果中包含图像链接
      • return_related_questions (布尔值,可选):在结果中包含相关问题
      • top_k (数字,可选,默认值:0):用于 top-k 过滤的标记数量
      • stream (布尔值,可选):增量流式传输响应
      • presence_penalty (数字,可选,默认值:0):调整新主题的可能性
      • frequency_penalty (数字,可选,默认值:1):减少重复
      • web_search_options (对象,可选):网络搜索配置选项

安装与使用

通过 Smithery 安装

要通过 Smithery 自动安装 Perplexity Search Golang for Claude Desktop:

npx -y @smithery/cli install @chenxilol/perplexity-mcp-go --client claude

先决条件

  • Go 1.23 或更高版本
  • Perplexity API 密钥

安装

  1. 克隆仓库:
git clone https://github.com/chenxilol/perplexity-mcp-go.git
cd perplexity-mcp-go
  1. 构建应用:
go build -o perplexity-search-mcp

在本地运行

  1. 设置你的 Perplexity API 密钥:
export PERPLEXITY_API_KEY="your-api-key-here"
  1. 运行服务器:
./perplexity-search-mcp

与 Claude 集成

  1. 将提供的 claude_desktop_config.json 复制到你的 Claude 配置目录中:

    • Windows: %USERPROFILE%\AppData\Roaming\Claude\claude_desktop_config.json
    • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
    • Linux: ~/.config/Claude/claude_desktop_config.json
  2. 编辑配置文件以包含你的 API 密钥:

{
  "mcpServers": {
    "perplexity-search": {
      "command": "/path/to/perplexity-search-mcp",
      "env": {
        "PERPLEXITY_API_KEY": "your-api-key-here"
      }
    }
  }
}

Docker 支持

  1. 构建 Docker 镜像:
docker build -t perplexity-search-mcp:latest .
  1. 运行容器:
docker run -i --rm -e PERPLEXITY_API_KEY=your-api-key-here perplexity-search-mcp:latest

示例用法

配置完成后,Claude 可以通过 MCP 使用 perplexity_search 工具执行实时网络搜索。

带有参数的示例搜索:

{
  "query": "最新的人工智能研究进展",
  "search_recency_filter": "week",
  "temperature": 0.5,
  "return_related_questions": true,
  "web_search_options": {
    "search_context_size": "high"
  }
}

故障排除

如果遇到问题:

  1. 验证你的 API 密钥是否正确设置
  2. 检查网络连接
  3. 查看 stderr 日志中的错误消息

许可证

本项目采用 MIT 许可证 - 详情见 LICENSE 文件。

致谢