文件历史

提交图

23 次代码提交

作者 SHA1 备注 提交日期
Alex Rudenko c53c1ec4c9 refactor: use response page in formatting (#2349) 2026-07-13 07:55:37 +00:00
Alex Rudenko 58ba174273 refactor: move remaining McpContext getters (#2342)
Moves various getters to McpPage.
2026-07-10 12:46:01 +00:00
Alex Rudenko 9cd734b0a3 refactor: clean up more of the context interface (#2335)
- removed redundant page getters
2026-07-09 13:50:48 +00:00
Wolfgang Beyer 3ade962a8d fix: Apply CPU throttling to secondary CDP session (#2092)
This addresses #1955 

CPU throttling needs to be applied to both the primary puppeteer session
and the secondary CDP session from the DevTools universe to have an
effect.

For network throttling this does not seem to be the case, I can see a
slowdown with the current implementation which only applies the network
throttling to the primary CDP session.

I also had to increase the navigation timeout to prevent timeout errors.
2026-05-22 07:17:30 +00:00
Pedro Durek 6992106d1c feat: add extraHttpHeaders emulation to emulate tool (#1176)
## Summary

Extend the existing `emulate` tool with an `extraHTTPHeaders` parameter
that calls Puppeteer's `page.setExtraHTTPHeaders()` (which uses CDP
`Network.setExtraHTTPHeaders` under the hood).

Closes #1175

## Approach

Per [feedback from
@natorion](https://github.com/ChromeDevTools/chrome-devtools-mcp/issues/1175#issuecomment-4097587153),
this integrates into the existing `emulate` tool rather than adding a
standalone tool. The `emulate` tool is already the central hub for
page-level state modifications (userAgent, viewport, networkConditions,
geolocation, colorScheme), and custom HTTP headers fit naturally
alongside them. This also avoids increasing the MCP tool count and LLM
token overhead.

## Changes

- **`src/types.ts`** — Added `extraHTTPHeaders?: Record<string, string>`
to `EmulationSettings`
- **`src/tools/emulation.ts`** — Added `extraHTTPHeaders` as an optional
zod parameter on the `emulate` tool
- **`src/McpContext.ts`** — Added handler logic in the `emulate()`
method:
- Calls `page.setExtraHTTPHeaders()` when `extraHTTPHeaders` is provided
  - Clears from settings when an empty `{}` is passed
- Preserves existing headers when the param is **omitted** (unlike other
emulation settings that reset when omitted) — prevents
`emulate({colorScheme: "dark"})` from accidentally clearing
previously-set headers
- **`tests/tools/emulation.test.ts`** — Added 5 test cases:
  1. Sets extra headers on requests
  2. Clears headers with `{}`
  3. Headers persist across navigations
  4. Does not affect other emulation settings
  5. Reports correctly per-page (new page has no headers)

## Use Case

This enables setting custom HTTP headers on **all** requests — including
the initial document navigation and `<script>` tag loads — which
`initScript` cannot do since it runs after the document is already
fetched.

## Usage

```js
// Set headers
emulate({ extraHTTPHeaders: { "X-Custom": "value", "Authorization": "Bearer token" } })

// Clear headers
emulate({ extraHTTPHeaders: {} })

// Combine with other emulation settings
emulate({ extraHTTPHeaders: { "X-Branch": "feature-1" }, userAgent: "MyBot/1.0" })
```

---------

Co-authored-by: Alex Rudenko <alexrudenko@chromium.org>
Co-authored-by: Nicholas Roscino <nroscino@google.com>
2026-05-20 09:37:27 +00:00
Alex Rudenko 213720b69c fix: improve geolocation emulation (#2036)
- add a message about successful configuration
- add a message about the currently emulated geolocation
- switch to comma separate format instead of `x` separator.

Tested with https://www.audero.it/demo/geolocation-api-demo.html
2026-05-18 12:13:12 +00:00
Alex Rudenko e51ba47203 fix: simplify emulation and script tools (#1073)
- reduces the token usage.
- makes emulation and script compatible with CLI.
- documents .nullable() and .object() restrictions for the future.
- the emulation tools do not have nullable anymore and undefined would
clear the emulation instead. The model is thus required to provide all
emulation settings at once.

Closes https://github.com/ChromeDevTools/chrome-devtools-mcp/issues/918
2026-03-02 13:31:55 +00:00
Alex Rudenko 4cb5a17b57 refactor: remove page passing via context (#1061)
- removes several redundant getters on the context.
- removes passing page instances via context.
2026-02-27 12:08:10 +00:00
Alex Rudenko 40c241bbfc refactor: move dialog handling to McpPage (#1059)
- renamed getSelectedPage to getSelectedPptrPage
- removes getSelectedPptrPage from tool interfaces
- moves dialog handling to McpPage
- makes responses to be optionally McpPage-scoped
2026-02-27 11:49:43 +01:00
Alex Rudenko 302e5a0419 refactor: consistently use McpPage in tools (#1057)
Follow-up to
https://github.com/ChromeDevTools/chrome-devtools-mcp/commit/caf601a32832bb87cfac801a6bbeacb87508412f

The work is not complete and as a follow-up I will handle other Context
methods and moved whatever is relevant to the McpPage. Also, duplicate
getters would go away.
2026-02-27 09:41:08 +00:00
Alex Rudenko 5f694c60ff refactor: improve type safety for page scoped tools (#1051)
I think we should create proper classes for tool definitions soon.

Follow-up for
https://github.com/ChromeDevTools/chrome-devtools-mcp/pull/1022
2026-02-26 14:33:57 +00:00
Alex Rudenko bc3c40e8f9 refactor: move emulation settings to context (#1000)
- reduces boilerplate 
- allows easily to restore emulation settings

This is in preparation for the integration with Lighthouse.
2026-02-20 11:36:14 +00:00
Alex Rudenko 5a23a8c201 feat: support testing light and dark mode (#858)
Closes https://github.com/ChromeDevTools/chrome-devtools-mcp/issues/130
2026-01-28 13:57:54 +00:00
Alex Rudenko a8169676f9 feat: support device viewport and user agent emulation (#798)
This PR adds two emulation attributes `viewport` and `userAgent` that
allow emulating a mobile or a different desktop device.

Closes https://github.com/ChromeDevTools/chrome-devtools-mcp/pull/272
Closes https://github.com/ChromeDevTools/chrome-devtools-mcp/issues/619
Closes https://github.com/ChromeDevTools/chrome-devtools-mcp/issues/410
Closes https://github.com/ChromeDevTools/chrome-devtools-mcp/issues/280
(the recommended way is to emulate via the MCP server instead of a
parallel DevTools session)
2026-01-20 14:07:57 +00:00
JustasM 3991e4c2a9 feat(emulation): add geolocation emulation tool (#634)
Adding emulate_geolocation tool to emulate device location for testing
location-based features. Supports setting latitude/longitude or clearing
the override.

Closing https://github.com/ChromeDevTools/chrome-devtools-mcp/issues/296
2025-12-02 08:57:55 +01:00
Simon Zünd 8e90a92780 chore: split withBrowser into withBrowser and withMcpContext (#620)
I split this PR off from my "create one DevTools universe per page" PR
in preparation. This allows tests to re-use browser instances without
creating an `McpContext`.

Drive-by: Move mocked browser/page into utils.ts.
2025-11-28 07:52:52 +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 4724bbba93 fix: avoid no page selected errors (#537)
Uses object identity to track the selected page. This helps to be in
sync with the browser state better.

Closes https://github.com/ChromeDevTools/chrome-devtools-mcp/issues/492

---------

Co-authored-by: Nikolay Vitkov <34244704+Lightning00Blade@users.noreply.github.com>
2025-11-07 12:55:01 +01:00
Alex Rudenko c06f4522ee refactor: merge emulate tools into one (#494)
Merges emulateCpu and emulateNetwork into a single tool to reduce token
consumption. Changes descriptions to be more concise.
2025-10-30 08:50:36 +00:00
iamitesh 139ce60781 feat: Add offline network emulation support to emulate_network command (#326)
https://github.com/ChromeDevTools/chrome-devtools-mcp/issues/320
Issue:
It would be very useful to have the ability to simulate offline network
conditions directly through the MCP emulate_network command, similar to
how it's possible in DevTools.
Currently, the command doesn’t support an Offline state, which limits
testing for PWA and offline-first web applications. Adding this option
would make it easier to automate and validate offline behavior through
MCP scripts or tools that rely on this API.

Solution
- Add 'Offline' option to throttlingOptions for simulating offline
network conditions
- Update emulate_network tool to handle offline mode with proper network
conditions
- Update documentation to include offline option and usage instructions
- Add test coverage for offline network emulation functionality
- Enable testing of PWA and offline-first web applications through MCP
2025-10-10 09:22:16 +02:00
Nikolay Vitkov 15277541d8 chore: add additional EsLint rule (#147) 2025-09-25 17:20:01 +02:00
Nikolay Vitkov 1e8662f068 fix(emulation): correctly report info for selected page (#63)
Previously if one page was setting emulation all were reporting it.
2025-09-22 16:03:47 +02:00
Alex Rudenko 31a0bdce26 feat: initial version 2025-09-11 12:46:05 +02:00