ChatGPT升级MCP服务器
MCP(模型上下文协议)服务器,使自主编码代理能够自动将复杂问题升级到ChatGPT Desktop应用程序-- ToS合规 通过原生UI自动化。
这有什么作用: 该工具允许自主编码代理(Copilot、Claude、Cline、Roo等)将难题升级到 *ChatGPT桌面应用程序* 在你的电脑上。它以与人类相同的方式自动化了ChatGPT——点击UI,发送问题,等待响应,复制它——然后将答案返回给您的代理,以便它可以继续工作 *没有你*.
### 🖥️ 仅限Windows 10/11 此工具仅支持Windows。 macOS和Linux不受支持,也没有增加支持的计划。 ### ⚠️ 重要要求 - ChatGPT桌面应用程序 (微软商店版本) - 自动化控制您的ChatGPT窗口-- 不要碰它 在升级过程中 - 仅 一次升级一次 (请求已排队) - ChatGPT中的UI更改可能会破坏自动化-- 打开一个问题 如果发生这种情况 ### ✅ ToS合规 此工具仅自动化您的 *本地* ChatGPT桌面应用程序。确实如此 不 自动化web UI、绕过安全功能或抓取数据。
特性
- 两个MCP工具:
- escalate_to_expert -向ChatGPT发送问题并收到详细回复 - list_projects -从配置中发现可用的项目ID
- 100%准确的UI检测 -基于像素的侧边栏状态检测和响应完成
- 基于OCR的导航 -PaddleOCR v5用于可靠的文本提取和模糊匹配
- 异步模型加载 -OCR模型在后台预加载,以加快响应时间
- 项目组织机构 -将多个项目映射到不同的ChatGPT对话
运作原理
┌─────────────────┐ MCP Protocol ┌──────────────────┐
│ Coding Agent │◄──────────────────►│ MCP Server │
│ (Copilot/Roo) │ │ (This Project) │
└─────────────────┘ └────────┬─────────┘
│
│ spawn
▼
┌──────────────────┐
│ Python Driver │
│ (Windows) │
└────────┬─────────┘
│
│ UI Automation
▼
┌──────────────────┐
│ ChatGPT Desktop │
│ App │
└──────────────────┘自动化流程
- 杀死ChatGPT -确保清洁状态
- 打开ChatGPT -重新开始
- 聚焦窗口 -带到前台
- 打开侧边栏 -点击汉堡包菜单(状态像素检测)
- 点击项目 -OCR+模糊匹配查找文件夹
- 单击对话 -OCR+模糊匹配来查找聊天(如果找不到,则按Ctrl+K回退)
- 焦点输入 -点击文本输入区
- 发送提示 -粘贴并提交
- 等待响应 -基于像素的停止按钮检测
- 复制响应 -强大的按钮探测功能,用于查找复制按钮
自动重试逻辑:如果任何一步失败,整个流程将重新启动(总共最多4次尝试)。每次重试都会获得一个新的ChatGPT实例。大多数失败都是暂时的(焦点丢失,窗口最小化),并在重试时成功。
系统要求
| 要求 | 版本 | 注释 |
|---|---|---|
| 视窗 | 10或11 | 不支持macOS/Linux |
| ChatGPT桌面 | 最新 | Microsoft Store版本 |
| Node.js | 18+ | 适用于MCP服务器 |
| python | 3.10+ | 用于UI自动化驱动程序 |
| 图形处理器 | 不需要 | 仅CPU OCR工作正常 |
Python包
pywinauto # Windows UI automation
pyperclip # Clipboard access
paddleocr # Text recognition
paddlepaddle # PaddleOCR backend为什么只有Windows?
ChatGPT Desktop通过UI自动化API在Windows上公开完全可访问的UI元素。基于像素的检测和键盘/鼠标自动化在Windows上可靠地工作。
macOS有不同的自动化API(Accessibility API),需要完全重写驱动程序。Linux没有ChatGPT桌面应用程序。
测试环境
| 组件 | 版本 | 状态 |
|---|---|---|
| ChatGPT桌面 | 1.2025.112 | ✅ 已测试 |
| Windows 11 | 24H2(26100.2605号楼) | ✅ 已测试 |
| 上次验证时间 | 2025年12月2日 |
稳健性特征
- 自动检索:每次升级最多4次尝试,具有智能故障检测功能
- 结构化可观察性:每次升级都有其独特之处
run_id用于关联和调试 - 错误原因代码:12+特定错误代码(例如。,
focus_failed,project_not_found,empty_response) - 混沌测试:通过激进的混沌测试(随机焦点窃取、窗口最小化、鼠标干扰)
- 智能回退:如果对话在侧边栏中不可见,则按Ctrl+K搜索
💡 ChatGPT更新后: 如果ChatGPT显著更改其布局,UI自动化可能会中断。如果您在更新后遇到问题,请 打开一个问题 使用您的ChatGPT版本。
安装
选项1:从npm安装(推荐)
# Install globally
npm install -g chatgpt-escalation-mcp
# Install Python dependencies
pip install pywinauto pyperclip paddleocr paddlepaddle
# Run setup wizard
chatgpt-escalation-mcp init选项2:从GitHub版本安装
- 从下载最新版本
- 解压缩ZIP文件
- 运行:
cd chatgpt-escalation-mcp
npm install
npm run build
pip install pywinauto pyperclip paddleocr paddlepaddle选项3:从源代码安装
# Clone the repository
git clone https://github.com/Dazlarus/chatgpt-escalation-mcp.git
cd chatgpt-escalation-mcp
# Install Node.js dependencies
npm install
# Build the project
npm run build
# Install Python dependencies
pip install pywinauto pyperclip paddleocr paddlepaddle快速开始
步骤1:安装ChatGPT桌面
winget install --id=9NT1R1C2HH7J --source=msstore --accept-package-agreements --accept-source-agreements或者从微软商店安装:通过OpenAI搜索“ChatGPT”。
步骤2:在ChatGPT中创建对话
- 打开ChatGPT桌面并登录
- 创建新 项目 (文件夹)已调用
Agent Expert Help - 在该项目中,创建一个名为
Copilot Escalations - 发送此初始消息以设置上下文:
You are an expert software architect. I'll send you technical questions from my coding agent (GitHub Copilot, Claude, etc.) when it gets stuck.
For each question:
1. Analyze the problem thoroughly
2. Provide specific, actionable guidance
3. Include code examples when helpful
4. Explain WHY a solution works, not just what to do
The questions will include context about what the agent already tried.步骤3:配置MCP服务器
在以下位置创建配置文件 ~/.chatgpt-escalation/config.json:
# Create config directory
New-Item -ItemType Directory -Path "$env:USERPROFILE\.chatgpt-escalation" -Force
# Create config file (edit the path in notepad)
notepad "$env:USERPROFILE\.chatgpt-escalation\config.json"粘贴此配置:
{
"chatgpt": {
"platform": "win",
"responseTimeout": 600000,
"projects": {
"default": {
"folder": "Agent Expert Help",
"conversation": "Copilot Escalations"
}
}
},
"logging": {
"level": "info"
}
}步骤4:添加到MCP客户端
使用GitHub Copilot获取VS代码 (%APPDATA%\Code\User\mcp.json):
{
"servers": {
"chatgpt-escalation": {
"command": "node",
"args": ["N://AI Projects//chatgpt-escalation-mcp//dist//src//server.js"]
}
}
}适用于克劳德桌面 (%APPDATA%\Claude\claude_desktop_config.json):
{
"mcpServers": {
"chatgpt-escalation": {
"command": "node",
"args": ["C://path//to//chatgpt-escalation-mcp//dist//src//server.js"]
}
}
}⚠️ 使用双正斜杠//在JSON的路径中,或将反斜杠转义为\\\\
第五步:教你的代理人什么时候升级
向您的代理添加升级说明。选择与您的工具匹配的格式:
GitHub Copilot (.github/copilot-instructions.md)
## Expert Escalation Protocol
You have access to the `escalate_to_expert` MCP tool that sends questions to ChatGPT for expert guidance.
### When to Escalate
- You've tried 3+ approaches without success
- The problem requires specialized domain knowledge
- You're unsure if the fundamental approach is correct
- You're hitting consistent failure patterns you can't diagnose
### How to Escalate
Use the `escalate_to_expert` tool with:
- `project`: "default" (or specific project ID)
- `reason`: Why you're stuck (be specific)
- `question`: The technical question
- `attempted`: What you already tried and results
- `artifacts`: Relevant code snippets
### After Escalation
Read the full response before implementing. ChatGPT often provides multiple approaches - pick the most appropriate one for the context.Cline / Roo Code (.clinerules or .roo/rules)
## Expert Escalation Protocol
You have access to the `escalate_to_expert` MCP tool. Use it when stuck.
### Escalation Triggers
1. **Accuracy plateau** - 3+ attempts with no improvement
2. **Consistent failures** - Same error pattern despite different approaches
3. **Domain gap** - Problem needs specialized knowledge you lack
4. **Architecture uncertainty** - Unsure if approach is fundamentally correct
### Before Escalating
Stop and ask the user: "I've tried [X approaches] but I'm hitting [limitation]. Should I escalate to ChatGPT?"
If yes, call `escalate_to_expert` with:
- `project`: "default"
- `reason`: Brief description of why you're stuck
- `question`: Specific technical question
- `attempted`: Numbered list of what you tried and results
- `artifacts`: Relevant code snippets
### Question Format
Structure your question clearly:
- **Problem:** One sentence description
- **Context:** Technical details, frameworks, constraints
- **What I tried:** Numbered list with results
- **Specific questions:** What you need answered
### After Response
1. Read the FULL response before implementing
2. Identify the recommended approach (there may be multiple)
3. Implement incrementally - test each suggestion
4. If unclear, ask user for clarification before proceedingOpenAI Codex CLI (AGENTS.md or instructions)
## Expert Escalation via ChatGPT
The `escalate_to_expert` MCP tool lets you ask ChatGPT for help on complex problems.
### When to Use
- Multiple failed attempts on a problem
- Need domain expertise (ML, systems, security, etc.)
- Debugging issues that don't make sense
- Architecture or design decisions
### Tool Usage升级为专家({ 项目:“默认”, 原因:“阻断剂的简要说明”, 问题:“具体技术问题”, 尝试:“尝试了什么,发生了什么”, 工件:\[{类型:“file_snippet”,路径或标签:“file.py”,内容:“…”}\] })
### Best Practices
- Be specific about what you tried and exact error messages
- Include relevant code snippets in artifacts
- Ask focused questions, not "help me fix this"
- After receiving response, implement suggestions step by stepClaude Desktop / Other MCP Clients
## Expert Escalation Protocol
You have access to the `escalate_to_expert` MCP tool that sends questions to ChatGPT.
### When to Escalate
- Tried 3+ approaches without success
- Problem requires specialized domain knowledge
- Unsure if fundamental approach is correct
- Hitting consistent failure patterns
### Tool Parameters
| Parameter | Required | Description |
|-----------|----------|-------------|
| project | Yes | Project ID (usually "default") |
| reason | Yes | Why you're escalating |
| question | Yes | The technical question |
| attempted | No | What you tried and results |
| artifacts | No | Code snippets [{type, pathOrLabel, content}] |
### After Response
Read fully before implementing. Pick the most appropriate suggestion for the context.升级呼叫示例
{
"project": "default",
"reason": "Authentication flow failing silently, can't identify root cause",
"question": "Why would JWT refresh tokens work in development but fail in production with no error messages?",
"attempted": "1. Checked token expiry (valid), 2. Verified CORS (correct), 3. Tested with Postman (works)",
"artifacts": [{"type": "file_snippet", "pathOrLabel": "auth.ts", "content": "..."}]
}配置参考
配置文件位置: %USERPROFILE%\.chatgpt-escalation\config.json
{
"chatgpt": {
"platform": "win",
"responseTimeout": 120000,
"projects": {
"my-project": {
"folder": "My Project Folder",
"conversation": "Expert Help Chat"
},
"simple-project": "Just a Conversation Title"
}
},
"logging": {
"level": "info"
}
}项目配置
项目可以通过两种方式配置:
简单 (ChatGPT侧栏中的根级别对话):
"project-id": "Conversation Title"带文件夹 (ChatGPT项目文件夹内的对话):
"project-id": {
"folder": "Project Folder Name",
"conversation": "Conversation Title"
}多个项目
您可以将不同的编码项目映射到不同的ChatGPT对话:
"projects": {
"webapp": {
"folder": "Web Projects",
"conversation": "React App Help"
},
"api": {
"folder": "Backend Projects",
"conversation": "API Design Help"
},
"default": "General Coding Help"
}然后,代理可以升级到正确的上下文:
{"project": "webapp", "question": "How to optimize React re-renders?"}
{"project": "api", "question": "Best practices for REST pagination?"}MCP工具参考
escalate_to_expert
通过桌面应用程序向ChatGPT发送问题。
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
project | string | 是 | 配置中的项目ID(使用 list_projects 发现) |
reason | string | 是 | 为什么升级(帮助ChatGPT理解上下文) |
question | string | 是 | 具体的技术问题 |
attempted | string | 否 | 您已经尝试过的内容和结果 |
projectContext | string | 否 | 关于代码库的其他上下文 |
artifacts | array | 否 | 代码片段、日志或注释(见下文) |
工件格式:
{
"type": "file_snippet" | "log" | "note",
"pathOrLabel": "src/auth.ts",
"content": "// the actual code or content"
}list_projects
从配置中查找可用的项目ID。如果你不知道有哪些项目可用,请先调用此命令。
退货:
{
"projects": ["default", "webapp", "api"],
"count": 3
}重要说明
ChatGPT对话设置
为了获得最佳效果,请使用建立专家角色的系统提示启动每个项目的ChatGPT对话:
您是参与此项目的自主编码代理的专用专家升级端点。 您的角色: - 提供清晰、技术正确、易于实施的指导。 - 假设代理人会立即按照您的指示行事。 - 除非绝对必要,否则避免向代理人提出后续问题。 - 简洁、直接、实用。 响应格式: 1. 首先简要解释问题和建议的解决方案。 1. 使用以下格式的严格JSON对象结束每个响应: {\ “指导”:“一句话总结代理人下一步应该做什么”,\ “action_plan”:\[“步骤1”、“步骤2”、“第3步”\],\ “优先级”:“低|中|高”,\ “notes_for_user”:“人类可选消息”\ } 重要规则: - JSON必须是消息中的最终内容。 - 不要将JSON包裹在代码围栏中。 - 不要在JSON后面添加任何注释。 - 不要使用占位符或不完整的结构。 - 始终返回语法有效的JSON。
使用过程中
- 保持ChatGPT桌面安装 (它将自动打开/关闭)
- 不要与ChatGPT交互 在升级过程中
- 根据响应长度,自动化需要约30-120秒
- 当你处于AFK状态或专注于其他任务时,效果最佳
版本兼容性
| ChatGPT桌面版本 | 状态 | 备注 |
|---|---|---|
| 1.2025.112 | ✅ 支持 | 上次测试时间为2025年11月30日 |
| 旧版本 | ⚠️ 未知 | 可能有效,未测试 |
| 未来版本 | ⚠️ 未知 | 如果UI发生重大变化,可能会中断 |
如果ChatGPT更新破坏了自动化, 打开一个问题 使用您的版本号。
升级期间会发生什么
当你的经纪人来电时 escalate_to_expert,服务器重新启动ChatGPT,导航到配置的对话,发送问题,等待完成,复制响应,并返回结构化JSON——与上面的高级流程图相匹配。典型时间: 30-120秒.
有关实现细节(像素检测、OCR、复制逻辑),请参阅 docs/internals-detection.md 和 docs/sidebar-selection.md.
检测内部
寻找低级启发式方法(侧边栏状态、响应生成、复制按钮)?它们记录在以下文件中供贡献者使用:
docs/internals-detection.mddocs/sidebar-selection.md
发展
# Watch mode
npm run dev
# Build
npm run build故障排除
“未找到ChatGPT窗口”
- 确保已安装ChatGPT桌面应用程序
- 自动化将自动启动它
“未找到对话”
- 验证配置中的对话标题是否完全匹配
- 检查项目文件夹名称是否正确
- 对话必须在首次使用前存在
“响应超时”
- 增加
responseTimeout在配置中用于更长的响应 - 检查ChatGPT是否受到速率限制或遇到问题
OCR不工作
# Reinstall PaddleOCR
pip install --upgrade paddleocr paddlepaddleWindows自动化问题
# Reinstall automation dependencies
pip install --upgrade pywinauto pyperclip pywin32日志
日志会写入stderr,MCP客户端可以捕获日志。集 logging.level 到 "debug" 在配置中用于详细输出。
常见驱动程序错误:NoneType window rect
如果您看到以下错误:
TypeError: 'NoneType' object is not subscriptable这通常意味着Python驱动程序无法找到或访问ChatGPT桌面窗口。尝试以下操作:
- 确保ChatGPT桌面已打开且未最小化
- 集
headless到false在您的配置中,如果是true(某些环境会隐藏窗口) - 将ChatGPT桌面移动到主监视器,并确保它不会被其他应用程序遮挡
- 确认对话和文件夹标题与您的配置完全匹配
- 跑
npm run doctor验证配置和依赖关系 - 重新运行MCP烟雾测试:
node tools/mcp_smoke_test.js
如果问题仍然存在,请检查后端日志(stdout/stderr)以获取更多详细信息,并使用日志片段和您的ChatGPT Desktop版本打开问题。
验证检查表
在首次升级之前,请确认:
- \[\]Windows 10或11
- \[\]已安装ChatGPT桌面(Microsoft Store版本)
- \[\]ChatGPT桌面打开,您已登录
- \[\]在ChatGPT中创建了项目文件夹(例如“Agent Expert Help”)
- \[\]在该文件夹中创建了对话(例如,“副驾驶升级”)
- \[\]配置中的对话标题匹配 精确地 (区分大小写)
- \[\]配置文件存在于
%USERPROFILE%\.chatgpt-escalation\config.json - \[\]MCP客户端配置了正确的路径
dist/src/server.js - \[\]已安装Node.js 18+(
node --version) - \[\]已安装Python 3.10+(
python --version) - \[\]已安装Python包(
pip list | findstr pywinauto)
常见问题解答
Can I keep working while it runs?
是的,但是 不与ChatGPT窗口交互自动化控制鼠标/键盘对特定窗口的输入。您可以正常使用其他应用程序。
Can I use this for multiple agents simultaneously?
不,一次只能升级一次。如果您有多个代理,它们将排队并按顺序处理。
Can this escalate to multiple ChatGPT conversations?
对!在配置中配置多个项目,每个项目指向不同的文件夹/对话。您的代理指定要使用的项目。
Will this work on macOS in the future?
不太可能。macOS有不同的自动化API(Accessibility API),需要重新编写完整的驱动程序。Windows专用范围旨在保持项目的可维护性。
Can I use Ollama or a local LLM instead?
不使用此工具,它专门自动化了ChatGPT Desktop应用程序。对于本地LLM,使用不同的MCP服务器直接调用Ollama的API。
How long does an escalation take?
通常为30-120秒:
- 打开ChatGPT并导航大约需要10秒
- ChatGPT生成响应的时间约为5-90s(取决于长度)
- 复制并返回大约需要5秒
The first run is really slow. Why?
PaddleOCR在首次使用时下载其模型文件(约100MB)。后续运行要快得多,模型在后台预加载。
卸载
# Remove config directory
Remove-Item -Recurse -Force "$env:USERPROFILE\.chatgpt-escalation"
# Remove from your MCP client config
# (edit your settings.json or claude_desktop_config.json)
# Optionally uninstall Python dependencies
pip uninstall pywinauto pyperclip paddleocr paddlepaddle安全
这个工具 从不 自动执行ChatGPT桌面窗口之外的任何操作。它从不读取无关的窗口,捕获其他应用程序的屏幕,也不与其他应用程序交互。所有自动化都仅限于ChatGPT进程。
作者
由...创建 达里恩·哈丁 (@Dazlarus)
许可证
麻省理工学院
更新日志
看 更改日志.md 版本历史。
附加文档
- 协议探测器的使用和故障排除:
docs/protocol-probe.md - 侧边栏内部选择和调整:
docs/sidebar-selection.md - 安全护栏和中断恢复:
docs/safety-guardrails.md
混沌/对抗测试
通过在随机窃取焦点、最小化ChatGPT、移动/点击鼠标、打开遮挡窗口和滚动的对手下运行命令来测试安全护栏。
快速命令:
# Run any command with chaos (60s, medium intensity)
npm run chaos --
# Run protocol probe with aggressive chaos (90s)
npm run chaos:probe
# Run full escalation test under chaos (90s, aggressive)
npm run chaos:escalate自定义混沌参数:
# Gentle chaos for 120 seconds
node tools/with_antagonist.js --duration=120 --intensity=gentle -- npm run probe
# Custom duration and intensity for escalation test
node tools/chaos_escalation_test.js --duration=60 --intensity=medium强度:
gentle:中断更少,行动之间的延迟更长medium:平衡(默认)aggressive:严重窃取焦点,频繁最小化/遮挡
对手在做什么:
- 随机移动和点击鼠标
- 将焦点转移到记事本
- 在ChatGPT上打开记事本窗口
- 最小化ChatGPT窗口
- 随机滚动事件
注: 这会故意中断您的桌面会话。在非关键环境或虚拟机上运行。
混沌升级测试(npm run chaos:escalate):
运行完整的端到端测试:
- 启动反派(默认90秒,攻击性)
- 连接到MCP服务器
- 列出项目
- 呼叫
escalate_to_expert带着一道试题 - 验证响应
- 报告通过/失败
这验证了安全护栏在实际升级流程中成功地从中断中恢复。
当前测试结果:
- ✅ 温和的:始终如一地通过
- ✅ 中等:始终如一地通过
- ✅ 激进的:通过重试逻辑(可能需要2-4次尝试)
种子试验:使用 --seed=12345 对于可再现的混沌模式:
node tools/chaos_escalation_test.js aggressive --duration=120 --seed=99999