MCP Perplexity 服务器工具
通过 Perplexity AI 的 API 启用智能代码分析和调试,提供详细的错误分析、模式检测和综合解决方案,并支持与 Claude 桌面客户端集成。
可用工具 (1 个)
该服务在 MCP 协议中暴露的工具,AI 可按需调用
search 3 个参数 需填 1 项
Search Perplexity for coding help
必填参数:query
服务介绍
Perplexity MCP 服务器
一个使用 Perplexity AI 的 API 提供智能代码分析和调试功能的 Model Context Protocol (MCP) 服务器。与 Claude 桌面客户端无缝协作。
功能
- 智能错误分析:详细分解编码错误并进行根本原因分析
- 模式检测:自动识别常见错误模式并提供针对性解决方案
- 全面解决方案:分步修复,提供多种实现方案
- 最佳实践:包括编码标准和错误预防技巧
- Python 支持:专门处理 Python 类型错误和常见编码问题
使用示例
可以问类似以下的问题:
- "修复我的 Python 代码中的这个 TypeError"
- "这个错误消息是什么原因造成的?"
- "我该如何修复这段代码?"
请包含您的代码片段以便进行有针对性的分析:
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)
服务器将提供:
- 错误的根本原因分析
- 带有代码示例的分步解决方案
- 防止类似问题的最佳实践
- 替代实现方法
安装
先决条件
- Node.js 18 或更高版本
- 一个 Perplexity AI API 密钥
选项 1:从 npm 安装(推荐)
# Using npm
npm install -g perplexity-mcp
# Or using the repository directly
npm install -g git+https://github.com/yourusername/perplexity-mcp.git
选项 2:从源码安装
- 克隆仓库:
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"
}
}
}
}
如果从源码安装:
{
"mcpServers": {
"perplexity": {
"command": "node",
"args": ["/absolute/path/to/perplexity-server/build/index.js"],
"env": {
"PERPLEXITY_API_KEY": "your-api-key-here"
}
}
}
}
安全性
- API 密钥安全地存储在 Claude 的桌面配置文件中
- 密钥作为环境变量传递给服务器
- 仓库中不存储任何敏感数据
- 服务器期望由 Claude 的环境提供 API 密钥
开发
项目结构
perplexity-server/
├── src/
│ └── index.ts # Main server implementation
├── package.json # Project configuration
└── tsconfig.json # TypeScript configuration
可用脚本
npm run build:构建项目npm run watch:监视更改并自动重新构建npm run prepare:准备发布包npm run inspector:运行 MCP 检查器进行调试
贡献
- 分叉仓库
- 创建你的功能分支 (
git checkout -b feature/amazing-feature) - 提交你的更改 (
git commit -m 'Add some amazing feature') - 推送到分支 (
git push origin feature/amazing-feature) - 打开一个 Pull Request
许可证
该项目根据 MIT 许可证许可 - 详情请参阅 LICENSE 文件。
致谢
- 感谢 Perplexity AI 提供强大的 API
- 使用 Model Context Protocol 构建