这是一个实现了Model Context Protocol (MCP)服务器,使OpenRouter能够与Perplexity Ask兼容。
该项目受到Perplexity Ask的启发,提供了一个连接到OpenRouter API的MCP服务器实现。它允许您通过OpenRouter使用Perplexity的模型,并且可以与任何兼容MCP的客户端一起使用。
perplexity_ask - 使用Sonar模型进行一般查询perplexity_research - 使用Sonar Deep Research模型进行深入研究perplexity_reason - 使用Sonar Reasoning模型进行复杂推理任务服务器需要以下环境变量:
OPENROUTER_API_KEY - 您的OpenRouter API密钥(必需)PORT - 运行服务器的端口(默认:3000)BASE_URL - 自定义OpenRouter基础URL(可选)ASK_MODEL - 用于问工具的模型(默认:perplexity/sonar-pro)RESEARCH_MODEL - 用于研究工具的模型(默认:perplexity/sonar-deep-research)REASON_MODEL - 用于推理工具的模型(默认:perplexity/sonar-reasoning-pro)DISABLE_ASK - 禁用问工具(默认:false)DISABLE_RESEARCH - 禁用研究工具(默认:false)DISABLE_REASON - 禁用推理工具(默认:false)最简单的方法是使用Docker来运行服务器:
docker run -p 3000:3000 \
-e OPENROUTER_API_KEY=your_api_key_here \
ghcr.io/elct9620/perplexity-ask-openrouter:latest
如果您更喜欢从源码构建:
# 克隆仓库
git clone https://github.com/elct9620/perplexity-ask-openrouter.git
cd perplexity-ask-openrouter
# 构建Docker镜像
docker build -t perplexity-ask-openrouter .
服务器暴露了以下端点:
/sse - 建立连接的SSE端点/messages - 发送消息给已建立的SSE连接的端点/mcp - 实现MCP协议的可流传输HTTP端点此服务器实现了Model Context Protocol,因此可以与任何兼容MCP的客户端一起使用。服务器支持SSE和可流传输的HTTP传输模式。
项目包括一个Dockerfile和GitHub Actions工作流程,用于构建并发布Docker镜像到GitHub Container Registry (ghcr.io)。