article
README
🚀 MCP ChatGPT 服务器
MCP ChatGPT 服务器允许您直接从 Claude Desktop 访问 OpenAI 的 ChatGPT API,为您提供便捷的 AI 交互体验。
📝 了解项目构建缘由:我构建了一个可以与其他 AI 交谈的 AI:揭开 MCP 热潮的神秘面纱
✨ 主要特性
- 可使用自定义参数调用 ChatGPT API。
- 支持让 Claude 和 ChatGPT 进行长时间对话。
- 能够配置模型版本、温度和其他参数。
- 可使用网络搜索获取最新的互联网信息。
- 采用 OpenAI 的响应 API 自动管理对话状态。
- 允许使用您自己的 OpenAI API 密钥。
📦 安装指南
通过 Smithery 安装
要通过 Smithery 自动安装 Claude Desktop 中的 ChatGPT Server,可运行以下命令:
npx -y @smithery/cli install @billster45/mcp-chatgpt-responses --client claude
先决条件
- Python 3.10 或更高版本。
- Claude Desktop 应用程序。
- OpenAI API 密钥。
- uv 用于 Python 包管理。
安装步骤
- 克隆此仓库:
git clone https://github.com/billster45/mcp-chatgpt-responses.git
cd mcp-chatgpt-responses
- 设置虚拟环境并使用 uv 安装依赖项:
uv venv
uv install
- 安装完成后,运行以下命令启动服务器:
uv run server:app
📚 详细文档
配置
在 Claude Desktop 中配置 MCP 服务器,请参考示例配置:
{
"mcpServers": {
"chatGpt": {
"type": "http",
"url": "http://localhost:5000"
}
},
"tools": {
"chatGpt": {
"command": "$ chatgpt工具",
"description": "与ChatGPT对话。使用$ {message}传递消息。",
"args": [
{
"name": "message",
"type": "string",
"description": "要发送给ChatGPT的消息。",
"required": true
}
]
}
}
}
工具
基本工具:ask_chatgpt
格式:
{
$: "chatgpt工具",
args: {
message: string,
options?: {
model?: string,
temperature?: number,
maxTokens?: number,
responseId?: string
}
}
}
示例:
{
$: "chatgpt工具",
args: {
message: "解释量子计算。",
options: {
model: "gpt-3.5-turbo",
temperature: 0.7,
maxTokens: 1000,
responseId: "response_123"
}
}
}
带网络搜索的工具:ask_chatgpt_with_search
格式:
{
$: "chatgpt工具",
args: {
message: string,
options?: {
model?: string,
temperature?: number,
maxTokens?: number,
responseId?: string
}
}
}
示例:
{
$: "chatgpt工具",
args: {
message: "纽约明天的天气如何?然后建议适合的食物和公园活动。",
options: {
model: "gpt-3.5-turbo",
temperature: 0.7,
maxTokens: 1500
}
}
}
🔧 技术细节
此工具利用 OpenAI 的响应 API,自动在 OpenAI 服务器上管理对话状态。这种方法具有以下优势:
- 简化了代码,让 OpenAI 处理上下文。
- 提供更可靠的上下文跟踪。
- 改善用户体验,通过维护消息历史记录。
- 允许通过网络搜索工具获取最新信息。
📄 许可证
本项目采用 MIT License。
扫码联系在线客服