MCP ChatGPT 响应
MCP ChatGPT Responses 通过两个 essential 工具将 Claude 与 ChatGPT 连接起来:用于 AI 之间对话的标准查询和用于获取当前信息的网络启用请求。它使用 OpenAI 的 Responses API 来自动维护对话状态。
MCP 服务配置
复制以下 JSON 到 OPClaw 或其他 MCP 客户端的配置文件中即可使用
{
"mcpServers": {
"chatgpt": {
"args": [
"--directory",
"\\path\\to\\mcp-chatgpt-responses",
"run",
"chatgpt_server.py"
],
"command": "uv",
"env": {
"DEFAULT_MODEL": "gpt-4o",
"DEFAULT_TEMPERATURE": "0.7",
"MAX_TOKENS": "1000",
"OPENAI_API_KEY": "your-api-key-here"
}
}
}
}
该服务需要配置环境变量:DEFAULT_MODEL、DEFAULT_TEMPERATURE、MAX_TOKENS、OPENAI_API_KEY
服务介绍
MCP ChatGPT 服务器
此 MCP 服务器允许您直接从 Claude 桌面访问 OpenAI 的 ChatGPT API。
📝 阅读我为什么构建这个项目:我构建了一个可以与其他 AI 对话的 AI:揭秘 MCP 热潮
功能
- 使用可自定义参数调用 ChatGPT API
- 让 Claude 和 ChatGPT 在长时间讨论中互相交流!
- 配置模型版本、温度和其他参数
- 使用网络搜索获取互联网上的最新信息
- 使用 OpenAI 的 Responses API 进行自动会话状态管理
- 使用您自己的 OpenAI API 密钥
设置说明
通过 Smithery 安装
要通过 Smithery 自动为 Claude 桌面安装 ChatGPT 服务器:
npx -y @smithery/cli install @billster45/mcp-chatgpt-responses --client claude
先决条件
- Python 3.10 或更高版本
- Claude 桌面 应用程序
- OpenAI API 密钥
- uv 用于 Python 包管理
安装
-
克隆此仓库:
git clone https://github.com/billster45/mcp-chatgpt-responses.git cd mcp-chatgpt-responses -
设置虚拟环境并使用 uv 安装依赖项:
uv venv.venv\\Scripts\\activateuv pip install -r requirements.txt
与 Claude 桌面一起使用
-
根据以下指南配置 Claude 桌面以使用此 MCP 服务器:
MCP 快速入门指南 -
将以下配置添加到您的 Claude 桌面配置文件中(根据需要调整路径):
{ "mcpServers": { "chatgpt": { "command": "uv", "args": [ "--directory", "\\path\\to\\mcp-chatgpt-responses", "run", "chatgpt_server.py" ], "env": { "OPENAI_API_KEY": "your-api-key-here", "DEFAULT_MODEL": "gpt-4o", "DEFAULT_TEMPERATURE": "0.7", "MAX_TOKENS": "1000" } } } } -
重启 Claude 桌面。
-
您现在可以通过 Claude 使用 ChatGPT API,只需提出涉及 ChatGPT 或 Claude 可能无法回答的问题即可。
可用工具
MCP 服务器提供以下工具:
-
ask_chatgpt(prompt, model, temperature, max_output_tokens, response_id)- 向 ChatGPT 发送提示并获取响应 -
ask_chatgpt_with_web_search(prompt, model, temperature, max_output_tokens, response_id)- 启用网络搜索向 ChatGPT 发送提示以获取最新信息
示例用法
基本 ChatGPT 用法:
告诉 Claude 向 ChatGPT 提问!
Use the ask_chatgpt tool to answer: What is the best way to learn Python?
告诉 Claude 与 ChatGPT 进行对话:
Use the ask_chatgpt tool to have a two way conversation between you and ChatGPT about the topic that is most important to you.
注意在轮流对话中,响应ID允许ChatGPT存储对话的历史记录,因此这是一场真正的对话,而不仅仅是一系列API调用。这被称为对话状态。
结合网络搜索:
对于可能从最新信息中受益的问题:
Use the ask_chatgpt_with_web_search tool to answer: What are the latest developments in quantum computing?
现在尝试以代理方式根据天气计划你完美的一天!
Use the ask_chatgpt_with_web_search tool to find the weather tomorrow in New York, then based on that weather and what it returns, keep using the tool to build up a great day out for someone who loves food and parks
工作原理
此工具利用了OpenAI的Responses API,该API会自动在OpenAI的服务器上维护对话状态。这种方法:
- 通过让OpenAI处理对话历史记录简化代码
- 提供更可靠的上下文跟踪
- 通过跨消息保持上下文来改善用户体验
- 允许通过网络搜索工具访问最新的网络信息
许可证
MIT许可证