Perplexity Advanced MCP

by code-yeongyu
Verified

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.

Integrations

  • Provides integration with GitHub for source code hosting and version control.

  • Provides a tool for asking internet search queries through Perplexity AI, supporting both simple and complex queries with file attachment capabilities. Optimized for different query types to balance cost and performance.

  • Enables distribution of the package through the Python Package Index, allowing users to install the MCP via pip or uvx.

Perplexity 高级 MCP

韩国


概述

Perplexity Advanced MCP 是一个高级集成包,它利用OpenRouterPerplexity API 提供增强的查询处理功能。该包拥有直观的命令行界面和强大的 API 客户端,可与 AI 模型无缝交互,处理简单和复杂的查询。

perplexity-mcp 的比较

perplexity-mcp使用Perplexity AI 的 API 提供基本的网页搜索功能,而 Perplexity Advanced MCP 则提供了一些附加功能:

  • **多供应商支持:**支持PerplexityOpenRouter API,让您可以灵活地选择供应商
  • **查询类型优化:**区分简单查询和复杂查询,优化成本和性能
  • **文件附件支持:**允许将文件内容作为上下文包含在查询中,从而实现更精确、更具上下文的响应
  • **增强的重试逻辑:**实施强大的重试机制以提高可靠性

总体而言,当与ClineCursor等编辑器集成时,这是最适合处理代码库的 MCP。

特征

  • **统一 API 客户端:**支持OpenRouterPerplexity API,并具有可配置模型来处理简单和复杂的查询。
  • **命令行界面(CLI):**管理 API 密钥配置并使用Typer运行 MCP 服务器。
  • **高级查询处理:**结合文件附件处理,允许您在查询中包含上下文数据。
  • **强大的重试机制:**利用 Tenacity 进行重试逻辑,确保 API 通信一致、可靠。
  • **可定制的日志记录:**灵活的日志记录配置,用于详细的调试和运行时监控。

最佳AI配置

为了获得 AI 助手(例如CursorClaude for Desktop )的最佳体验,我建议在项目说明或 AI 规则中添加以下配置:

<perplexity-advanced-mcp> <description> Perplexity is an LLM that can search the internet, gather information, and answer users' queries. For example, let's suppose we want to find out the latest version of Python. 1. You would search on Google. 2. Then read the top two or three results directly to verify. Perplexity does that work for you. To answer a user's query, Perplexity searches, opens the top search results, finds information on those websites, and then provides the answer. Perplexity can be used with two types of queries: simple and complex. Choosing the right query type to fulfill the user's request is most important. </description> <simple-query> <description> It's cheap and fast. However, it's not suitable for complex queries. On average, it's more than 10 times cheaper and 3 times faster than complex queries. Use it for simple questions such as "What is the latest version of Python?" </description> <pricing> $1/M input tokens $1/M output tokens </pricing> </simple-query> <complex-query> <description> It's slower and more expensive. Compared to simple queries, it's on average more than 10 times more expensive and 3 times slower. Use it for more complex requests like "Analyze the attached code to examine the current status of a specific library and create a migration plan." </description> <pricing> $1/M input tokens $5/M output tokens </pricing> </complex-query> <instruction> When reviewing the user's request, if you find anything unexpected, uncertain, or questionable, **and you think you can get answer from the internet**, do not hesitate to use the "ask_perplexity" tool to consult Perplexity. However, if the internet is not required to satisfy users' request, it's meaningless to ask to perplexity. Since Perplexity is also an LLM, prompt engineering techniques are paramount. Remember the basics of prompt engineering, such as providing clear instructions, sufficient context, and examples Include as much context and relevant files as possible to smoothly fulfill the user's request. When adding files as attachments, make sure they are absolute paths. </instruction> </perplexity-advanced-mcp>

此配置可帮助 AI 助手更好地了解何时以及如何使用 Perplexity 搜索功能,从而优化成本和性能。

用法

通过 Smithery 安装

要通过Smithery自动为 Claude Desktop 安装 Perplexity Advanced MCP:

npx -y @smithery/cli install @code-yeongyu/perplexity-advanced-mcp --client claude

uvx快速入门

运行 MCP 服务器最简单的方法是使用uvx

uvx perplexity-advanced-mcp -o <openrouter_api_key> # or -p <perplexity_api_key>

您还可以使用环境变量配置 API 密钥:

export OPENROUTER_API_KEY="your_key_here" # or export PERPLEXITY_API_KEY="your_key_here" uvx perplexity-advanced-mcp

笔记:

  • 同时提供 OpenRouter 和 Perplexity API 密钥将导致错误
  • 当同时提供 CLI 参数和环境变量时,CLI 参数优先

CLI 使用Typer构建,确保用户友好的命令行体验。

MCP 搜索工具

该软件包包含一个通过ask_perplexity函数集成的 MCP 搜索工具。它支持简单和复杂的查询,并可处理文件附件以提供额外的上下文信息。

  • **简单查询:**提供快速、高效的响应。
  • **复杂查询:**进行详细推理并支持 XML 格式的文件附件。

配置

  • **API 密钥:**通过命令行选项或环境变量配置OPENROUTER_API_KEYPERPLEXITY_API_KEY
  • **模型选择:**配置(在src/perplexity_advanced_mcp/config.py中)将查询类型映射到特定模型:
    • OpenRouter
      • 简单查询: perplexity/sonar
      • 复杂查询: perplexity/sonar-reasoning
    • 困惑
      • 简单查询: sonar-pro
      • 复杂查询: sonar-reasoning-pro

开发背景与理念

这个项目源于我个人的好奇心和实验。顺应最近的“氛围编码”潮流,超过 95% 的代码都是通过Cline + Cursor IDE 编写的。俗话说“说话不费力,代码见分晓”——有了Wispr Flow的语音转文本功能,我只需开口说话,代码就能出来!大部分开发工作都是我通过说“帮我写 xyz 的代码,修复 xyz 的错误”之类的指令,然后按下回车键完成的。值得一提的是,创建这个功能齐全的项目只花了不到几个小时。

从项目脚手架到文件结构,所有内容均通过 LLM 编写和审核。甚至 PyPI 发布的 GitHub Actions 工作流和发布审批流程也通过 Cursor 处理。作为一名人类开发人员,我的职责是:

  • 启动和停止 MCP 服务器以帮助 AI 进行正确的测试
  • 出现问题时复制并提供错误日志
  • 从互联网上查找并提供Python MCP SDK文档和示例
  • 请求修改看起来不正确的代码

在当今世界,许多事物都可以自动化和替代,我希望这款 MCP 能够帮助像您一样使用它的开发者发现超越编写代码的价值。愿它助您成为能够做出更高层次决策和考量的新一代开发者。

发展

要贡献或修改此包:

1.克隆存储库:

gh repo clone code-yeongyu/perplexity-advanced-mcp

2.安装依赖项:

uv sync

3.贡献:

欢迎贡献代码!请遵循现有的代码风格和提交指南。

执照

该项目已获得 MIT 许可。

-
security - not tested
F
license - not found
-
quality - not tested

这是一个先进的集成包,利用 OpenRouter 和 Perplexity API 来提供增强的网络搜索功能,提供简单和复杂的查询处理以及文件附件支持。

  1. Overview
    1. Comparison with perplexity-mcp
      1. Features
        1. Optimal AI Configuration
          1. Usage
            1. Installing via Smithery
            2. Quick Start with uvx
            3. MCP Search Tool
          2. Configuration
            1. Development Background & Philosophy
              1. Development
                1. 1. Clone the Repository:
                2. 2. Install Dependencies:
                3. 3. Contribute:
              2. License
                ID: sok882f31z