POE MCP服务器

一个生产就绪的模型上下文协议(MCP)服务器,集成POE API与Warp.dev终端,提供AI驱动的终端辅助功能,包括上下文感知工具、自动化工作流和实时流媒体能力。

  • by Anansitrading
  • Python
  • 本地部署
  • 10 星标
  • 更新于
在 GitHub 查看 Anansitrading/poe-proxy-mcp

使用说明

Warp.dev增强型POE MCP服务器

一个生产就绪的模型上下文协议(MCP)服务器,将POE(POE.com API)与Warp.dev终端集成在一起,通过上下文感知工具、自动化工作流和实时流功能实现AI驱动的终端辅助。

🚀 特性

核心能力

  • 多模型支持:访问GPT-4o、Claude 3 Opus/Sonet、Gemini Pro、困惑和O3型号
  • 曲速终端集成:与Warp的上下文提取和动作执行深度集成
  • OpenAI SDK兼容性:使用POE后端替换OpenAI API
  • 生产准备就绪:速率限制、健康检查、指标和优雅关机

高级功能

  • 上下文感知查询:自动提取终端输出、选择、CWD、git状态
  • 实时流媒体:带有增量内容流的服务器发送事件(SSE)
  • 命令执行:通过验证安全执行终端命令
  • 文件操作:直接从模型响应创建和修改文件
  • 会话管理:跨多个查询维护对话上下文
  • 速率限制:具有500 RPM限制和请求队列的指数回退
  • 健康监测:内置健康检查和普罗米修斯式指标

📋 先决条件

  • 操作系统:Linux(在Ubuntu、Zorin OS上测试)、macOS或Windows上的WSL2
  • python:3.8或更高版本
  • 经纱终端: 从warp.dev下载
  • POE API密钥:从以下地址获取您的 poe.com/api_key

🔧 安装

步骤1:克隆和设置

# Clone the repository
git clone https://github.com/Anansitrading/enhanced-poe-mcp.git
cd enhanced-poe-mcp

# Quick installation with script
chmod +x install.sh
./install.sh

# Or manual setup
python3 -m venv venv
source venv/bin/activate  # On Linux/macOS
pip install -e .

步骤2:配置环境

创建一个 .env 使用您的凭据文件:

# Required
POE_API_KEY=your_poe_api_key_here

# Optional (with defaults)
OPENAI_API_KEY=your_openai_key  # For OpenAI SDK compatibility
DEBUG_MODE=false
USE_CLAUDE_COMPATIBLE=true
MAX_FILE_SIZE_MB=10
SESSION_EXPIRY_MINUTES=60
RATE_LIMIT_RPM=500
MAX_RETRIES=3
STREAM_BUFFER_SIZE=64
METRICS_ENABLED=true
HEALTH_CHECK_INTERVAL=30

步骤3:在曲速终端中配置

选项A:本地安装(可能导致稳定性问题)

  1. 打开扭曲MCP设置:

    • 导航到: 设置→ AI → 管理MCP服务器
    • 或按 Ctrl+P (Linux/Windows)或 Cmd+P (macOS)并搜索“打开MCP服务器”
  2. 添加POE MCP服务器: 点击 +添加 按钮并粘贴此配置:

    {
      "enhanced-poe-mcp": {
        "command": "python3",
        "args": ["/home/david/Projects/Kijko/MVP/MVP_Kijko/enhanced-poe-mcp/poe_server_phase2.py"],
        "env": {
          "POE_API_KEY": "your_poe_api_key_here",
          "PYTHONUNBUFFERED": "1",
          "DEBUG_MODE": "false",
          "RATE_LIMIT_RPM": "500"
        }
      }
    }
    

    重要:替换 /home/david/Projects/Kijko/MVP/MVP_Kijko/enhanced-poe-mcp 使用您的实际安装路径。

  3. 保存并启动:

    • 点击 保存 添加配置
    • 点击 开始 在您的服务器条目旁边
    • 服务器状态应显示为“正在运行”

选项B:远程托管(建议用于稳定性)

Warp支持远程MCP服务器! 远程托管MCP服务器以避免本地稳定性问题。

  1. 部署到Railway.app (最佳免费选项):

    # Prepare for deployment
    cd enhanced-poe-mcp
    echo "web: python poe_server_phase2.py" > Procfile
    git add .
    git commit -m "Add Procfile for Railway"
    git push origin main
    
  2. 配置铁路:

    • 注册地址: railway应用程序
    • 创建新项目→ 从GitHub部署
    • 在铁路仪表板中添加环境变量:
      • POE_API_KEY
      • PORT=8000
      • 任何其他配置变量
  3. 为远程MCP配置Warp:

    {
      "enhanced-poe-mcp": {
        "url": "https://your-app.up.railway.app/mcp/stream"
      }
    }
    

替代主机选项:

  • Render.com:良好的免费层,易于部署
  • 谷歌云运行:慷慨的免费层,需要Docker
  • Fly.io:全球部署,更复杂的设置
  • 维塞尔: ❌ 不兼容-无法处理持久连接、SSE流或长时间运行的任务

🎮 在经纱终端中的使用

指定POE型号

POE是一个拥有数百个LLM的市场。您必须指定要使用的模型:

# Using Claude 3.5 Sonnet
@poe --model claude-3-5-sonnet "Explain quantum computing"

# Using GPT-4o
@poe --model gpt-4o "Write a Python function"

# Using Gemini Pro
@poe --model google-gemini-pro "Analyze this data"

常用模型标识符:

型号 机器人标识符
克劳德3.5十四行诗 claude-3-5-sonnet
克劳德3 Opus claude-3-opus-20240229
GPT-4涡轮增压器 gpt-4-turbo
GPT-4o gpt-4o
Gemini Pro google-gemini-pro
《骆驼3》(70B) llama-3-70b
西北风大 mistral-large
困惑 perplexity-online
自定义机器人 使用poe.com/[机器人名称]中的句柄

基本POE查询

# Ask a simple question with specific model
@poe --model claude-3-5-sonnet What is the fastest way to create a Python virtual environment?

# Expected output:
# Claude will respond with: "Use `python -m venv <directory>` to create a virtual environment. 
# Activate it with `source <directory>/bin/activate` on Linux/macOS..."

带文件附件的查询

# Review a configuration file with Claude 3.5
@poe --model claude-3-5-sonnet Review this Dockerfile for security issues [attach:./Dockerfile]

# Expected output:
# Claude analyzes the file and provides security recommendations:
# "Found potential issues: 1) Running as root user, 2) No health check defined..."

上下文感知查询

# Get help with a recent error (POE sees your terminal output)
@poe --model gpt-4o Why did my git push fail?

# Expected output:
# GPT-4o analyzes recent terminal output and responds:
# "The push failed because the remote has changes not in your local branch. 
# Run `git pull --rebase` first..."

执行终端命令

# Let POE execute safe commands using Gemini
@poe --model google-gemini-pro Find all Python files modified today and show their sizes

# Expected output:
# Gemini generates and executes: find . -name "*.py" -mtime 0 -ls
# Shows results directly in terminal

流式长响应

# Get streaming output for complex tasks with Claude Opus
@poe --model claude-3-opus-20240229 --stream Generate a complete FastAPI application with authentication

# Expected output:
# Claude Opus streams the code generation in real-time, showing each part as it's created

会话管理

# Clear conversation context
@poe clear session

# Expected output:
# "Session cleared. Starting fresh conversation."

列出可用型号

# See all available AI models
@poe list models

# Expected output:
# Available models:
# - claude-3-opus: Advanced reasoning and analysis
# - gpt-4o: Latest GPT-4 variant
# - gemini-pro: Google's advanced model
# - perplexity: Web-aware responses

健康检查

# Check server health
@poe health check

# Expected output:
# Server Status: Healthy ✓
# Uptime: 2h 34m
# Active Sessions: 3
# Request Rate: 45 RPM

🛠️ 高级配置

服务器变体

该项目包括针对不同用例的多个服务器实现:

服务器文件 描述 用例
poe_server.py 基本MCP服务器 简单POE代理
enhanced_poe_server.py 通过扭曲动作增强 终端自动化
poe_server_v2.py SDK兼容 OpenAI SDK替换
poe_server_phase2.py 生产服务器 全功能+监控

运行不同模式

# Basic server
python poe_server.py

# Enhanced server with Warp integration
python enhanced_poe_server.py

# Production server (recommended)
python poe_server_phase2.py

# SSE mode for web clients
python run_sse_server.py [port]

环境变量引用

变量 描述 默认值 必填
POE_API_KEY 您的POE API密钥 - ✅
OPENAI_API_KEY OpenAI API密钥(用于SDK模式) - ❌
DEBUG_MODE 启用详细日志记录 false ❌
USE_CLAUDE_COMPATIBLE 克劳德思维协议 true ❌
MAX_FILE_SIZE_MB 最大文件上传大小 10 ❌
SESSION_EXPIRY_MINUTES 会话生存期 60 ❌
RATE_LIMIT_RPM 每分钟请求数限制 500 ❌
MAX_RETRIES 重试失败的尝试 3 ❌
STREAM_BUFFER_SIZE SSE缓冲区大小(KB) 64 ❌
METRICS_ENABLED 启用指标收集 true ❌
HEALTH_CHECK_INTERVAL 健康检查间隔(秒) 30 ❌

📊 监控和指标

健康检查端点

# Check server health programmatically
import requests
health = requests.get("http://localhost:8000/health")
print(health.json())
# Output: {"status": "healthy", "uptime": 3600, "active_sessions": 5}

指标端点

# Get performance metrics
metrics = requests.get("http://localhost:8000/metrics")
print(metrics.json())
# Output: {"total_requests": 1234, "error_rate": 0.02, "avg_latency_ms": 250}

🐛 故障排除

MCP服务器无法在Warp中启动

问题:服务器无法启动或在Warp MCP面板中显示为“错误”

解决方案:

  1. 验证Python路径: which python3 并更新配置
  2. 检查文件权限: chmod +x poe_server_phase2.py
  3. 手动测试: cd /path/to/server && python3 poe_server_phase2.py
  4. 检查日志:查找终端输出中的错误

身份验证错误

问题:“无效的API密钥”或“身份验证失败”

解决方案:

  1. 验证中的POE_API_KEY .env 文件
  2. 确保密钥已添加到Warp MCP配置环境中
  3. 测试密钥位于 poe.com/api_key

利率限制问题

问题:“超出速率限制”错误

解决方案:

  1. 增加 RATE_LIMIT_RPM 在配置中
  2. 启用请求排队(在第2阶段服务器中自动)
  3. 在客户端代码中实现指数回退

上下文不起作用

问题:POE看不到终端输出或上下文

解决方案:

  1. 使用 poe_server_phase2.py (非基本服务器)
  2. 确保启用了Warp上下文权限
  3. 更新到最新Warp版本

Linux特定问题

问题:权限被拒绝或找不到模块

解决方案:

# Fix permissions
chmod -R 755 /path/to/enhanced-poe-mcp
chown -R $USER:$USER /path/to/enhanced-poe-mcp

# Install missing Python packages
pip install -r requirements.txt

# Use virtual environment
source venv/bin/activate

🚀 远程部署指南(铁路)

为什么要远程主机?

  • 避免局部稳定性问题
  • 即使机器关闭,也始终可用
  • 集中配置管理
  • 更有利于团队协作

分步铁路部署

  1. 准备你的项目:

    cd enhanced-poe-mcp
    
    # Create Procfile for Railway
    echo 'web: python poe_server_phase2.py' > Procfile
    
    # Ensure requirements.txt is complete
    pip freeze > requirements.txt
    
    # Create runtime.txt for Python version
    echo "python-3.11.x" > runtime.txt
    
    # Commit changes
    git add .
    git commit -m "Add Railway deployment files"
    git push origin main
    
  2. 建立铁路:

    • 注册地址: railway应用程序 (GitHub免费)
    • 点击 “新项目” → “从GitHub仓库部署”
    • 选择您的 enhanced-poe-mcp 仓库
    • Railway将自动检测Python并开始部署
  3. 配置环境变量: 在铁路仪表板中,转到 变量 选项卡并添加:

    POE_API_KEY=your_poe_api_key_here
    PORT=8000
    DEBUG_MODE=false
    RATE_LIMIT_RPM=500
    PYTHONUNBUFFERED=1
    
  4. 获取您的服务器URL:

    • 首选 设置 铁路选项卡
    • 在...之下 领域,单击 “生成域”
    • 复制您的URL(例如。, https://your-app.up.railway.app)
  5. 使用远程URL配置Warp:

    {
      "enhanced-poe-mcp": {
        "url": "https://your-app.up.railway.app/mcp/stream"
      }
    }
    
  6. 测试连接:

    # Test your remote server
    curl https://your-app.up.railway.app/health
    
    # Should return:
    # {"status": "healthy", "version": "2.0.0"}
    

监控您的远程服务器

  • 日志:在铁路仪表板中的“部署”下查看
  • 指标:检查 /metrics 端点
  • 健康:监视器 /health 端点
  • 用法:铁路在仪表板中显示资源消耗

🌗️ 建筑

┌─────────────────┐         ┌──────────────────────────┐
│  Warp Terminal  │ ◄──────►│   POE MCP Server         │
│                 │  MCP     ├──────────────────────────┤
│  - User Input   │  Proto   │ • Request Handler        │
│  - Context      │         │ • Rate Limiter           │
│  - Actions      │         │ • Session Manager        │
└─────────────────┘         │ • Warp Context Handler   │
                            │ • Streaming Engine       │
                            └───────────┬──────────────┘
                                       │
                            ┌───────────▼──────────────┐
                            │      POE API             │
                            │                          │
                            │ • Claude, GPT-4o         │
                            │ • Gemini, Perplexity     │
                            └──────────────────────────┘

🧪 测试

# Run all tests
python run_tests.py

# Run with verbose output
python run_tests.py --verbose

# Test specific components
python -m pytest tests/test_poe_server.py -v
python -m pytest tests/test_rate_limiter.py -v
python -m pytest tests/test_streaming.py -v

📚 API文档

MCP工具参考

工具 说明 参数
ask_poe 基本POE查询 prompt, model, session_id
ask_with_attachment 使用文件查询 prompt, model, file_path
ask_poe_with_warp_context 上下文感知查询 prompt, model, warp_context
stream_poe_to_warp 流媒体响应 prompt, model, stream=true
execute_warp_action 运行终端命令 action_type, content, validate
clear_session 重置对话 session_id
list_available_models 获取型号列表 -
health_check 服务器运行状况 -
get_metrics 性能统计 -

🤝 贡献

我们欢迎捐款!请看 贡献.md 作为指导方针。

开发设置

# Clone and setup development environment
git clone https://github.com/Anansitrading/enhanced-poe-mcp.git
cd enhanced-poe-mcp
python3 -m venv venv
source venv/bin/activate
pip install -e ".[dev]"

# Run in development mode
DEBUG_MODE=true python poe_server_phase2.py

📄 许可证

此项目根据MIT许可证获得许可-请参阅 许可证 文件以获取详细信息。

🙏 致谢

  • Poe.com 用于API访问
  • Warp.dev 对于令人惊叹的终端
  • FastMCP 对于MCP框架
  • 持续支持的开源社区

📞 支持


备注:这个项目不隶属于Poe.com或Warp.dev。它是一个独立的集成工具。