Skip to content

fix: default pageId routing on for page-scoped tools - #2603

Closed
SomSamantray wants to merge 2 commits into
ChromeDevTools:mainfrom
SomSamantray:fix/default-page-id-routing
Closed

fix: default pageId routing on for page-scoped tools#2603
SomSamantray wants to merge 2 commits into
ChromeDevTools:mainfrom
SomSamantray:fix/default-page-id-routing

Conversation

@SomSamantray

Copy link
Copy Markdown

Two AI agents sharing one chrome-devtools-mcp server could silently act on the wrong browser tab: every page-scoped tool call operated on whatever page was "selected" server-side, so a concurrent select_page from one agent could redirect the next tool call from a different agent onto the wrong tab. A --experimentalPageIdRouting flag already existed to fix this by letting a call target its page explicitly, but it was opt-in and essentially unused in practice.

This makes that routing the default: pageId is now accepted on every page-scoped tool without any flag, while a caller that never mentions pageId sees no change in behavior. --no-experimentalPageIdRouting and --slim still force selected-page-only routing for anyone who wants the old strict semantics.

Two related gaps surfaced while implementing the default flip and are fixed alongside it: the merged pageId schema field was required rather than optional, which would have broken every ordinary tool call that omits pageId once the flag defaulted on; and evaluate_script's own independent page-resolution branch didn't guard against an omitted pageId or respect --slim, unlike the generic page-scoped path.

Fixes #1245

Test plan

  • Added/updated tests covering the new default, the --slim and --no-experimentalPageIdRouting opt-outs, and a regression test proving a page-scoped action's emulation settings (CPU throttling, network conditions) stay scoped to the page it actually targets rather than leaking from whichever page happens to be globally selected.
  • npm run typecheck and the full touched test files (tests/cli.test.ts, tests/ToolHandler.test.ts, tests/McpContext.test.ts, tests/tools/script.test.ts) pass locally against a real headless Chromium.

Makes pageId routing the default for page-scoped MCP tools instead of
requiring the --experimentalPageIdRouting opt-in flag, so concurrent
agents sharing one server session stop racing on the shared selected
page between select_page and the next tool call.

- Flip experimentalPageIdRouting's default to true; --no-experimentalPageIdRouting
  and --slim still force selected-page-only routing.
- Make the merged pageId schema field optional so callers that omit it
  keep working exactly as before.
- Fix evaluate_script's independent pageId handling to match: it had its
  own resolution branch that (a) didn't guard against pageId being
  omitted, which would throw once the flag defaulted on, and (b) didn't
  respect --slim.
- Update README docs describing the new default and opt-out.

Fixes ChromeDevTools#1245
@OrKoN

OrKoN commented Aug 21, 2026

Copy link
Copy Markdown
Collaborator

Thanks for the PR. This is a duplicate of #1777 and we are working on enabling this by default.

@OrKoN OrKoN closed this Aug 21, 2026
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.

Make pageId routing default to prevent multi-agent race conditions

2 participants