如何讓編碼智能體使用已登入的 Chrome(2026)
How to Let Your Coding Agent Use Your Logged-In Chrome (2026)
文章整理讓編碼智能體連接已登入 Chrome 的方法,包括以瀏覽器擴充功能連接分頁,或啟用遠端除錯連接正在使用的 Chrome。
To let a coding agent work in your real, signed-in Chrome, install a browser extension that hands it tabs, or turn on Chrome's remote debugging toggle so a tool can attach to the Chrome you already have open. On Claude Code with a paid Claude plan, Claude in Chrome (claude --chrome) is the shortest path; the list below gives the pick for every other agent and login.
We make Browser Use and Browser Harness. Everything about the other tools comes from their own docs and READMEs, checked October 25, 2026, and linked where I use it.
Which one fits your agent
- Claude Code: Claude in Chrome if you sign in with a Pro, Max, Team or Enterprise plan. On an API key, Bedrock or another provider it stays off, so use Browser Harness, Playwright MCP's extension mode or Chrome DevTools MCP.
- Codex: in the ChatGPT desktop app, OpenAI's browser extension. In Codex CLI, Browser Harness or one of the two MCP servers.
- Gemini CLI: its built-in browser agent with
sessionModeset to"existing", or any of the MCP options. - Cursor: its built-in Browser keeps its own cookies per workspace, not your Chrome logins. For your Chrome, add Browser Harness, Playwright MCP or Chrome DevTools MCP to
.cursor/mcp.json. - Any MCP client: Playwright MCP in extension mode gives the agent tabs you pick. Chrome DevTools MCP in auto-connect mode or our Browser Harness give it your whole running Chrome.
Why not copy your cookies into a fresh browser?
Because a fresh automation browser is a different device. You can export cookies and load them, for example with Playwright MCP's --storage-state, which loads cookies and local storage from a file into an isolated browser context (README). It works on some sites and can fail on sites that tie sessions to your device or ask you to sign in again:
- Sessions bound to your device. With Device Bound Session Credentials, Chrome keeps a private key in secure hardware such as a TPM, and when a site's short-lived session cookies expire, Chrome refreshes them only by proving it has that key. On sites that use it, copied cookies expire and can't be renewed on another machine.
- Signing in again. A fresh profile starts logged out of everything, so you redo every login and second factor there. The Chrome DevTools MCP docs note that some accounts may prevent sign-in when the browser is controlled through WebDriver (Chrome DevTools MCP docs).
- The old shortcut is closed. From Chrome 136,
--remote-debugging-portand--remote-debugging-pipeare ignored on your default Chrome data directory; they need--user-data-dirpointing somewhere else. Google made the change because attackers were using remote debugging to pull cookies out of Chrome (Chrome blog, March 17, 2025).
Every option below works in your real browser instead, so your logins, device checks and second factors stay where they are.
1. Claude in Chrome
Anthropic's Chrome extension, which Claude Code connects to from the CLI or the VS Code extension (docs).
- Works with: Claude Code only.
- Setup: install the Claude in Chrome extension (version 1.0.36 or later), sign in to Claude Code with
/login, then runclaude --chrome. Run/chrometo check the connection or turn it on by default. - Your Chrome? Yes. Claude opens new tabs in a tab group, shares your browser's login state and works in a visible window. The docs list Google Chrome and Microsoft Edge, and say Claude Code also sets up Brave, Arc, Vivaldi and Opera.
- Limits: needs a direct Anthropic plan (Pro, Max, Team or Enterprise). It stays off with an API key or a
claude setup-tokentoken, through Amazon Bedrock, Google Cloud's Agent Platform or Microsoft Foundry, and in WSL. It pauses at login pages and CAPTCHAs for you to handle. Site permissions come from the extension's settings.
I'd use it if you only use Claude Code and already pay for a Claude plan. See also our Claude in Chrome page.
2. Playwright MCP, extension mode
Microsoft's Playwright MCP server normally launches its own browser with a persistent profile per workspace. Its --extension flag connects it to your running Chrome or Edge through the Playwright Extension instead (extension README).
- Works with: any MCP client, including Claude Code, Codex, Gemini CLI and Cursor.
- Setup: install the Playwright Extension, then add the server with
--extension:
{
"mcpServers": {
"playwright-extension": {
"command": "npx",
"args": ["@playwright/mcp@latest", "--extension"]
}
}
}- Your Chrome? Yes, in tabs you choose. The first time the agent uses the browser, a page opens where you pick the tab it connects to. Several clients can connect at once; each gets its own tab group and only sees the tabs in it.
- Limits: you approve each connection unless you copy the
PLAYWRIGHT_MCP_EXTENSION_TOKENfrom the extension into the server'senv. If the extension is in several Chrome profiles, it connects to the one you used last;--profile-dir-namepicks one. Chrome or Edge only.
I'd use it when you want the agent kept to specific tabs. Free, Apache-2.0. Our Playwright MCP comparison has more.
3. Chrome DevTools MCP, auto-connect mode
Google's Chrome DevTools MCP is built around debugging: performance traces, network requests, console messages. By default it starts a new Chrome with a dedicated profile. On Chrome 144 or later, --autoConnect attaches it to the Chrome you already run (advanced usage, Chrome blog).
- Works with: any MCP client.
- Setup: open
chrome://inspect/#remote-debuggingin Chrome and turn on remote debugging, then add the server with--autoConnect:
{
"mcpServers": {
"chrome-devtools": {
"command": "npx",
"args": ["chrome-devtools-mcp@latest", "--autoConnect"]
}
}
}- Your Chrome? Yes. Chrome shows a dialog asking you to allow the session, then the "Chrome is being controlled by automated test software" banner while it runs. With several profiles open it connects to Chrome's default one and sees every open window of that profile.
- Limits: you start Chrome yourself. The older route,
--browser-url=http://127.0.0.1:9222, needs Chrome launched with--remote-debugging-portand a separate--user-data-dir, so it is a separate profile, not your everyday one. Google collects usage statistics by default;--no-usage-statisticsturns that off.
I'd use it when the job is debugging your own app with your logins. Free, Apache-2.0. Our Chrome DevTools MCP comparison has more.
4. Gemini CLI's browser agent
Gemini CLI ships a browser subagent that runs a bundled Chrome DevTools MCP (docs).
- Works with: Gemini CLI.
- Setup: it is off by default. Enable remote debugging at
chrome://inspect/#remote-debugging(Chrome 144 or later), then turn the agent on insettings.jsonwith the session mode set to"existing":
{
"agents": {
"overrides": { "browser_agent": { "enabled": true } },
"browser": { "sessionMode": "existing" }
}
}- Your Chrome? Only with
"existing", which attaches to your running Chrome. The default,"persistent", launches Chrome with its own profile in~/.gemini/cli-browser-profile/. - Limits: form filling always asks for confirmation.
allowedDomainslimits where it can go, andmaxActionsPerTaskstops it after 100 tool calls by default. It shows a consent dialog the first time.
I'd use it if Gemini CLI is your agent: nothing extra to install. Our Gemini browser page lists the other options.
5. Codex in the ChatGPT desktop app
OpenAI's ChatGPT browser extension lets Codex and Work chats in the ChatGPT desktop app use your Chrome, Edge, Brave, Opera or Vivaldi.
- Works with: Codex in the ChatGPT desktop app. The docs only describe the desktop app; Codex CLI isn't mentioned.
- Setup: in the desktop app, open Settings > Computer Use, select Install next to your browser, then pick the browser with an @-mention in a chat.
- Your Chrome? Yes, the browser profile where you installed the extension, so it can act on sites you're signed in to.
- Limits: by default it asks before it acts on each new website. You can allow once, for that site, or for all sites, which OpenAI labels Elevated Risk.
For Codex CLI, use Browser Harness or one of the MCP servers. Our Codex browser page has the setup lines.
6. Browser Harness
Our open-source tool (GitHub, MIT). It attaches to the Chrome you have open over the Chrome DevTools Protocol. How the agent uses it depends on the agent:
- Works with: Claude Code and Codex run it as a command-line tool with its skill, and there the agent writes any helper it is missing as it works. Cursor and other MCP clients, such as Gemini CLI, use
browser-harness-mcp, which gives them a fixed set ofbrowser_*tools (MCP docs). - Setup: paste the setup prompt from the README into your agent. It installs Browser Harness with
uv, registers the skill and openschrome://inspect/#remote-debugging, where you tick "Allow remote debugging for this browser instance" once (install.md). Then Chrome asks you to Allow the connection. - Your Chrome? Yes, the whole running browser, with your tabs and logins. The tab it controls gets a horse emoji at the start of its title, and it works in the background so your visible tab stays yours.
- Limits: it sees your whole Chrome, not a chosen tab or site. It needs Chrome 144 or later for the toggle. Local recordings are off unless you say yes during setup. The command-line tool sends usage telemetry by default, including the code the agent pipes to it and what that code prints;
browser-harness telemetry disableturns it off (telemetry code, install.md).
I'd use it when you want one tool you can use from Claude Code, Codex, Gemini CLI and Cursor, on any plan or API key. Product page: Browser Harness.
Side by side
| Option | Agents | Your real signed-in Chrome? | Setup | Cost, license | Notes |
|---|---|---|---|---|---|
| Claude in Chrome | Claude Code | Yes, in a tab group it opens | Extension, then claude --chrome | Needs a Pro, Max, Team or Enterprise plan | Off with API keys, Bedrock, Google Cloud, Foundry and WSL; pauses at logins and CAPTCHAs |
| Playwright MCP, extension mode | Any MCP client | Yes, tabs you pick | Playwright Extension plus the extension flag | Free, Apache-2.0 | Approve each connection unless you set the extension token; Chrome or Edge |
| Chrome DevTools MCP | Any MCP client | Yes in auto-connect mode; its own profile by default | Chrome's remote debugging toggle plus the auto-connect flag | Free, Apache-2.0 | Chrome 144+; Allow dialog; usage statistics on by default |
| Gemini CLI browser agent | Gemini CLI | Yes in "existing" session mode; its own profile by default | Settings file plus Chrome's remote debugging toggle | Built into Gemini CLI, Apache-2.0 | Chrome 144+; form filling always asks first |
| ChatGPT browser extension | Codex in the ChatGPT desktop app | Yes, the profile with the extension | Settings, Computer Use, Install | Plan not stated in the docs | Asks before each new site; Codex CLI not covered |
| Browser Harness (ours) | Claude Code, Codex; Cursor, Gemini CLI and other MCP clients via MCP | Yes, the whole browser | Setup prompt (or MCP config) plus Chrome's remote debugging toggle | Free, MIT | Chrome 144+; Allow dialog; usage telemetry on by default, one command turns it off; agent writes missing helpers in CLI mode |
| Copied cookies | Any | No, a fresh browser | Export cookies, then load them into a new browser | Free | Device-bound sessions can't be refreshed; you redo logins elsewhere |
Quick setup by agent
These combine each tool's documented flags with each agent's documented MCP syntax. In Claude Code and Codex, everything after -- is passed to the server.
Claude Code (MCP docs)
claude --chrome
claude mcp add playwright-extension -- npx @playwright/mcp@latest --extension
claude mcp add chrome-devtools --scope user -- npx chrome-devtools-mcp@latest --autoConnectFor Browser Harness, paste the setup prompt. Our docs' Claude Code tutorial sets up the Browser Use CLI instead, which is built on Browser Harness and also drives your signed-in Chrome. /claude-code-browser compares the options.
Codex CLI (MCP docs)
codex mcp add playwright-extension -- npx @playwright/mcp@latest --extension
codex mcp add chrome-devtools -- npx chrome-devtools-mcp@latest --autoConnectFor Browser Harness, paste the same setup prompt into Codex.
Gemini CLI (MCP docs)
Use the built-in browser agent with "sessionMode": "existing" from section 4, or add Browser Harness through its MCP server:
gemini mcp add browser-harness uvx -- --from "browser-harness[mcp]" browser-harness-mcpThe Playwright and Chrome DevTools JSON blocks above go under mcpServers in settings.json as they are.
Cursor (MCP docs)
Add one of the JSON blocks above, or Browser Harness, under mcpServers in .cursor/mcp.json (or ~/.cursor/mcp.json for every project):
{
"mcpServers": {
"browser-harness": {
"type": "stdio",
"command": "uvx",
"args": ["--from", "browser-harness[mcp]", "browser-harness-mcp"]
}
}
}Cursor's built-in Browser needs no setup for your own app on localhost, but it keeps its own cookies per workspace, not your Chrome's. More in /cursor-browser.
Safety
An agent in your signed-in browser can do anything you can: send email, change settings, buy things. The vendors say so plainly.
- Prompt injection is the main risk. Anthropic calls it "the biggest risk facing browser-using AI tools": instructions hidden in a page, email or document can trick the agent into actions you didn't ask for, such as sending your data somewhere. With Claude Opus 4.8 and its current defenses, attack success was under 0.08% in Anthropic's internal testing, and it says the risk is still not zero (Anthropic). OpenAI tells you to treat page content as untrusted and not to send secrets through browser tasks unless you have to (OpenAI).
- Use a separate Chrome profile when you can. Anthropic recommends a separate browser profile without access to sensitive accounts such as banking, healthcare and government. With an extension, install it only in that profile; Playwright MCP's
--profile-dir-namepicks which profile it connects to. Tools that attach to the whole browser, like Chrome DevTools MCP and Browser Harness, see what that Chrome has open, so keep the sensitive accounts in a Chrome you don't attach to. - Know what the agent can reach. Chrome DevTools MCP warns that it exposes the browser's content to your MCP client (README). For the manual setup, where you start Chrome with
--remote-debugging-port, it warns that any application on your machine can connect to that port and control the browser (advanced usage). The Chrome 144+ toggle used by auto-connect mode, Gemini CLI's"existing"mode and Browser Harness instead shows a dialog asking you to Allow each connection (Chrome blog, December 11, 2025). Either way, turn remote debugging off when you're done. - Review actions on email and payment sites. Keep approval prompts on for anything that sends, pays or deletes. Claude in Chrome asks before it uses financial sites, the ChatGPT extension asks before each new site, and Gemini CLI asks before every form fill.
More
- Our open-source Python library can launch Chrome with a copy of one of your Chrome profiles (Real Browser docs). Because it is a copy in a new browser, the device-bound-session caveats above apply.
- Per-agent pages: Claude Code, Claude in Chrome, Codex, Gemini CLI, Cursor.
- Every browser MCP server for coding agents, with our matched eval: The Best MCP Servers to Control a Browser.
來源:Browser Use · browser-use.com