Skip to content

feat(agent): replace the runtime npx for browser agent chrome devtool mcp with pre-built bundle#22213

Merged
gsquared94 merged 24 commits intomainfrom
feat/chrome-dt-bundle
Mar 16, 2026
Merged

feat(agent): replace the runtime npx for browser agent chrome devtool mcp with pre-built bundle#22213
gsquared94 merged 24 commits intomainfrom
feat/chrome-dt-bundle

Conversation

@cynthialong0-0
Copy link
Copy Markdown
Contributor

@cynthialong0-0 cynthialong0-0 commented Mar 12, 2026

Summary

Replaced the runtime npx dependency for the browser MCP server with a bundled version in packages/core, improved tool exclusion management via a manifest, and removed the custom type_text tool.

Details

  • bundle-browser-mcp.mjs: Created a thin wrapper that imports chrome-devtools-mcp using esbuild. This script will tree shake out excluded tool files, and output a self-contained js file under package/core/dist
  • create a manifest.json to list all excluded tools, it now excludes tools from lighthouse, performance, screencast, and extensions.
  • replace npx with node in browserManager.ts
  • Remove customized type_text to consolidate and resolve error for duplicate tools

Related Issues

Fixes #20984, #20983

How to Validate

1. Enable the agent

Add to .gemini/settings.json:

{
  "agents": {
    "overrides": {
      "browser_agent": { "enabled": true }
    }
  }
}

2. Prompt the browser agent and verify tools can be used, and excluded tools in manifest cannot be used.

Example Prompt with included tools

Go to github.com/google-gemini/gemini-cli and tell me the latest release version

Example Prompt with excluded tools

Go to the NYT Wordle site, solve today's puzzle, and screencast how you solve it

And get response for something like:

  The agent captured the process visually as it solved it.

  Fulfilling your request to "screencast" the solution involved capturing high-resolution snapshots and
  screenshots at every step.

Pre-Merge Checklist

  • Updated relevant documentation and README (if needed)
  • Added/updated tests (if needed)
  • Noted breaking changes (if any)
  • Validated on required platforms/methods:
    • MacOS
      • npm run
      • npx
      • Docker
      • Podman
      • Seatbelt
    • Windows
      • npm run
      • npx
      • Docker
    • Linux
      • npm run
      • npx
      • Docker

@gemini-cli gemini-cli bot added the priority/p1 Important and should be addressed in the near term. label Mar 12, 2026
@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 12, 2026

Size Change: -4.06 kB (-0.02%)

Total Size: 26.1 MB

Filename Size Change
./bundle/chunk-IPNGUQEU.js 0 B -13.4 MB (removed) 🏆
./bundle/chunk-V6WMSUEI.js 0 B -3.62 MB (removed) 🏆
./bundle/core-U5XUMPRG.js 0 B -40.3 kB (removed) 🏆
./bundle/devtoolsService-ZJMCF3KF.js 0 B -27.7 kB (removed) 🏆
./bundle/interactiveCli-EUOWJMPS.js 0 B -1.59 MB (removed) 🏆
./bundle/oauth2-provider-22UOHOOO.js 0 B -9.19 kB (removed) 🏆
./bundle/chunk-DWY7N2WW.js 13.4 MB +13.4 MB (new file) 🆕
./bundle/chunk-EWAXOLE7.js 3.62 MB +3.62 MB (new file) 🆕
./bundle/core-J5B3Z2CL.js 40.3 kB +40.3 kB (new file) 🆕
./bundle/devtoolsService-CM7O5DLJ.js 27.7 kB +27.7 kB (new file) 🆕
./bundle/interactiveCli-66CU3YO2.js 1.59 MB +1.59 MB (new file) 🆕
./bundle/oauth2-provider-5KH6B5WK.js 9.19 kB +9.19 kB (new file) 🆕
ℹ️ View Unchanged
Filename Size
./bundle/chunk-34MYV7JD.js 2.45 kB
./bundle/chunk-37ZTTFQF.js 966 kB
./bundle/chunk-5AUYMPVF.js 858 B
./bundle/chunk-664ZODQF.js 124 kB
./bundle/chunk-DAHVX5MI.js 206 kB
./bundle/chunk-IUUIT4SU.js 56.5 kB
./bundle/chunk-RJTRUG2J.js 39.8 kB
./bundle/chunk-VN2KBIC6.js 1.95 MB
./bundle/devtools-36NN55EP.js 696 kB
./bundle/dist-T73EYRDX.js 356 B
./bundle/gemini.js 695 kB
./bundle/getMachineId-bsd-TXG52NKR.js 1.55 kB
./bundle/getMachineId-darwin-7OE4DDZ6.js 1.55 kB
./bundle/getMachineId-linux-SHIFKOOX.js 1.34 kB
./bundle/getMachineId-unsupported-5U5DOEYY.js 1.06 kB
./bundle/getMachineId-win-6KLLGOI4.js 1.72 kB
./bundle/memoryDiscovery-A4UZQ6IE.js 922 B
./bundle/multipart-parser-KPBZEGQU.js 11.7 kB
./bundle/node_modules/@google/gemini-cli-devtools/dist/client/main.js 221 kB
./bundle/node_modules/@google/gemini-cli-devtools/dist/src/_client-assets.js 227 kB
./bundle/node_modules/@google/gemini-cli-devtools/dist/src/index.js 11.5 kB
./bundle/node_modules/@google/gemini-cli-devtools/dist/src/types.js 132 B
./bundle/sandbox-macos-permissive-open.sb 890 B
./bundle/sandbox-macos-permissive-proxied.sb 1.31 kB
./bundle/sandbox-macos-restrictive-open.sb 3.36 kB
./bundle/sandbox-macos-restrictive-proxied.sb 3.56 kB
./bundle/sandbox-macos-strict-open.sb 4.82 kB
./bundle/sandbox-macos-strict-proxied.sb 5.02 kB
./bundle/src-QVCVGIUX.js 47 kB
./bundle/tree-sitter-7U6MW5PS.js 274 kB
./bundle/tree-sitter-bash-34ZGLXVX.js 1.84 MB
./bundle/undici-4X2YZID5.js 360 B

compressed-size-action

@gemini-cli gemini-cli bot added area/core Issues related to User Interface, OS Support, Core Functionality 🔒 maintainer only ⛔ Do not contribute. Internal roadmap item. labels Mar 13, 2026
@cynthialong0-0
Copy link
Copy Markdown
Contributor Author

/gemini review

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a significant improvement by bundling the chrome-devtools-mcp server instead of fetching it with npx at runtime, enhancing reliability and startup performance. The implementation is generally well-executed. However, a critical path resolution issue in browserManager.ts has been identified, which violates our guidelines for consistent and robust path handling (Rule 1) and would prevent the bundled script from being located in production builds. Addressing this path issue will bring the changes into excellent shape.

@cynthialong0-0 cynthialong0-0 marked this pull request as ready for review March 13, 2026 15:48
@cynthialong0-0 cynthialong0-0 requested review from a team as code owners March 13, 2026 15:48
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly refactors how the browser agent's underlying Chrome DevTools Protocol (CDP) server, chrome-devtools-mcp, is managed. By bundling chrome-devtools-mcp directly into the packages/core module and replacing the runtime npx dependency with a direct node execution, the change aims to enhance the stability and startup speed of the browser agent. Furthermore, a new manifest allows for precise control over which chrome-devtools-mcp tools are included, optimizing the bundle size and reducing extraneous dependencies.

Highlights

  • Bundled Chrome DevTools MCP: Replaced the runtime npx dependency for the browser agent's Chrome DevTools MCP server with a pre-bundled version, improving startup performance and reliability.
  • Tool Exclusion via Manifest: Implemented a new manifest-driven mechanism to explicitly exclude specific tools (e.g., lighthouse, performance, screencast, extensions) from the chrome-devtools-mcp bundle, reducing its size and unnecessary dependencies.
  • Consolidated type_text Tool: Removed the custom type_text tool implementation, as its functionality is now provided directly by the chrome-devtools-mcp suite, simplifying the toolset.
  • Build Process Integration: Integrated the bundling process for chrome-devtools-mcp into the core package's build script, ensuring the bundled version is created automatically.
Changelog
  • eslint.config.js
    • Extended ESLint configuration to include new script files within packages/core/scripts.
  • package-lock.json
    • Updated numerous dependencies, including the addition of puppeteer-core and chrome-devtools-mcp and their transitive dependencies.
    • Removed 'dev' flags for several packages like estraverse, esutils, http-proxy-agent, and tslib.
    • Updated semver dependency to version 7.7.4.
  • packages/core/package.json
    • Added a new bundle:browser-mcp script command.
    • Declared puppeteer-core and chrome-devtools-mcp as dependencies.
  • packages/core/scripts/bundle-browser-mcp.mjs
    • Added a new ESBuild script to bundle chrome-devtools-mcp.
    • Implemented an emptyModulePlugin to tree-shake excluded tools based on a manifest.
    • Included logic to copy necessary third_party assets while filtering out large, unnecessary bundles.
  • packages/core/src/agents/browser/browser-tools-manifest.json
    • Added a new manifest file to specify chrome-devtools-mcp tools to be excluded from the bundle, with reasons for exclusion.
  • packages/core/src/agents/browser/browserAgentFactory.test.ts
    • Adjusted expected tool counts in tests to reflect the removal of the custom type_text tool.
    • Updated assertions to account for type_text being an MCP tool.
  • packages/core/src/agents/browser/browserManager.test.ts
    • Modified tests to verify the node command and bundled chrome-devtools-mcp.mjs path are used.
    • Removed assertions related to npx and its -y argument.
  • packages/core/src/agents/browser/browserManager.ts
    • Refactored the browser manager to launch the bundled chrome-devtools-mcp using node instead of npx.
    • Updated path resolution for the bundled script.
    • Removed CHROME_DEVTOOLS_MCP_VERSION constant and npx-specific arguments.
    • Updated comments to reflect the new bundling approach.
  • packages/core/src/agents/browser/mcpToolWrapper.test.ts
    • Updated tests to remove checks and expectations for the previously custom type_text tool.
  • packages/core/src/agents/browser/mcpToolWrapper.ts
    • Removed the custom TypeTextInvocation and TypeTextDeclarativeTool classes.
    • Modified createMcpDeclarativeTools to no longer add a custom type_text tool.
  • scripts/build_package.js
    • Integrated the new bundle-browser-mcp.mjs script into the core package's build process, ensuring it runs when the package is built.
Activity
  • The author, cynthialong0-0, created this pull request to implement a bundled version of the Chrome DevTools MCP server and improve tool exclusion.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@cynthialong0-0 cynthialong0-0 changed the title Feat/chrome dt bundle feat(agent): replace the runtime npx for browser agent chrome devtool mcp with pre-built bundle Mar 13, 2026
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request effectively replaces the runtime npx dependency for chrome-devtools-mcp with a locally bundled version, which is a great improvement for stability and performance. The use of a manifest file for excluding tools is also a clean solution.

I've found two critical issues related to path resolution that will likely break the build and prevent the browser agent from starting in the production environment. Please see my comments for the specific fixes.

@gsquared94 gsquared94 self-assigned this Mar 13, 2026
@gsquared94
Copy link
Copy Markdown
Contributor

Running with npm run clean && npm run build && npm run bundle getting this error:

image

Copy link
Copy Markdown
Contributor

@gsquared94 gsquared94 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@gsquared94 gsquared94 enabled auto-merge March 16, 2026 07:49
@gsquared94 gsquared94 added this pull request to the merge queue Mar 16, 2026
Merged via the queue into main with commit 366aa84 Mar 16, 2026
27 checks passed
@gsquared94 gsquared94 deleted the feat/chrome-dt-bundle branch March 16, 2026 08:16
theerud pushed a commit to theerud/gemini-cli that referenced this pull request Mar 16, 2026
… mcp with pre-built bundle (google-gemini#22213)

Co-authored-by: Gaurav Ghosh <gaghosh@google.com>
Co-authored-by: Gaurav <39389231+gsquared94@users.noreply.github.com>
@lesteral
Copy link
Copy Markdown

This also (effectively) fixes #20587 (thank you)

@lesteral
Copy link
Copy Markdown

@cynthialong0-0 @gsquared94 - after starting to use this update, I now see, in the debug log:

❌ chrome-devtools-mcp transport closed unexpectedly. The MCP server process may have crashed.

It consistently occurs right after

Input blocker removed successfully

& before

Browser agent cleanup complete

Excerpt from the debug log:

image

(Ignore the 429 / GaxiosError - it's just that time of the day - this error occurs whether or not the 429's are hit.)

kunal-10-cloud pushed a commit to kunal-10-cloud/gemini-cli that referenced this pull request Mar 21, 2026
… mcp with pre-built bundle (google-gemini#22213)

Co-authored-by: Gaurav Ghosh <gaghosh@google.com>
Co-authored-by: Gaurav <39389231+gsquared94@users.noreply.github.com>
ProthamD pushed a commit to ProthamD/gemini-cli that referenced this pull request Mar 29, 2026
… mcp with pre-built bundle (google-gemini#22213)

Co-authored-by: Gaurav Ghosh <gaghosh@google.com>
Co-authored-by: Gaurav <39389231+gsquared94@users.noreply.github.com>
gsquared94 added a commit to gsquared94/gemini-cli that referenced this pull request Apr 1, 2026
The bundle:browser-mcp script (which builds packages/core/dist/bundled/
chrome-devtools-mcp.mjs) was never invoked as part of the root bundle
pipeline added in google-gemini#22213. This caused the bundled chrome-devtools-mcp
to be missing from published npm packages, resulting in MODULE_NOT_FOUND
errors at runtime when using the browser agent.

Changes:
- Add bundle:browser-mcp step to root bundle script before esbuild
- Make copy_bundle_assets.js fail loudly when the bundled directory is
  missing instead of silently skipping the copy
warrenzhu25 pushed a commit to warrenzhu25/gemini-cli that referenced this pull request Apr 9, 2026
… mcp with pre-built bundle (google-gemini#22213)

Co-authored-by: Gaurav Ghosh <gaghosh@google.com>
Co-authored-by: Gaurav <39389231+gsquared94@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/core Issues related to User Interface, OS Support, Core Functionality 🔒 maintainer only ⛔ Do not contribute. Internal roadmap item. priority/p1 Important and should be addressed in the near term.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Refactor to use the programmatic Server API for in-process embedding

4 participants