fix: default pageId routing on for page-scoped tools - #2603
Closed
SomSamantray wants to merge 2 commits into
Closed
Conversation
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
Collaborator
|
Thanks for the PR. This is a duplicate of #1777 and we are working on enabling this by default. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two AI agents sharing one
chrome-devtools-mcpserver could silently act on the wrong browser tab: every page-scoped tool call operated on whatever page was "selected" server-side, so a concurrentselect_pagefrom one agent could redirect the next tool call from a different agent onto the wrong tab. A--experimentalPageIdRoutingflag 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:
pageIdis now accepted on every page-scoped tool without any flag, while a caller that never mentionspageIdsees no change in behavior.--no-experimentalPageIdRoutingand--slimstill 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
pageIdschema field was required rather than optional, which would have broken every ordinary tool call that omitspageIdonce the flag defaulted on; andevaluate_script's own independent page-resolution branch didn't guard against an omittedpageIdor respect--slim, unlike the generic page-scoped path.Fixes #1245
Test plan
--slimand--no-experimentalPageIdRoutingopt-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 typecheckand 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.