Skip to content

feat: make pageId routing always-on#1777

Open
bcfmtolgahan wants to merge 1 commit into
ChromeDevTools:mainfrom
bcfmtolgahan:feat/pageid-routing-always-on
Open

feat: make pageId routing always-on#1777
bcfmtolgahan wants to merge 1 commit into
ChromeDevTools:mainfrom
bcfmtolgahan:feat/pageid-routing-always-on

Conversation

@bcfmtolgahan
Copy link
Copy Markdown
Contributor

Splits out from #1244 per review feedback.

Removes the experimentalPageIdRouting flag — pageId is now always
exposed on page-scoped tools. The flag is kept as a no-op for backwards
compatibility.

@bcfmtolgahan bcfmtolgahan force-pushed the feat/pageid-routing-always-on branch from cceb6af to 394fbd2 Compare March 31, 2026 13:19
Comment thread src/bin/chrome-devtools-mcp-cli-options.ts Outdated
@OrKoN
Copy link
Copy Markdown
Collaborator

OrKoN commented Apr 1, 2026

TODO: this cannot land before the fixes to the wait helpers are made to correctly operate on the specified page.

@OrKoN
Copy link
Copy Markdown
Collaborator

OrKoN commented Apr 1, 2026

TODO: evaluate that the model uses pageId correctly via eval scenarios in https://github.com/ChromeDevTools/chrome-devtools-mcp/tree/main/scripts/eval_scenarios

github-merge-queue Bot pushed a commit that referenced this pull request Apr 1, 2026
Splits out from #1244 per review feedback.

'waitForEventsAfterAction' previously lived in 'McpContext' and always
used the selected page's CPU/network throttling settings. With pageId
routing, a tool can target a different page than the selected one,
meaning wrong throttling multipliers were applied.

Moving the method to 'McpPage' fixes this: each tool now calls
'page.waitForEventsAfterAction(...)' and gets the correct page's
emulation settings.

'getNetworkMultiplierFromString' is extracted to 'WaitForHelper.ts' to
avoid a circular import (McpContext → McpPage already exists).

Unblocks #1777.
wolfib pushed a commit that referenced this pull request Apr 1, 2026
Splits out from #1244 per review feedback.

'waitForEventsAfterAction' previously lived in 'McpContext' and always
used the selected page's CPU/network throttling settings. With pageId
routing, a tool can target a different page than the selected one,
meaning wrong throttling multipliers were applied.

Moving the method to 'McpPage' fixes this: each tool now calls
'page.waitForEventsAfterAction(...)' and gets the correct page's
emulation settings.

'getNetworkMultiplierFromString' is extracted to 'WaitForHelper.ts' to
avoid a circular import (McpContext → McpPage already exists).

Unblocks #1777.
@OrKoN
Copy link
Copy Markdown
Collaborator

OrKoN commented May 11, 2026

@bcfmtolgahan would you be up to rebasing this PR?

@bcfmtolgahan bcfmtolgahan force-pushed the feat/pageid-routing-always-on branch from 5f96b59 to 7bb6554 Compare May 14, 2026 11:28
@bcfmtolgahan
Copy link
Copy Markdown
Contributor Author

@OrKoN rebased onto latest main. Adapted to the new 'ToolHandler.ts', location for schema injection and routing. Squashed to a single commit since the changes got intertwined during the adaptation, happy to split if preferred.

@OrKoN OrKoN force-pushed the feat/pageid-routing-always-on branch from 7bb6554 to bac9c3b Compare May 20, 2026 10:41
Rename --experimental-page-id-routing to --page-id-routing and enable it
by default. Users can opt out with --no-page-id-routing if token overhead
is unacceptable or routing does not work as expected.

- Rename serverArgs.experimentalPageIdRouting to pageIdRouting and set
  default: true; describe text updated to reflect opt-out semantics.
- Update ToolHandler.ts schema injection and page resolution to use the
  new flag name.
- Drop the now-redundant delete of pageIdRouting from chrome-devtools-cli
  start options (was previously removing experimentalPageIdRouting).
- Update evaluate_script to use cliArgs.pageIdRouting and guard
  getPageById with a request.params.pageId check so passing the flag
  without a pageId no longer throws (mirrors the guard used in
  ToolHandler.ts).
- Improve pageIdSchema description: explain list_pages and selected-page
  fallback so the field is self-documenting.
- Fix generate-docs.ts to inject pageIdSchema for page-scoped tools so
  tool-reference.md surfaces pageId on every page-scoped tool; pass a
  slim flag so slim docs stay unchanged.
- Update eval scenarios to rely on the new default instead of passing
  --experimental-page-id-routing; update the example flag in the
  TestScenario JSDoc accordingly.
- Fix pageId type in script.test.ts (string -> number).
- Regenerated docs/tool-reference.md, README options section, and
  src/telemetry/{flag_usage_metrics,tool_call_metrics}.json.
- Add pageIdRouting/page-id-routing to the cli.test.ts default args
  fixture to reflect the new default.
@OrKoN OrKoN force-pushed the feat/pageid-routing-always-on branch from bac9c3b to 702a9b9 Compare May 20, 2026 10:46
@OrKoN
Copy link
Copy Markdown
Collaborator

OrKoN commented May 21, 2026

FYI we made pageId required when the page id routing is enabled because it makes the MCP server perform better with the agents. But it also causes a regression for the CLI interface where the required pageId becomes a mandatory positional argument for all commands and the skill is not updated. I think we would to disable pageId routing for the CLI for now. cc @samiyac

@OrKoN
Copy link
Copy Markdown
Collaborator

OrKoN commented May 21, 2026

also the tests fail because the pageId is now a required argument.

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