Chrome无痕,Codex也能接管? | Chrome Incognito, Now Codex-Controllable?
真正有意思的是:AI 不需要“打开一个浏览器”,它可以直接接管已经存在的页面。只要那个 Chrome 可调试,Codex 就能列出页面、选择页面、导航、点击、输入、截图。换句话说,你负责把门打开,AI 负责进门——有点像谈恋爱,但千万别把钥匙给错人。
The interesting part is that AI does not necessarily need to launch a new browser. If Chrome is debuggable, Codex can work with pages that are already open: list them, select one, navigate, click, type, and take screenshots. You open the door; the AI walks in. Just make sure you gave the key to the right guest.
正确玩法 | The Correct Setup
第 0 步:检查环境 | Step 0: Check the Environment
Node.js 必须至少是 22.12.0,并确认已经安装正式版 Google Chrome。
Node.js must be at least 22.12.0, and the official Google Chrome build should be installed.
node --version # 必须 ≥ 22.12.0,不够先 brew install node
第 1 步:启动真正的无痕 Chrome | Step 1: Launch Real Incognito Chrome
核心就是这一招:独立临时 profile + --incognito + 调试端口。
The key combination is: isolated temporary profile + --incognito + remote debugging.
# 清掉可能残留的旧调试实例,避免 profile 锁死
pkill -f "remote-debugging-port=9222"; sleep 2
# 无痕 + 独立临时 profile + 调试端口启动
open -na "Google Chrome" --args \
--remote-debugging-port=9222 \
--user-data-dir=/tmp/chrome-mcp-incognito \
--incognito --new-window
你会看到一个独立的无痕 Chrome。--user-data-dir 又把它和你的正常 Chrome profile 隔开,相当于给 AI 准备了一间临时酒店房间,而不是把你家钥匙直接塞给它。
You will see a separate Incognito Chrome window. The temporary --user-data-dir further separates it from your normal Chrome profile—basically a disposable hotel room instead of handing an AI the keys to your house.
第 2 步:让 MCP 接管 | Step 2: Let MCP Connect
# 若之前加过,先删
codex mcp remove chrome-devtools
# 连接模式添加(不再让 MCP 自己启动 Chrome)
codex mcp add chrome-devtools -- npx chrome-devtools-mcp@latest --browser-url=http://127.0.0.1:9222
# 验证
codex mcp list
官方文档明确支持这种“先启动 Chrome,再通过 --browser-url 连接”的方式。(GitHub)
The official documentation explicitly supports this “launch Chrome first, then connect via --browser-url” workflow. (GitHub)
第 3 步:让 Codex 操作现有页面 | Step 3: Operate the Existing Page
codex
然后告诉 Codex:
Then tell Codex:
用 chrome-devtools 工具:不要新建页面,列出当前已打开的页面并选中它,
导航到 https://www.google.com,在搜索框输入"今天印度最高气温"并回车,
等待结果加载后截图,并总结页面显示的气温。
这里有一个小暗坑:让 Codex 使用 list_pages + select_page,不要随便 new_page。 你既然费劲把 AI 送进无痕房间,就别让它自己跑隔壁开新房。
There is one important trap: tell Codex to use list_pages + select_page rather than casually creating a new page. If you went through all this trouble to put the agent in the Incognito room, don’t let it wander into another room.
Part 3:关掉它其实很简单 | Part 3: Shutting It Down
正常情况下,直接关闭这个 Chrome 就行,⌘Q 退出即可。9222 端口会随着对应进程结束而释放。
Normally, simply closing that Chrome is enough. Press ⌘Q; once the process exits, port 9222 is released.
如果你想确认“尸体真的凉透了”,可以:
If you want to make absolutely sure nothing remains:
# 1. 杀掉所有带该调试端口的 Chrome 进程
pkill -f "remote-debugging-port=9222"
# 2. 确认端口已释放(无输出 = 干净)
lsof -i :9222
# 3. (可选)清掉临时 profile 目录,不留任何痕迹
rm -rf /tmp/chrome-mcp-incognito
/tmp/chrome-mcp-incognito 里可能还有少量实例文件,所以最后 rm -rf 可以把临时目录也清掉。
The temporary profile may contain a few instance-level files, so rm -rf removes that temporary directory too.
Part 4:已经打开的无痕页面,能不能直接接管? | Part 4: Can Codex Control an Existing Incognito Page?
Y,但前提是 Chrome 可调试。
Yes—but Chrome must be debuggable.
如果这个无痕 Chrome 是用 --remote-debugging-port=9222 启动的,MCP 可以直接连接并操作已经打开的页面。
If the Incognito Chrome was launched with --remote-debugging-port=9222, MCP can connect and operate its existing pages.
如果 Chrome 144+ 正常运行,也可以在 chrome://inspect/#remote-debugging 开启 Remote Debugging,再使用:
For Chrome 144+, you can also enable Remote Debugging at chrome://inspect/#remote-debugging and use:
codex mcp remove chrome-devtools
codex mcp add chrome-devtools -- npx chrome-devtools-mcp@latest --autoConnect
这是 Chrome 官方现在提供的自动连接路线。(Chrome for Developers)
This is the current automatic-connection path documented by Chrome. (Chrome for Developers)
但别把 autoConnect 当成魔法。它要求 Chrome 144+,而且连接现有浏览器意味着 Agent 可能继承现有登录状态、Cookie 和会话,因此只应该给你信任的 Agent 使用。(Chrome for Developers)
But don’t treat autoConnect like magic. It requires Chrome 144+, and connecting to an existing browser can expose active sessions, cookies, and logged-in accounts to the agent. Use it only with agents you trust. (Chrome for Developers)
Part 5:ChatGPT App 为什么不一样? | Part 5: Why the ChatGPT App Is Different
ChatGPT App 可以控制浏览器,但它内置的是自己的浏览器状态,不等于“启动你的 Chrome 无痕窗口”。如果你必须要字面意义上的 Chrome Incognito,CLI + Chrome DevTools MCP 才是更直接的路线。
The ChatGPT App can control a browser, but its built-in browser state is not the same thing as launching your Chrome Incognito window. If your requirement is literally Chrome Incognito, the CLI + Chrome DevTools MCP route is the direct solution.
所以最终答案非常简单:
So the final verdict is brutally simple:
需求 Requirement Codex CLI ChatGPT App
控制浏览器 ✅ Y ✅ Y
控制已存在页面 ✅ Y ✅ Y
真 Chrome Incognito ✅ Y ❌ N
--browser-url 连接 ✅ Y 不适用
--autoConnect ✅ Chrome 144+ 不适用
说白了:App 是“AI 自己有间房”;CLI 是“你指定一间无痕房,让 AI 进去干活”。 后者才真正满足这个需求。
In short: the App gives the AI its own room; CLI lets you choose a specific Incognito room and send the AI inside. For strict Chrome Incognito requirements, the latter wins.
上一轮最大的错误,就是把“Chrome DevTools MCP 能控制 Chrome”和“Chrome DevTools MCP 自带无痕参数”混成了一件事。实际上,MCP 的官方配置重点是连接方式;真正的 Incognito 由 Chrome 的启动参数负责。官方文档目前列出的连接参数包括 --autoConnect、--browser-url 和 --ws-endpoint。(GitHub)
The biggest mistake in the previous version was confusing “Chrome DevTools MCP can control Chrome” with “Chrome DevTools MCP itself provides an Incognito flag.” They are different things. MCP handles the connection; Chrome handles Incognito. The current official configuration includes --autoConnect, --browser-url, and --ws-endpoint. (GitHub)
相关链接(Related Links):
https://openai.com/codex/
https://github.com/openai/codex
https://github.com/ggml-org/llama.cpp
https://huggingface.co/ggml-org/gpt-oss-20b-GGUF
https://huggingface.co/unsloth/gpt-oss-20b-GGUF
https://github.com/router-for-me/CLIProxyAPI
https://help.router-for.me/
https://help.router-for.me/agent-client/codex
https://ccswitch.io/
https://github.com/farion1231/cc-switch
https://huggingface.co/models?library=gguf
评论
发表评论