Remote debugging with authorization in the browser
Published on Updated on 13 min read
Enable Brave remote debugging at brave://inspect/#remote-debugging with an authorization prompt, and connect agents through DevToolsActivePort.
This post follows One browser per profile for AI agents on Hyprland. There I split each Brave profile into its own process, with one CDP port per profile, so AI agents would hit the right browser. That post ended with a warning. The CDP port has no authentication, and any process running as my user could control all three logged-in profiles.
Now the three profiles start without a debugging port. When an agent wants to use the browser, Brave shows an authorization prompt and only allows the connection if I accept.
Quick summary
This guide covers desktop remote debugging over Chrome DevTools Protocol (CDP) at brave://inspect/#remote-debugging. The brave://inspect/#devices page is for inspecting Android tabs over USB and is outside this workflow.
There are two ways to enable CDP in current Brave, depending on what you need. To attach an agent to a running profile with your signed-in sessions, open brave://inspect/#remote-debugging and turn on remote debugging. Brave writes the port and WebSocket path to DevToolsActivePort inside the profile data folder and shows a confirmation prompt for each new connection. That mode exists from Chrome 144 on.
For isolated tests or CLI runs with an open HTTP port from startup, pass a separate --user-data-dir along with --remote-debugging-port=9222:
brave --user-data-dir=/tmp/brave-debug --remote-debugging-port=9222
Since Chromium 136, --remote-debugging-port without --user-data-dir is ignored on the default profile for security, as documented by Chrome for Developers. I did not test that flag against the default Brave profile, to keep my active profiles untouched; the command above, with a disposable --user-data-dir, worked.
I checked all of this on November 19, 2026 on Brave 158.1.100.58 (Chromium 158.0.8127.42), on Linux, in a disposable headless profile. That is why I did not repeat the click on the authorization prompt, and the macOS and Windows details come from the tools’ documentation rather than my own tests. The tool versions mentioned from here on are the ones current on that date: chrome-devtools-mcp 1.13.0, brave-mcp 1.12.0, and chrome-devtools-axi 0.1.46.
How big the problem was
With Brave started with --remote-debugging-port=9222, a curl with no credentials already got an answer:
curl -s http://127.0.0.1:9222/json/version
The response includes the browser WebSocket address. With that address, a script can open tabs, read cookies and run JavaScript on any site where I am logged in. That applies to an AI agent, to a compromised npm package, or to any other program running as my user.
The port only listens on localhost, so nobody outside the machine can reach it. The risk is in the programs already running here.
Chromium remote debugging with authorization
Chromium has a second way to turn on remote debugging, through the chrome://inspect/#remote-debugging page. In Brave the address is brave://inspect/#remote-debugging. The same page exists in Chrome, Edge and Vivaldi, each with its own internal prefix, such as edge://inspect. The option exists from Chrome 144 on. I set up the original workflow on a Chromium 154 build and checked it again on 158.
I turn the option on once per profile. Brave saves the choice in the Local State file of the data folder, so it stays on after restarting the browser:
"devtools": { "remote_debugging": { "user-enabled": true } }
With the option on, the behavior changes in three ways:
- The HTTP discovery endpoints stop answering. The same
curlas before gets a404. - Brave writes the connection address to the
DevToolsActivePortfile inside the profile data folder. - Every new WebSocket connection opens an authorization prompt in the browser.
DevToolsActivePort has two lines, the port and the WebSocket path:
9222
/devtools/browser/0981ab15-ef84-48ba-b46d-30d06ca90cf7
In a standard Brave installation, the data folder that holds Local State and DevToolsActivePort depends on the operating system, according to the brave-devtools-mcp source and docs:
| OS | Default Brave data folder |
|---|---|
| Linux | ~/.config/BraveSoftware/Brave-Browser |
| macOS | ~/Library/Application Support/BraveSoftware/Brave-Browser |
| Windows | %LOCALAPPDATA%\BraveSoftware\Brave-Browser\User Data |
On Linux, Brave also respects XDG_CONFIG_HOME when set. I only reproduced the Linux path locally because my tests ran on Linux; the macOS and Windows paths were not run on this machine. When Brave starts with a custom --user-data-dir, such as my ~/.config/brave-personal, ~/.config/brave-bliss and ~/.config/brave-unicesumar profiles, Local State and DevToolsActivePort sit directly inside that directory.
sequenceDiagram accTitle: An agent connecting to Brave with authorization accDescr: The agent reads DevToolsActivePort in the profile folder, opens the WebSocket and Brave asks for authorization. After I accept, the axi bridge keeps the connection open for the next calls. participant A as Agent participant X as chrome-devtools-axi participant B as Brave personal participant E as Me A->>X: axi-brave personal newpage URL X->>X: reads ~/.config/brave-personal/DevToolsActivePort X->>B: opens ws://127.0.0.1:9222/devtools/browser/ID B->>E: asks for authorization E->>B: allows B-->>X: connection accepted A->>X: next calls X->>B: reuses the same connection
Launchers without a port
The first change was removing the flag from the three scripts in ~/.local/bin:
exec /usr/bin/brave \
--user-data-dir="$HOME/.config/brave-bliss" \
--profile-directory="Profile 1" \
- --remote-debugging-port=9223 \
"$@"
Then I closed the personal Brave, opened it from the launcher and turned the option on at brave://inspect/#remote-debugging. ss showed Brave listening on 9222 without the flag on the command line. The curl on /json/version started getting a 404.
Common authorization and CDP errors
These errors show up whether you use chrome-devtools-mcp, Playwright, or direct CDP scripts, or a wrapper such as chrome-devtools-axi. I reproduced the chrome-devtools-mcp errors on Brave; for chrome-devtools-axi I read src/bridge.ts instead of starting a second bridge.
Could not find DevToolsActivePort for chrome
When you run chrome-devtools-mcp --autoConnect without a profile folder, the server passes Chrome’s default channel to Puppeteer and looks for Google Chrome’s port file:
Could not find DevToolsActivePort for chrome at /home/satin/.config/google-chrome/DevToolsActivePort
I reproduced that failure with chrome-devtools-mcp 1.13.0. To connect to Brave, you have three options. Pass --userDataDir pointing to the Brave profile folder so chrome-devtools-mcp reads DevToolsActivePort directly from there, read the two lines of DevToolsActivePort and connect via --wsEndpoint, or use the brave-mcp fork, which resolves Brave’s default folder per operating system.
On recent macOS versions, the official chrome-devtools-mcp and brave-mcp docs also report Could not find DevToolsActivePort or EPERM: operation not permitted when the terminal or MCP client lacks Files & Folders permission for the browser in system privacy settings. That macOS permission error was not reproduced on this Linux host.
404 on /json/version and 403 on /devtools/page
With brave://inspect/#remote-debugging enabled, legacy CDP clients fail to connect and get 404 on /json/version and /json/list, plus 403 Forbidden when trying to open a WebSocket directly on /devtools/page/<id>. This is expected in authorization mode, and it showed up the same way in my test.
Connections must go through the browser socket at /devtools/browser/<id>, using the port and path recorded in the two lines of DevToolsActivePort. Tools that require --browserUrl over HTTP fail when Brave only has #remote-debugging enabled without --remote-debugging-port.
Repeated authorization prompts and short timeouts
Brave displays the prompt to allow remote debugging on every new WebSocket connection to /devtools/browser/<id>, because approval applies to that open connection rather than being saved globally per client. If a script closes and reopens the WebSocket on every command, the prompt appears every time.
A long-lived connection or a persistent bridge such as chrome-devtools-axi keeps the WebSocket open across calls. Even then, raising the startup timeout helps on the first call, since the bridge’s 30-second default can expire before you spot the dialog and click allow.
Arguments executablePath and browserUrl are mutually exclusive
When I first wired up chrome-devtools-axi, the CLI only returned a generic error because the bridge started with stdio: "ignore" and hid the output from chrome-devtools-mcp:
error: "Bridge for session \"brave-personal\" exited with code 1 before becoming ready on port 9357"
code: BRIDGE_NOT_READY
Running the bridge script in the foreground with the same environment variables exposed the real chrome-devtools-mcp error, which still behaves the same way in 1.13.0:
Arguments executablePath and browserUrl are mutually exclusive
My Omarchy setup has no Chrome installed, so CHROME_DEVTOOLS_AXI_MCP_PATH pointed to a script of mine, mcp-runner.mjs, which added --executablePath with the Brave path. That worked when the axi opened its own browser, then failed when attaching to an open browser because --executablePath conflicts with --browserUrl, --wsEndpoint, and --autoConnect. The runner stopped passing --executablePath in those three cases:
const connectsToExisting = process.argv.slice(2).some(a =>
/^--(browserUrl|wsEndpoint|autoConnect)\b/.test(a));
const args = [
mcpScript,
...(connectsToExisting ? [] : [`--executablePath=${browserPath}`]),
...process.argv.slice(2)
];
At that time, the axi also did not forward CHROME_DEVTOOLS_AXI_USER_DATA_DIR when CHROME_DEVTOOLS_AXI_AUTO_CONNECT=1 was set, and the MCP SDK StdioClientTransport stripped extra environment variables from the child process. On Linux without an explicit environment, the SDK keeps only HOME, LOGNAME, PATH, SHELL, TERM and USER.
In chrome-devtools-axi 0.1.46, upstream now supports CHROME_DEVTOOLS_AXI_USER_DATA_DIR and CHROME_DEVTOOLS_AXI_EXECUTABLE_PATH, and skips --executablePath automatically in AUTO_CONNECT and BROWSER_URL modes. That removes the need for mcp-runner.mjs just to avoid the flag conflict. However, CHROME_DEVTOOLS_AXI_AUTO_CONNECT=1 still sends only --autoConnect without --userDataDir, and buildMcpChildEnv() still filters the child environment down to CHROME_DEVTOOLS_MCP_NO_USAGE_STATISTICS and CI. For custom Brave profile directories, passing the ws:// URL from DevToolsActivePort through CHROME_DEVTOOLS_AXI_BROWSER_URL is still required.
The axi-brave shortcut
So agents would not build the URL by hand, I created ~/.local/bin/axi-brave:
#!/usr/bin/env bash
set -euo pipefail
profile="${1:-}"
case "$profile" in
personal|bliss|unicesumar) shift ;;
*) echo "usage: axi-brave <personal|bliss|unicesumar> <axi command>" >&2; exit 2 ;;
esac
portfile="$HOME/.config/brave-$profile/DevToolsActivePort"
if [[ ! -s "$portfile" ]] || ! pgrep -f -- "--user-data-dir=$HOME/.config/brave-$profile" >/dev/null; then
echo "Brave $profile is closed or has remote debugging off." >&2
exit 3
fi
port=$(sed -n 1p "$portfile"); path=$(sed -n 2p "$portfile")
export CHROME_DEVTOOLS_AXI_SESSION="brave-$profile"
export CHROME_DEVTOOLS_AXI_BROWSER_URL="ws://127.0.0.1:${port}${path}"
export CHROME_DEVTOOLS_AXI_BRIDGE_TIMEOUT_MS="${CHROME_DEVTOOLS_AXI_BRIDGE_TIMEOUT_MS:-120000}"
exec chrome-devtools-axi "$@"
The default bridge timeout is 30 seconds, too short for me to see the prompt and click. The shortcut raises it to 2 minutes.
$ axi-brave personal newpage https://palpitae.com.br/
page:
title: Palpitae | Bolão de futebol online grátis com os amigos
url: "https://palpitae.com.br/"
The first call took 10 seconds, the time it took me to accept the prompt. The bridge keeps the WebSocket open, so the second call answered right away and asked nothing. A new prompt only shows up when the bridge goes idle and closes the connection.
Comparing chrome-devtools-mcp, brave-mcp, and chrome-devtools-axi
The three tools handle Brave connections differently. This table summarizes what each repository documents and ships in the versions listed in the summary:
| Feature | chrome-devtools-mcp |
brave-mcp (brave-devtools-mcp) |
chrome-devtools-axi |
|---|---|---|---|
| Primary role | Official MCP server and chrome-devtools CLI |
Brave fork with feature parity and brave-devtools CLI |
CLI wrapper with a persistent bridge and TOON output over chrome-devtools-mcp |
Native Brave discovery with --autoConnect |
No, looks for Chrome and requires --userDataDir for Brave |
Yes, reads DevToolsActivePort from Brave’s default folder on Linux, macOS, and Windows |
No, CHROME_DEVTOOLS_AXI_AUTO_CONNECT=1 sends only --autoConnect without --userDataDir |
| Direct WebSocket connection | --wsEndpoint |
--wsEndpoint |
CHROME_DEVTOOLS_AXI_BROWSER_URL=ws://... |
| Default usage telemetry | Enabled, opt out with --no-usage-statistics or CHROME_DEVTOOLS_MCP_NO_USAGE_STATISTICS |
Disabled by default, opt in with --usage-statistics |
Forwards CHROME_DEVTOOLS_MCP_NO_USAGE_STATISTICS and CI to the child MCP process |
| Session handling | Direct through the MCP client or CLI | Direct through the MCP client or CLI | Background bridge per CHROME_DEVTOOLS_AXI_SESSION and uid=g<N>:<id> refs |
I only ran chrome-devtools-mcp 1.13.0 live against Brave. Details for brave-mcp come from the triuzzi/brave-devtools-mcp source and docs, and details for chrome-devtools-axi 0.1.46 come from the installed CLI and src/bridge.ts without starting a live bridge during this check.
One rule for every agent
I use Claude Code, Codex, Cursor CLI, OpenCode, Gemini CLI and others. They all read the same instruction file, ~/.agents/CONTEXT.md, through a symlink or an import. The browser rule lives there, and the profile comes from the project folder:
| Project folder | Profile |
|---|---|
~/Work/bliss and work folders |
axi-brave bliss |
~/Work/personal |
axi-brave personal |
~/Work/unicesumar |
axi-brave unicesumar |
| any other folder | the agent asks |
The same rule tells the agent to warn me before the first call and forbids opening a port or restarting the browser on its own.
The browser extension and the axi
The Claude extension for Chrome does not use CDP. It talks to Claude Code through native messaging and already asked for permission per site. Even so, I use the axi for most tasks, for two reasons.
The first is reach. The Claude extension only serves Claude Code, and the ChatGPT one only serves OpenAI products. The axi is a terminal command, and any agent with a shell can call it.
The second is token use. The extension relies a lot on screenshots, and every image goes into the model context. The axi returns compact text, and its screenshot command saves the image to a file. The image only goes into the context if the agent opens the file.
| Browser extension | chrome-devtools-axi |
|
|---|---|---|
| Who can use it | only the vendor’s agent | any agent with a shell |
| Connection | native messaging and account | CDP through DevToolsActivePort |
| Screenshot | comes back as an image in the context | saved to a file |
| DevTools features | console | console, network, performance, Lighthouse |
What stays the same
Authorization protects against a random program trying to use the port without me noticing. It does not create a barrier between processes of the same user. A malicious program running as my user can still read the profile folder on disk. No browser setting fixes that.
The setup also depends on details an update can change. mcp-runner.mjs points to an internal path of chrome-devtools-mcp, and axi-brave reads the current DevToolsActivePort format. If either changes, the axi stops connecting. In both cases the browser does not go back to accepting connections without a prompt.