文件历史

16 次代码提交

作者 SHA1 备注 提交日期
Alex Rudenko b4546ef86b test: fix potential flakiness in tests (#2396)
release-please / release-please (push) Has been cancelled
Compile and run tests / Tests on macos-latest with node 22 (push) Has been cancelled
Compile and run tests / Tests on ubuntu-latest with node 22 (push) Has been cancelled
Compile and run tests / Tests on windows-latest with node 22 (push) Has been cancelled
Compile and run tests / Tests on macos-latest with node 24 (push) Has been cancelled
Compile and run tests / Tests on ubuntu-latest with node 24 (push) Has been cancelled
Compile and run tests / Tests on windows-latest with node 24 (push) Has been cancelled
Compile and run tests / Tests on macos-latest with node 26 (push) Has been cancelled
Compile and run tests / Tests on ubuntu-latest with node 26 (push) Has been cancelled
Compile and run tests / Tests on windows-latest with node 26 (push) Has been cancelled
Check code before submitting / [Required] Check correct format (push) Has been cancelled
Check code before submitting / [Required] Check docs updated (push) Has been cancelled
Compile and run tests / [Required] Tests passed (push) Has been cancelled
Assortment of various flakiness conditions found running tests in a loop
locally:


This PR introduces a comprehensive set of hermetic retry layers and
aggressive
timeout handlers across the test suite to insulate it from random
Chromium
startup hangs, CDP deadlocks, and Puppeteer lifecycle flakes. It
guarantees that
temporary browser infrastructure failures are automatically retried
without
failing the CI, while actual code assertion failures still fail fast.

### Test Harness & Retry Improvements

• tests/utils.ts: Rewrote withBrowser to include a 30-second internal
timeout and
a 3-attempt retry loop. If Chromium locks up or disconnects (Target
closed /
socket hang up), the browser is forcibly evicted (via SIGKILL if
browser.close()
hangs) and the test setup is cleanly retried.
• tests/index.test.ts: Wrapped withClient (used by E2E tests) in a
3-attempt
retry loop to handle the daemon/Chromium hanging during launch and
triggering the
60-second MCP client timeout.
• tests/browser.test.ts: Added a safeClose helper that imposes a
2-second timeout
before SIGKILLing browsers, and wrapped raw Puppeteer tests in
runWithRetry to
handle startup hangs.
• tests/shutdown.test.ts: Added a setupServerWithRetry helper to prevent
random
60s RPC timeouts when the server's Chrome instance hangs during boot.

### Flaky Operations & Navigation Fixes

• src/tools/performance.ts & tests/tools/performance.test.ts: Replaced
the
notoriously flaky waitUntil: ['networkidle0'] with 'load' when
navigating to
about:blank in performance_start_trace. This prevents random 10-second
Navigation
timeout exceeded errors. Also stubbed goto in the associated unit tests
for
better hermeticity.
• src/McpContext.ts: Wrapped browser.installExtension() with a 15-second
timeout
to prevent deadlocks when an extension fails to load.
• tests/tools/extensions.test.ts: Removed flaky headless UI navigations
to
chrome://extensions in favor of using the context.listExtensions() API.
• tests/tools/pages.test.js.snapshot: Synced test snapshots to reflect
updated
environment baselines.
2026-07-21 13:47:47 +00:00
Natasha Gorshunova 02b4492ca6 feat: support allowedUrlPattern & blockedUrlPattern Options (#2037)
## Support for Network Blocklists and Allowlists
(`--blocked-url-pattern` & `--allowed-url-pattern` arguments)

This PR adds support for CLI options to restrict network access in the
browser session via URL patterns.

### Key Features & How It Works

- **Pattern Matching:** Utilizes the [URLPattern
Standard](https://urlpattern.spec.whatwg.org/) for pattern matching.
- **Target Detachment:** Silently detaches from targets (pages/tabs)
whose URLs match blocked patterns (or do not match allowed patterns)
upon connection.
- **Runtime Blocking:** Prevents navigations and blocks runtime requests
(such as fetch/XHR and subresources) if they violate the pattern rules.
- **Mutual Exclusivity:** `--blocked-url-pattern` and
`--allowed-url-pattern` conflict with each other and cannot be
configured simultaneously.
- **Browser Requirements:**
  - **`--allowed-url-pattern`**: Requires **Chrome 149+**.
- **`--blocked-url-pattern`**: Works on Chrome versions older than 149,
but **Chrome 149+ is highly recommended**.

### Important Limitations & Side Effects

- **Network Emulation/Throttling Conflict:** Network throttling is
disabled when a network blocklist/allowlist is configured, to avoid
conflicting with Puppeteer's underlying blocking mechanisms.
- Using the `emulate` tool to modify `networkConditions` (e.g. setting
to `Offline`) will throw an error: *`Network throttling is not supported
when network blocking (allowlist/blocklist) is configured.`*
- Other emulation settings (e.g., `cpuThrottlingRate`, `geolocation`,
`viewport`) are unaffected and remain fully functional.

---

### Configuration Examples

#### 1. Blocking specific domains or endpoints (Blocklist)
Add the `--blocked-url-pattern` options to the `args` list in your MCP
settings file:

```json
{
  "mcpServers": {
    "chrome-devtools": {
      "command": "npx",
      "args": [
        "chrome-devtools-mcp@latest",
        "--blocked-url-pattern=*://*.blocked-example.com/*",
        "--blocked-url-pattern=*://*.another-blocked-example.com/*"
      ]
    }
  }
}
```

#### 2. Restricting access to authorized domains (Allowlist)
Add the `--allowed-url-pattern` options to restrict the browser to
permitted hosts (requires Chrome 149+):

```json
{
  "mcpServers": {
    "chrome-devtools": {
      "command": "npx",
      "args": [
        "chrome-devtools-mcp@latest",
        "--allowed-url-pattern=https://*.allowed-example.com/*",
        "--allowed-url-pattern=https://*.another-allowed-example.com/*"
      ]
    }
  }
}
```

---------

Co-authored-by: Natallia Harshunova <nharshunova@chromium.org>
Co-authored-by: Alex Rudenko <alexrudenko@chromium.org>
2026-06-08 09:20:00 +00:00
dependabot[bot] 20021469dc chore(deps-dev): bump puppeteer from 24.43.0 to 25.0.2 in the bundled group across 1 directory (#2045)
Bumps the bundled group with 1 update in the / directory:
[puppeteer](https://github.com/puppeteer/puppeteer).

Updates `puppeteer` from 24.43.0 to 25.0.2
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/puppeteer/puppeteer/releases">puppeteer's
releases</a>.</em></p>
<blockquote>
<h2>puppeteer-core: v25.0.2</h2>
<h2><a
href="https://github.com/puppeteer/puppeteer/compare/puppeteer-core-v25.0.1...puppeteer-core-v25.0.2">25.0.2</a>
(2026-05-15)</h2>
<h3>🛠️ Fixes</h3>
<ul>
<li>update docs text (<a
href="https://redirect.github.com/puppeteer/puppeteer/issues/14992">#14992</a>)
(<a
href="https://github.com/puppeteer/puppeteer/commit/36527b8b9dd856e11a372b46cba23409e5613573">36527b8</a>)</li>
</ul>
<h3>Dependencies</h3>
<ul>
<li>The following workspace dependencies were updated
<ul>
<li>dependencies
<ul>
<li><code>@​puppeteer/browsers</code> bumped from 3.0.1 to 3.0.2</li>
</ul>
</li>
</ul>
</li>
</ul>
<h2>puppeteer: v25.0.2</h2>
<h2><a
href="https://github.com/puppeteer/puppeteer/compare/puppeteer-v25.0.1...puppeteer-v25.0.2">25.0.2</a>
(2026-05-15)</h2>
<h3>♻️ Chores</h3>
<ul>
<li><strong>puppeteer:</strong> Synchronize puppeteer versions</li>
</ul>
<h3>Dependencies</h3>
<ul>
<li>The following workspace dependencies were updated
<ul>
<li>dependencies
<ul>
<li><code>@​puppeteer/browsers</code> bumped from 3.0.1 to 3.0.2</li>
<li>puppeteer-core bumped from 25.0.1 to 25.0.2</li>
</ul>
</li>
</ul>
</li>
</ul>
<h2>puppeteer-core: v25.0.1</h2>
<h2><a
href="https://github.com/puppeteer/puppeteer/compare/puppeteer-core-v25.0.0...puppeteer-core-v25.0.1">25.0.1</a>
(2026-05-13)</h2>
<h3>🛠️ Fixes</h3>
<ul>
<li>enabled features should take precedence over disabled features (<a
href="https://redirect.github.com/puppeteer/puppeteer/issues/14985">#14985</a>)
(<a
href="https://github.com/puppeteer/puppeteer/commit/f6fd7c29f92e6183b2fd48f0571957306c58d440">f6fd7c2</a>)</li>
<li>roll to Chrome 148.0.7778.167 (<a
href="https://redirect.github.com/puppeteer/puppeteer/issues/14980">#14980</a>)
(<a
href="https://github.com/puppeteer/puppeteer/commit/84c46fede6b02a1e9a00104b97b28c263f0c84df">84c46fe</a>)</li>
<li>roll to Firefox 150.0.3 (<a
href="https://redirect.github.com/puppeteer/puppeteer/issues/14983">#14983</a>)
(<a
href="https://github.com/puppeteer/puppeteer/commit/872f77822d6b6b9b6510752d838107a967241bdb">872f778</a>)</li>
</ul>
<h3>Dependencies</h3>
<ul>
<li>The following workspace dependencies were updated
<ul>
<li>dependencies
<ul>
<li><code>@​puppeteer/browsers</code> bumped from 3.0.0 to 3.0.1</li>
</ul>
</li>
</ul>
</li>
</ul>
<h2>puppeteer: v25.0.1</h2>
<h2><a
href="https://github.com/puppeteer/puppeteer/compare/puppeteer-v25.0.0...puppeteer-v25.0.1">25.0.1</a>
(2026-05-13)</h2>
<!-- raw HTML omitted -->
</blockquote>
<p>... (truncated)</p>
</details>
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a
href="https://github.com/puppeteer/puppeteer/blob/main/CHANGELOG.md">puppeteer's
changelog</a>.</em></p>
<blockquote>
<h2><a
href="https://github.com/puppeteer/puppeteer/compare/puppeteer-v25.0.1...puppeteer-v25.0.2">25.0.2</a>
(2026-05-15)</h2>
<h3>♻️ Chores</h3>
<ul>
<li><strong>puppeteer:</strong> Synchronize puppeteer versions</li>
</ul>
<h3>Dependencies</h3>
<ul>
<li>The following workspace dependencies were updated
<ul>
<li>dependencies
<ul>
<li><code>@​puppeteer/browsers</code> bumped from 3.0.1 to 3.0.2</li>
</ul>
</li>
</ul>
</li>
</ul>
<h3>🛠️ Fixes</h3>
<ul>
<li>update docs text (<a
href="https://redirect.github.com/puppeteer/puppeteer/issues/14992">#14992</a>)
(<a
href="https://github.com/puppeteer/puppeteer/commit/36527b8b9dd856e11a372b46cba23409e5613573">36527b8</a>)</li>
</ul>
<h2><a
href="https://github.com/puppeteer/puppeteer/compare/puppeteer-v25.0.0...puppeteer-v25.0.1">25.0.1</a>
(2026-05-13)</h2>
<h3>♻️ Chores</h3>
<ul>
<li><strong>puppeteer:</strong> Synchronize puppeteer versions</li>
</ul>
<h3>Dependencies</h3>
<ul>
<li>The following workspace dependencies were updated
<ul>
<li>dependencies
<ul>
<li><code>@​puppeteer/browsers</code> bumped from 3.0.0 to 3.0.1</li>
</ul>
</li>
</ul>
</li>
</ul>
<h3>🛠️ Fixes</h3>
<ul>
<li>enabled features should take precedence over disabled features (<a
href="https://redirect.github.com/puppeteer/puppeteer/issues/14985">#14985</a>)
(<a
href="https://github.com/puppeteer/puppeteer/commit/f6fd7c29f92e6183b2fd48f0571957306c58d440">f6fd7c2</a>)</li>
<li>roll to Chrome 148.0.7778.167 (<a
href="https://redirect.github.com/puppeteer/puppeteer/issues/14980">#14980</a>)
(<a
href="https://github.com/puppeteer/puppeteer/commit/84c46fede6b02a1e9a00104b97b28c263f0c84df">84c46fe</a>)</li>
<li>roll to Firefox 150.0.3 (<a
href="https://redirect.github.com/puppeteer/puppeteer/issues/14983">#14983</a>)
(<a
href="https://github.com/puppeteer/puppeteer/commit/872f77822d6b6b9b6510752d838107a967241bdb">872f778</a>)</li>
</ul>
<h2><a
href="https://github.com/puppeteer/puppeteer/compare/puppeteer-v24.43.1...puppeteer-v25.0.0">25.0.0</a>
(2026-05-12)</h2>
<h3>⚠ BREAKING CHANGES</h3>
<ul>
<li>remove deprecated Puppeteer.product (<a
href="https://redirect.github.com/puppeteer/puppeteer/issues/14977">#14977</a>)</li>
<li>bump min NodeJS to 22 (<a
href="https://redirect.github.com/puppeteer/puppeteer/issues/14973">#14973</a>)</li>
<li>return a Promise for executablePath, defaultArgs (<a
href="https://redirect.github.com/puppeteer/puppeteer/issues/14965">#14965</a>)</li>
</ul>
<!-- raw HTML omitted -->
</blockquote>
<p>... (truncated)</p>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="https://github.com/puppeteer/puppeteer/commit/3aadc38c533caa8df87f381868291ede870883e2"><code>3aadc38</code></a>
chore: release main (<a
href="https://redirect.github.com/puppeteer/puppeteer/issues/14993">#14993</a>)</li>
<li><a
href="https://github.com/puppeteer/puppeteer/commit/36527b8b9dd856e11a372b46cba23409e5613573"><code>36527b8</code></a>
fix: update docs text (<a
href="https://redirect.github.com/puppeteer/puppeteer/issues/14992">#14992</a>)</li>
<li><a
href="https://github.com/puppeteer/puppeteer/commit/3ea7bd54b97965fb0e1b83a2c017720162785c92"><code>3ea7bd5</code></a>
fix: capitalize &quot;Chrome&quot; in troubleshooting.md (<a
href="https://redirect.github.com/puppeteer/puppeteer/issues/14991">#14991</a>)</li>
<li><a
href="https://github.com/puppeteer/puppeteer/commit/ae72fdbec9720c982fc2ed818036d7be9b2aa1dc"><code>ae72fdb</code></a>
chore: Tiny punctuation update in troubleshooting.md (<a
href="https://redirect.github.com/puppeteer/puppeteer/issues/14990">#14990</a>)</li>
<li><a
href="https://github.com/puppeteer/puppeteer/commit/1597fde55de1e7b3c31032aa43dce0607b4307d3"><code>1597fde</code></a>
chore: release main (<a
href="https://redirect.github.com/puppeteer/puppeteer/issues/14982">#14982</a>)</li>
<li><a
href="https://github.com/puppeteer/puppeteer/commit/f6fd7c29f92e6183b2fd48f0571957306c58d440"><code>f6fd7c2</code></a>
fix: enabled features should take precedence over disabled features (<a
href="https://redirect.github.com/puppeteer/puppeteer/issues/14985">#14985</a>)</li>
<li><a
href="https://github.com/puppeteer/puppeteer/commit/bf05fb9bf5bac997e365eda2e31c6067e5ec1677"><code>bf05fb9</code></a>
fix: update browsers to trigger release (<a
href="https://redirect.github.com/puppeteer/puppeteer/issues/14984">#14984</a>)</li>
<li><a
href="https://github.com/puppeteer/puppeteer/commit/872f77822d6b6b9b6510752d838107a967241bdb"><code>872f778</code></a>
fix: roll to Firefox 150.0.3 (<a
href="https://redirect.github.com/puppeteer/puppeteer/issues/14983">#14983</a>)</li>
<li><a
href="https://github.com/puppeteer/puppeteer/commit/84c46fede6b02a1e9a00104b97b28c263f0c84df"><code>84c46fe</code></a>
fix: roll to Chrome 148.0.7778.167 (<a
href="https://redirect.github.com/puppeteer/puppeteer/issues/14980">#14980</a>)</li>
<li><a
href="https://github.com/puppeteer/puppeteer/commit/ee655d8292f37cc33f279746ef72613e5ccb5db8"><code>ee655d8</code></a>
chore(main): release ng-schematics 0.8.0 (<a
href="https://redirect.github.com/puppeteer/puppeteer/issues/14978">#14978</a>)</li>
<li>Additional commits viewable in <a
href="https://github.com/puppeteer/puppeteer/compare/puppeteer-v24.43.0...puppeteer-v25.0.2">compare
view</a></li>
</ul>
</details>
<br />

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Alex Rudenko <alexrudenko@chromium.org>
2026-05-17 06:34:22 +00:00
Alex Rudenko 1746ed9ee1 fix: detect X server display on Linux (#1027)
in headful mode on Linux we should try detecting X server if DISPLAY is
not set.
2026-02-24 14:35:55 +00:00
Lakshan Perera 9a51af219f feat: Allow opting out of default Chrome launch arguments (#729)
Related Issue -
https://github.com/ChromeDevTools/chrome-devtools-mcp/issues/430

### Description

When Chrome is launched via Puppeteer, it automatically adds a set of
default flags like `--enable-automation --disable-extensions
--disable-component-extensions-with-background-pages.`

Currently, there is no way to opt out of these defaults, which makes
certain use cases difficult or impossible to support. this PR adds a way
to selectively ignore specific default Chrome launch flags applied by
Puppeteer using its
[ignoreDefaultArgs](https://pptr.dev/api/puppeteer.launchoptions#ignoredefaultargs)
property.

```json
{
  "name": "chrome-devtools-mcp",
  "version": "latest",
  "mcpServers": {
    "chrome-devtools": {
      "command": "npx",
      "args": [
        "chrome-devtools-mcp@latest",
        "--ignore-default-chrome-arg='--enable-automation'",
        "--ignore-default-chrome-arg='--disable-extensions'"
      ]
    }
  }
}
```

**Feedback appreciated** @OrKoN
2026-01-12 10:08:18 +00:00
Alex Rudenko 6f59b3975a fix: map channel for resolveDefaultUserDataDir (#658)
- delegate to Puppeteer for channel lookup
- handle lookup in a custom user data dir on the MCP side
2025-12-09 13:01:08 +00:00
Alex Rudenko e3c59bcd9c feat: support --user-data-dir with --auto-connect (#654)
This PR integrates `--user-data-dir` with the `--auto-connect` feature.
If `--user-data-dir` is provided as well `--auto-connect`, the specified
dir is used to locate a running browser server.
2025-12-09 10:46:23 +01:00
zyzyzyryxy 94752ffade fix: prevent dropping license notices on some files when publishing (#604)
This PR prevents license notices being dropped when creating package for
publication.

This can happen when first import in the file is type-only import that
gets removed during build. When there is no empty line between the
license block comment and such import, the comment is treated as related
to the import and gets removed alongside it.
Adding an empty line between copyright notice and the import fixes the
issue.

Co-authored-by: Piotr Paulski <piotrpaulski@chromium.org>
2025-11-24 12:38:30 +00:00
Alex Rudenko 2982195ec9 chore: experimental devtools-on-devtools support (#51)
Allows using the MCP server for the devtools development.
2025-10-10 14:17:00 +00:00
Alex Rudenko 357db65d18 fix: change default screen size in headless (#299)
Sets the screen size in headless to be 3840x2160px to allow resize tool
to work correctly for most use cases.

Closes https://github.com/ChromeDevTools/chrome-devtools-mcp/issues/294
2025-10-07 13:27:23 +00:00
Alex Rudenko ef61a08707 feat: support initial viewport in the CLI (#229)
Closes https://github.com/ChromeDevTools/chrome-devtools-mcp/issues/165

This PR uses page_resize logic to set the initial viewport size. Not
using the emulation because it looks buggy in headful which is our
default mode.
2025-10-01 10:11:35 +02:00
Nikolay Vitkov 15277541d8 chore: add additional EsLint rule (#147) 2025-09-25 17:20:01 +02:00
Alex Rudenko 9c8da4a449 test: use cft for e2e tests (#80)
we were using the Chrome version pre-installed on the GitHub actions and
I wonder if it could have been the source for the flakiness.
2025-09-23 19:53:33 +02:00
Alex Rudenko 92046183d4 chore(deps): bump puppeteer (#79)
Contains fixes for the pipe transport.
2025-09-23 17:01:19 +00:00
Alex Rudenko 74fa209145 test: skip flaky test (#77) 2025-09-23 14:03:44 +00:00
Alex Rudenko 732267db5f fix: detect multiple instances and throw (#12)
We should be checking for browser logs in Puppeteer instead.
2025-09-11 16:42:27 +02:00