Skip to main content
Glama

Perplexity MCP Server

by laodev1

Perplexity MCP 服务器

概述

Perplexity MCP 服务器是 Anthropic 模型上下文协议 (MCP) 的 Node.js 实现,使 Claude 能够与 Perplexity 的语言模型进行交互。该服务器在 Claude 和 Perplexity AI 的功能之间搭建了安全的桥梁,允许通过使用工具增强 AI 交互。

可用工具

该服务器目前实现了两个主要工具:

1. perplexity_chat

先进的聊天完成工具,支持完整的消息历史记录。

{ "name": "perplexity_chat", "description": "Generate a chat completion using Perplexity AI", "parameters": { "model": "string (optional) - One of: llama-3.1-sonar-small-128k-online, llama-3.1-sonar-large-128k-online, llama-3.1-sonar-huge-128k-online", "messages": "array of {role, content} objects - The conversation history", "temperature": "number (optional) - Sampling temperature between 0-2" } }

2. perplexity_ask

简化的单一查询界面,用于快速提问。

{ "name": "perplexity_ask", "description": "Send a simple query to Perplexity AI", "parameters": { "query": "string - The question or prompt to send", "model": "string (optional) - One of: llama-3.1-sonar-small-128k-online, llama-3.1-sonar-large-128k-online, llama-3.1-sonar-huge-128k-online" } }

安装

  1. 克隆存储库:
    git clone https://github.com/yourusername/perplexity-mcp-server.git cd perplexity-mcp-server
  2. 安装依赖项:
    npm install
  3. 创建.env文件:
    PERPLEXITY_API_KEY=your-api-key-here
  4. 构建项目:
    npm run build

Claude桌面配置

要将此服务器添加到 Claude Desktop,请更新您的claude_desktop_config.json

{ "mcpServers": { //more servers... "perplexity": { "command": "node", "args": ["path\\to\\perplexity-mcp-server\\dist\\index.js"], "env": { "PERPLEXITY_API_KEY": "YOUR_PERPLEXITY_API_KEY" } } //more servers... } }

配置文件通常位于:

  • Windows: %APPDATA%/Claude/config/claude_desktop_config.json
  • macOS: ~/Library/Application Support/Claude/config/claude_desktop_config.json
  • Linux: ~/.config/Claude/config/claude_desktop_config.json

发展

启动开发服务器并自动重新编译:

npm run dev

服务器使用 TypeScript 并使用@modelcontextprotocol/sdk包实现 MCP 协议。

建筑学

核心组件

  1. PerplexityServer 类
    • 实现 MCP 服务器协议
    • 处理工具注册和执行
    • 管理错误处理和服务器生命周期
  2. 工具系统
    • 模块化工具定义
    • 类型安全的工具处理程序
    • 结构化输入验证

技术细节

  • 使用 TypeScript 构建以确保类型安全
  • 使用@modelcontextprotocol/sdk实现 MCP
  • 通过 stdio 传输进行通信
  • 基于环境的配置

错误处理

服务器实现了全面的错误处理:

  • API错误报告
  • 无效工具请求处理
  • 连接错误管理
  • 过程信号处理

依赖项

  • @modelcontextprotocol/sdk : ^1.0.3
  • dotenv :^16.4.7
  • isomorphic-fetch :^3.0.0

贡献

  1. 分叉存储库
  2. 创建你的功能分支( git checkout -b feature/amazing-feature
  3. 提交您的更改( git commit -m 'Add some amazing feature'
  4. 推送到分支( git push origin feature/amazing-feature
  5. 打开拉取请求

安全

  • API 密钥通过环境变量进行管理
  • 所有工具参数的输入验证
  • 错误消息在输出前被清理
  • 通过 MCP 协议进行进程隔离

执照

该项目已获得 ISC 许可。

故障排除

常见问题及解决方案:

  1. 未找到服务器
    • 验证claude_desktop_config.json中的路径是否正确
    • 确保服务器已构建( npm run build
    • 检查 Node.js 是否在你的 PATH 中
  2. 身份验证错误
    • 在 .env 中验证您的 Perplexity API 密钥
    • 检查 API 密钥是否具有所需的权限
  3. 工具执行错误
    • 验证工具参数与方案匹配
    • 检查网络连接
    • 查看服务器日志以获取详细的错误消息

You must be authenticated.

A
security – no known vulnerabilities
F
license - not found
A
quality - confirmed to work

remote-capable server

The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.

Node.js 实现使 Claude 能够通过 Anthropic 的模型上下文协议与 Perplexity AI 的语言模型进行交互,从而提供高级聊天完成和快速查询的工具。

  1. 概述
    1. 可用工具
      1. perplexity\_chat
      2. perplexity\_ask
    2. 安装
      1. Claude桌面配置
        1. 发展
          1. 建筑学
            1. 核心组件
            2. 技术细节
          2. 错误处理
            1. 依赖项
              1. 贡献
                1. 安全
                  1. 执照
                    1. 故障排除

                      Related MCP Servers

                      • A
                        security
                        A
                        license
                        A
                        quality
                        Enables integration of Perplexity's AI API with LLMs, delivering advanced chat completion by utilizing specialized prompt templates for tasks like technical documentation, code review, and API documentation.
                        Last updated -
                        1
                        94
                        8
                        JavaScript
                        MIT License
                        • Linux
                      • A
                        security
                        F
                        license
                        A
                        quality
                        This server provides access to the Perplexity AI API, enabling interaction through chatting, searching, and documentation retrieval within MCP-based systems.
                        Last updated -
                        5
                        2
                        JavaScript
                      • -
                        security
                        A
                        license
                        -
                        quality
                        Provides access to Perplexity AI models through two tools: ask\_perplexity for expert programming assistance and chat\_perplexity for maintaining ongoing conversations with context preservation.
                        Last updated -
                        Python
                        MIT License
                        • Linux
                        • Apple
                      • -
                        security
                        F
                        license
                        -
                        quality
                        A server implementing the Model Context Protocol that enables AI assistants like Claude to interact with Google's Gemini API for text generation, text analysis, and chat conversations.
                        Last updated -
                        Python
                        • Linux
                        • Apple

                      View all related MCP servers

                      MCP directory API

                      We provide all the information about MCP servers via our MCP API.

                      curl -X GET 'https://glama.ai/api/mcp/v1/servers/laodev1/perplexity-mcp-server'

                      If you have feedback or need assistance with the MCP directory API, please join our Discord server