Poe o3 MCP服务器
一种轻量级模型上下文协议(MCP)服务器实现,通过Poe的API提供对OpenAI的o3模型和其他模型的访问。该服务器允许您将Poe的AI功能集成到任何兼容MCP的应用程序中。
特性
- 使用FastMCP实现简单的MCP服务器
- 与Poe的API直接集成,以访问o3模型和其他模型
- 通过提示中的命令行样式标志进行模型选择
- 异步请求处理,实现高效处理
- 全面的错误处理和记录
- 易于设置和配置
先决条件
- Python 3.8+
- Poe API钥匙(可从 https://poe.com/api_key)
安装
- 克隆此存储库:
git clone https://github.com/Anansitrading/po3_MCP.git
cd po3_MCP- 创建虚拟环境(推荐):
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate- 安装所需的依赖项:
pip install -r requirements.txt- 设置环境变量:
cp sample.env .env- 编辑
.env文件并添加您的Poe API密钥:
POE_API_KEY=your_poe_api_key_here用法
运行MCP服务器
使用以下命令运行服务器:
python poe_o3_mcp_server.py服务器将启动并监听标准输入/输出上的MCP协议消息。
通过标志选择型号
您可以通过在提示中添加标记来选择Poe上可用的不同型号:
--Claude-3.5-Sonnet Tell me about quantum computing这将把您的查询路由到Claude-3.5-Sonet模型,而不是默认的o3模型。
该标志可以放置在消息中的任何位置:
- 开始时:
--GPT-4 What is the capital of France? - 在中间:
Tell me --Claude-3-Opus about the history of Rome - 最后:
What are the three laws of robotics? --Claude-3.5-Sonnet
在将标志发送到模型之前,它将自动从消息中删除。
如果没有指定标志,服务器默认使用“o3”模型。
与MCP客户端集成
此服务器提供两个工具:
o3_query-向o3模型(或通过标志发送另一个模型)发送查询并获得响应ping-一个返回“pong”的简单测试工具
将服务器与MCP客户端一起使用的示例:
from mcp.client import MCPClient
# Connect to the MCP server
client = MCPClient(server_command=["python", "path/to/poe_o3_mcp_server.py"])
# Call the o3_query tool with the default o3 model
response = client.call_tool("o3_query", {"message": "Tell me about quantum computing"})
print(response)
# Call the o3_query tool with a different model using a flag
response = client.call_tool("o3_query", {"message": "--Claude-3.5-Sonnet Tell me about quantum computing"})
print(response)
# Test the connection with ping
ping_response = client.call_tool("ping", {})
print(ping_response) # Should print "pong"您还可以运行附带的示例脚本:
python example.py配置
服务器使用以下环境变量:
POE_API_KEY:您的Poe API密钥(必需)LOG_LEVEL:日志记录级别(可选,默认为DEBUG)
故障排除
如果您遇到问题:
- 检查您的Poe API密钥是否有效,并在
.env文件 - 确保安装了正确的依赖项
- 检查服务器日志以获取详细的错误消息
- 验证您是否有活动的互联网连接
- 如果使用模型标志,请确保模型名称正确且在Poe上可用
许可证
麻省理工学院

