Perplexity MCP Server

Perplexity MCP Server

镜像

简介

Perplexity MCP 服务器通过 Perplexity AI 的 API 提供智能代码分析和调试功能,与 Claude 桌面客户端无缝集成。

主要功能

  • 智能错误分析与根本原因诊断
  • 自动识别错误模式并提供解决方案
  • 提供多种实现方案的修复方法
  • 针对 Python 类型错误的专门支持

安装步骤

前提条件

  • Node.js 18+
  • Perplexity AI API 密钥

从 npm 安装(推荐)

npm install -g perplexity-mcp

从源码安装

git clone https://github.com/yourusername/perplexity-server.git
cd perplexity-server
npm install
npm run build
npm install -g .

配置 Claude 桌面应用

编辑 Claude 桌面配置文件:

  • MacOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%/Claude/claude_desktop_config.json

添加以下配置:

{
  "mcpServers": {
    "perplexity": {
      "command": "perplexity-mcp",
      "args": [],
      "env": {
        "PERPLEXITY_API_KEY": "your-api-key-here"
      }
    }
  }
}

使用示例

向 Claude 提出问题并包含您的代码片段:

def calculate_total(items):
    total = 0
    for item in items:
        total = total + item['price']  # TypeError: string + int

data = [
    {'name': 'Book', 'price': '10'},
    {'name': 'Pen', 'price': '2'}
]

result = calculate_total(data)

服务器将分析错误并提供:

  1. 错误根本原因
  2. 代码修复方案
  3. 最佳实践建议
  4. 替代实现方法

安全注意事项

  • API 密钥仅存储在 Claude 的配置文件中
  • 通过环境变量安全传递给服务器

更多信息

完整文档和贡献指南请访问 GitHub 仓库