Skip to content

fix: enable extensions when connecting to existing Chrome - #1171

Closed
luisnomad wants to merge 2 commits into
ChromeDevTools:mainfrom
luisnomad:codex/enable-extensions-existing-chrome
Closed

luisnomad wants to merge 2 commits into
ChromeDevTools:mainfrom
luisnomad:codex/enable-extensions-existing-chrome

Conversation

@luisnomad

Copy link
Copy Markdown

Summary

  • pass enableExtensions through the connected-browser path for --browserUrl, --wsEndpoint, and --autoConnect
  • extract browser resolution into a small helper so the attach-vs-launch wiring is testable
  • document that --category-extensions applies when connecting to an existing Chrome instance

Testing

  • npm run build
  • node scripts/test.mjs tests/index.test.ts tests/resolveBrowser.test.ts

@zyzyzyryxy

Copy link
Copy Markdown
Contributor

Thank you for your contribution.

Please submit an issue describing your use case before we can act on your PR. Specifically let us know if you think you are addressing a bug or implementing a new feature.

@luisnomad

Copy link
Copy Markdown
Author

Thanks. I believe this PR is fixing a bug rather than adding a new feature. Extension-related behavior already exists in the server, and ensureBrowserConnected() already accepts enableExtensions, but the connected-browser path in createMcpServer() was not passing categoryExtensions through.

The result is that extension pages/service workers are not exposed consistently when attaching to an existing Chrome instance via --browserUrl, --wsEndpoint, or --autoConnect, even though the launched-browser path already supports that mode.

I think #1072 is the closest existing issue for this area. My use case is attaching to an already-running Chrome profile and inspecting extension contexts there, rather than launching a separate isolated browser. If you’d prefer a dedicated bug issue for this narrower case, I can open one and link it here.

@luisnomad

Copy link
Copy Markdown
Author

Follow-up: I think #1072 is only adjacent context and not the exact issue this PR addresses. I opened #1173 to track the specific bug here: --category-extensions is not applied on the connected-browser path even though launch-mode already supports it and ensureBrowserConnected() already accepts enableExtensions.

I think #1173 is the better issue to associate with this PR.

@luisnomad

Copy link
Copy Markdown
Author

Follow-up: I updated #1173 to reflect the maintainer guidance that the current behavior is intentional and that this should be discussed as a feature request rather than a bug.

With that framing, this PR should be read as a prototype for a narrower feature: exposing extension pages/service workers in attached-browser mode, not enabling the full extension-management toolset over WebSocket-based attach flows. If that narrower direction is acceptable, I can rework the PR around that supported subset.

@zyzyzyryxy
zyzyzyryxy requested a review from nroscino March 16, 2026 12:29
@OrKoN

OrKoN commented Apr 2, 2026

Copy link
Copy Markdown
Collaborator

Thanks for the PR but we already have extension implementation in progress. Stay tuned!

@OrKoN OrKoN closed this Apr 2, 2026
github-actions Bot pushed a commit to lmn451/chrome-devtools-mcp that referenced this pull request Oct 13, 2026
…romeDevTools#3047)

Fixes ChromeDevTools#3046.

Split out of ChromeDevTools#3041 at the reviewer's request. This is the target-filter
half; ChromeDevTools#3041 keeps the config change.

`BrowserManager#connect()`, used for `--browserUrl`, `--wsEndpoint` and
`--autoConnect`, built Puppeteer's target filter with
`makeTargetFilter()` and no argument. So Puppeteer dropped every
`chrome-extension://` target at connect time, and `list_pages` never
showed extension pages or service workers when attached, even with
`--categoryExtensions`. `#launch()` already passes the flag. This passes
it the same way in `#connect()`.

The omission dates from ChromeDevTools#1922, whose attach call site didn't pass the
flag (see ChromeDevTools#1171 and ChromeDevTools#1173). ChromeDevTools#2787 carried it into `BrowserManager`.

## Changes

- `src/BrowserManager.ts`: read `categoryExtensions` from the server
args in `#connect()` and pass it to `makeTargetFilter()`.
- `tests/browser.test.ts`: two tests that connect with `browserUrl` and
check the `targetFilter` handed to `puppeteer.connect`. A
`chrome-extension://` target is kept only when `categoryExtensions` is
set. The `true` case fails without the `BrowserManager` change.

With the flag off, behaviour is unchanged: `undefined` falls back to
`makeTargetFilter`'s `false` default.

## Note on reachability

On `main`, `--categoryExtensions` with an attach flag is currently
rejected at startup (ChromeDevTools#2989, lifted in ChromeDevTools#3041). So this path can't be
reached from the command line on `main` until ChromeDevTools#3041 lands. The unit
tests reach it directly. Landing this first means ChromeDevTools#3041 doesn't expose
an attach mode with hidden extension pages.

## Testing

- `npm run gen` (no changes) and `npm run check-format`: clean.
- `node scripts/test.js tests/browser.test.ts tests/cli.test.ts`: all
pass.
- Manual, on Windows with Chrome 154.0.8037.98, a tab open on an
unpacked MV3 extension's page: the same change applied on top of 1.10.1,
started with `--browserUrl http://127.0.0.1:<port>
--categoryExtensions=true`. `list_pages` lists the tab under `##
Extension Pages`. Unpatched 1.10.1 and 1.9.0 list no extension pages.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Nicholas Roscino <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants