文件历史

提交图

62 次代码提交

作者 SHA1 备注 提交日期
Nikolay Vitkov 77e1d3f961 refactor: use a destructor to shorten the calls (#2376) 2026-07-16 11:50:44 +00:00
Dominik Inführ f78a911dc0 feat: Emit native contexts in snapshot summary (#2375)
Emits native contexts and their sizes with the get_heapsnapshot_summary
MCP tool. This should help the agent get an overview about which native
contexts consume the most memory.

Co-authored-by: Dominik Inführ <dinfuehr@chromium.org>
2026-07-16 11:16:00 +00:00
Alex Rudenko 9c3542bd74 refactor: move and rename files (#2355)
- move utilities to sub-folders where applicable
- changes issue-descriptions to issuesDescriptions.ts and moves it to
devtools/
2026-07-13 10:58:14 +00:00
Alex Rudenko b703f2ce20 fix(snapshot): resolve element ids on the correct snapshot (#2295)
closes https://github.com/ChromeDevTools/chrome-devtools-mcp/issues/2243

This probably regressed with the addition of third party developer tools
because the resolveCdpElementId was not moved from page to TextSnapshot.
2026-07-06 09:08:46 +00:00
Dominik Inführ 5d7b656050 feat: Add MCP tools for heap snapshot comparison (#2198)
This commit adds two MCP tools for comparing heap snapshots.
`compare_heapsnapshot_summary` compares two memory snapshot and returns
which classes have new/deleted objects.
`compare_heapsnapshot_class_nodes` can then be used to list the object
ids added and deleted for a specific class.

Co-authored-by: Dominik Inführ <dinfuehr@chromium.org>
2026-06-30 13:24:21 +00:00
nyxst4ck 5a9d6af743 fix(network): keep redirect chain order consistent between text and JSON (#2221)
## Problem

`get_network_request` returns, from the **same call**, both a
human-readable
text block (`toStringDetailed()`) and a
`structuredContent.networkRequest`
object (`toJSONDetailed()`) — emitted together in `McpResponse.ts`. For
a
request that went through HTTP redirects, the redirect chain comes out
in
**opposite orders** in the two representations:

- `toJSONDetailed()` (`NetworkFormatter.ts`) reverses `redirectChain()`
once →
  newest→oldest in the JSON.
- the text formatter then reverses it **a second time** → oldest→newest
in the
  text.

Because each path calls `redirectChain()` separately and Puppeteer
returns a
fresh copy on every call (`HTTPRequest#redirectChain()` does
`this._redirectChain.slice()`), the two reverses operate on different
arrays and
don't cancel. So a consumer reading the text and a consumer parsing the
structured JSON from the same response see contradictory redirect
orders.

## Solution

Drop the redundant `.reverse()` in the text formatter so the rendered
text uses
the order already produced by `toJSONDetailed()`. Both representations
are now
consistent (newest→oldest), and `structuredContent` is unchanged.

## Why the existing tests didn't catch it

- The existing "handles redirect chain" test uses a **single-element**
chain,
  where reversing is a no-op.
- `getMockRequest().redirectChain()` returned the **same array
reference** on
every call, unlike real Puppeteer — so the two reverses accidentally
agreed in
tests. This PR makes the mock return a fresh copy per call (matching
Puppeteer)
and adds a regression test with a multi-element chain that asserts the
text and
  JSON orders match.

## Testing

- `npm test` for the formatter suite passes. New test
`renders the redirect chain in the same order in text and JSON` is
**red**
before the fix (text `[first, second]` vs JSON `[second, first]`) and
**green**
  after, with no change to existing snapshots.
- `npm run typecheck` and Prettier/ESLint are clean.

No existing issue tracked this; found via code inspection and confirmed
empirically.
2026-06-18 17:18:14 +00:00
Dominik Inführ 08c234ea4b feat: Add get_heapsnapshot_dominators MCP tool (#2215)
Adding the get_heapsnapshot_dominators MCP tool to show the dominators
for a given node. In combination with get_heapsnapshot_retaining_paths
this should help understand what keeps an object reachable and thus
alive.

Co-authored-by: Dominik Inführ <dinfuehr@chromium.org>
Co-authored-by: Nicholas Roscino <nroscino@google.com>
2026-06-16 12:07:41 +00:00
Dominik Inführ a97c642d43 feat: Add retaining paths MCP tool (#2187)
This PR adds the `get_heapsnapshot_retaining_paths` MCP tool. This can
be used to find the paths from the target object to the GC roots which
keep that object alive.

Co-authored-by: Dominik Inführ <dinfuehr@chromium.org>
2026-06-09 12:53:30 +00:00
Nikolay Vitkov bede4fbdfa chore: install HostBindingAdapter (#2186)
This PR introduces the HostBindingAdapter to utilize the functions
usually available to DevTools.
Additionally I moved all the DevTools related files under a `devtools`
directory to better separate the extractor logic.
The patch scripts for DevTools were moved under a function to remove the
side-effect nature of the file.
Now gets called in a the creation of the McpContext (and a before hook
in test.)
2026-06-09 12:18:25 +00:00
Alex Rudenko f8fb2a9236 test: drop node20 code in tests (#2146) 2026-05-27 11:12:22 +00:00
Nikolay Vitkov 32dc50d59b chore(memory): update names and exposed information (#2079)
Update the tools to all include the `heapsnapshot` term for easier
handling.
Renames UID to ID to reduce confusion with the snapshot UIDs.
Renames Id to NodeId to better differentiate from the base Id.
Remove EdgeIndex as it was not useful.

Closes:
https://github.com/ChromeDevTools/chrome-devtools-mcp/issues/1970
2026-05-18 16:49:41 +00:00
Nikolay Vitkov b2b05a0670 chore(memory): expose retainer logic (#2056)
Allows the LLM to query the heapsnapshot further to understand what the
retainer path logic.
2026-05-18 09:54:00 +00:00
Nikolay Vitkov 66dacb83fd chore(memory): sort all by retainer size (#1963)
This is a better measurement as if object self size is X and the
retainerSize Y. X will always be smaller then Y, there Y will be the
actual size on the Heap.
2026-04-28 14:32:04 +00:00
Alex Rudenko 80bee1e6cd fix: note about missing elements should not show in verbose mode (#1950)
Closes https://github.com/ChromeDevTools/chrome-devtools-mcp/issues/1947
2026-04-24 07:29:05 +00:00
@masamaru0513 dbddb2e4ef feat: group identical consecutive console messages in list_console_messages (#1939)
## Summary

Group consecutive identical console messages in `list_console_messages`,
similar to Chrome DevTools' console grouping behavior.

Fixes #904

## Changes

- Introduce `GroupedConsoleFormatter` subclass that extends
`ConsoleFormatter` and overrides `toString()` / `toJSON()` for
count-aware formatting
- Add `ConsoleFormatter.groupConsecutive()` static method that groups
consecutive messages with the same type, text, and argument count
- Apply grouping **before pagination** so grouped counts are accurate
and page sizes reflect the collapsed view
- Add unit tests for grouping logic, string formatting, and JSON output

## Key design decisions

- **`GroupedConsoleFormatter` subclass**: Keeps the existing formatter
interface clean — no new methods added to `ConsoleFormatter`.
`ConsoleFormatter` and `GroupedConsoleFormatter` are interchangeable via
the same interface.
- **Grouping before pagination** (not at format time): This was the
feedback on #963 and #1025 — grouping at format time breaks pagination
counts. This implementation groups in `McpResponse` before calling
`paginate()`.
- **No `lastId`**: Since grouped messages are truly identical, only the
first message's ID is needed.
- **`argCount` matching**: Prevents false grouping of messages with the
same text but different argument counts.

## Output example

```
msgid=1 [log] hello world (1 args) [5 times]
```

## Testing

- Unit tests in `tests/formatters/ConsoleFormatterGrouping.test.ts`
- Manual verification: identical messages (×5), mixed pattern (A,A,B,A,A
→ A×2, B×1, A×2)
2026-04-23 09:55:18 +00:00
Wolfgang Beyer e046c23563 chore: in-page tool output: stash DOM elements and preprocess for serialization (#1877)
Improvements for handling in-page tool responses. In order to
successfully pass an in-page tool response from the page context to the
MCP server, the response needs to be serializable. The code walks the
response object an performs the following changes:

- DOM elements are stashed onto the window object and replaced with an
ID. On the MCP server side this ID is used to map back to the
corresponding UID in the page snapshot generated from the accessibility
tree.
- Circular references are replaced with a string.
- Class instances (which can be complex or non-serializable) are
replaced with a string.
- Functions are replaced with a string.

If the in-page tool response contains DOM elements which are not part of
the page snapshot, a new snapshot is created add the missing elements
are added explicitly.
2026-04-22 14:51:09 +00:00
Nikolay Vitkov 9211c6b52d chore(memory): expose a tool for getting the inital data. (#1909)
This refactors the code to extract the Id logic from the PageCollector
and provide it in the heapsnapshot.
We need to use an UID as we need the internal ClassKey to query the
heapsnapshot, but that is a strange string (usually looking like
`,ClassName`) which may get the LLM confused as we use comma separated
output.
2026-04-20 18:39:48 +00:00
Nikolay Vitkov 0331f6a8a2 chore: implement memory snapshot information (#1874)
WIP of exposing a tool for debugging memory issue directly with the MCP
2026-04-17 12:40:41 +00:00
Nikolay Vitkov 2f458c11eb fix(network): trailing data in Network redirect chain (#1880)
Closes https://github.com/ChromeDevTools/chrome-devtools-mcp/pull/1808
2026-04-17 12:19:46 +00:00
Alex Rudenko 5c398c4e7c feat: support DevTools header redactions as an option (#1848)
This PR adds a CLI flag to enable redacting network headers in the same
way they are redacted in DevTools. Note that sometimes it might prevent
the agent from properly analysing network issues. Pass
`--redact-headers=false` to revert to the previous behavior.
2026-04-14 13:21:11 +00:00
Nikolay Vitkov e56d79393c chore: don't re-export internals (#1211) 2026-03-20 13:15:06 +00:00
Alex Rudenko 9ef4479bec refactor: types for JSON output of IssueFormatter (#1007)
- makes the id required in types
- requires toString(), toStringDetailed() to use the JSON
representation.
2026-02-23 08:03:09 +00:00
Alex Rudenko 0d78685a5b refactor: cleanup string and structured console formatters (#1005)
- typed JSON objects for structured output
- same source is used for text formatting
2026-02-20 11:43:35 +00:00
Alex Rudenko c9691c6250 test: fix missing sinon.restore (#989) 2026-02-18 15:39:30 +00:00
Nikolay Vitkov 327a3884d8 refactor: remove text from the status code for Network requests (#778)
LLM are trained to know the common status code so we can rely on that
when displaying the status code and fall back to text in case of errors
or pending reponse.
2026-02-18 14:23:26 +00:00
Alex Rudenko d59bca4ddf test: add tests for more a11y attributes (#934)
I think this covers all a11y attributes from CDP + we have now verbose
vs non-verbose mode.

Closes https://github.com/ChromeDevTools/chrome-devtools-mcp/issues/363
2026-02-11 09:03:10 +00:00
Simon Zünd 8e2380b434 fix: console formatter hides frames from ignored scripts (#927)
This PR wires up the default DevTools ignore listing to hide frames from
third party scripts in stack traces. By default, we ignore:

* Scripts with `/node_modules/` in their URL or where the URL starts
with `node:/`
* Scripts that are marked as ignore listed in the source map
* Content scripts from extensions

The PR adds both, unit tests and an e2e test. This is because we allow
the unit test to pass a mocked ignore checker, where-as the e2e uses the
real DevTools one.
2026-02-10 07:24:09 +00:00
Simon Zünd caea23a7cf fix: limit stack traces to 50 lines (#923)
This PR refactors the stack trace formatting logic a bit: We split the
`formatStackTrace` function into 2: One for the top-level stack trace
and the rest for the recursive ones. We also return lines separately so
we can slice the result later.
2026-02-09 12:06:04 +00:00
Simon Zünd 9b90564888 chore: implement formatting for Error.cause messages (#905)
A follow-up PR will add actual `cause` property resolving of remote
`Error` objects.
2026-02-06 11:28:40 +00:00
Simon Zünd ffa00dab1b feat: show message and stack trace in details when console.log'ging Error objects (#902)
This PR improves the `get_console_message` tool when logging `Error`
objects. We use the existing `getExceptionDetails` CDP command to
retrieve the structured stack trace, we'll then source map.

Example:

```js
try {
  compute();
} catch (e) {
  console.log('Compute failed', e);
}
```

Before:
```txt
### Arguments
Arg #0: Compute failed
Arg #1: {}
```

After:
```txt
### Arguments
Arg #0: Compute failed
Arg #1: ComputeError: Invariant violation
at compute (foo.ts:1:20)
at <anonymous> (main.ts:2:8)
Note: line and column numbers use 1-based indexing
```

---------

Co-authored-by: Alex Rudenko <OrKoN@users.noreply.github.com>
2026-02-06 09:38:27 +00:00
Simon Zünd 1fad330bad chore: implement formatting of Error console.log arguments (#901)
This PR implements formatting for `SymbolizedError` objects that are
part of "resolved arguments". A follow-up PR will handle the actual
conversion of `Error` remote objects to `SymbolizedError`s.
2026-02-06 08:25:38 +00:00
Simon Zünd f4cfd4664e chore: introduce SymbolizedError class (#890)
The "SymbolizedError" class represents a fully resolved error: The stack
trace is fully resolved and (in the future), the full `Error.cause`
chain is also fully resolved.

We'll use the `SymbolizedError` for both "uncaught exceptions" as well
as when logging `Error` objects to the console (e.g. `console.log(new
Error())`. This means the `resolvedArgs` array in `ConsoleFormatter`
will contain one `SymbolizedError` instance for every `Error` object
logged.
2026-02-05 07:57:21 +00:00
Simon Zünd 7e1ec81fb6 fix: use 1-based line/column and fix wasm offsets in stack frames (#884)
`UILocation.linkText` does the right thing when formatting a location,
e.g. a wasm location will be formatted as `foo.wasm:0x95`.
2026-02-04 08:15:27 +00:00
Simon Zünd a08f550b28 chore: implement formatting for UncaughtError (#875) 2026-02-03 11:42:18 +00:00
Alex Rudenko 695817f6d6 fix: make request and response handling more robust (#846)
Closes https://github.com/ChromeDevTools/chrome-devtools-mcp/issues/842
2026-01-27 12:35:47 +00:00
Alex Rudenko dc43ede1f2 fix: improve error handling for console messages (#844)
Closes https://github.com/ChromeDevTools/chrome-devtools-mcp/issues/838
2026-01-27 12:27:10 +00:00
Alex Rudenko b0d041a0b2 chore: structured content for console (#804) 2026-01-22 06:53:03 +00:00
Alex Rudenko feee900a4c chore: create a console formatter class (#802)
This cleans up the McpResponse and helps with returning the structured
content.
2026-01-21 10:04:20 +00:00
Alex Rudenko c29d097b92 chore: extract issue formatter in preparation to structured content (#794)
This makes it easier to add JSON-format as the output for issues.
Console formatter will be changed next.
2026-01-20 07:03:30 +00:00
Alex Rudenko 6d0e4cab28 feat: support filePath for network request and response bodies (#795)
Closes https://github.com/ChromeDevTools/chrome-devtools-mcp/issues/377
2026-01-19 12:44:59 +00:00
Alex Rudenko 755eeef3af chore: support structured network (#774)
This PR adds a structured variant of the network responses and refactors
the code accordingly.
2026-01-15 11:59:00 +00:00
Alex Rudenko 3fcca026cb chore: support structured content (#744)
The idea is to turn formatters into instances and support both text and
JSON formatting. The structured content is output if the experimental
structured content flag is passed. For now, only the snapshots are
returned in a structured way.

Refs https://github.com/ChromeDevTools/chrome-devtools-mcp/issues/689
2026-01-12 13:53:12 +00:00
Simon Zünd b48e10b69c chore: implement stack trace formatting for console messages (#738)
The PR only implements the formatting, we don't create
`DevTools.StackTrace` instances from puppeteer console message stack
traces yet.
2026-01-08 10:27:28 +01:00
Alex Rudenko 7114bb1bf3 chore: integrate issues and fix up checks (#628) 2025-11-28 09:16:32 +00:00
Natasha Gorshunova 63b826cfe0 chore: report issues in details in get_console_mesasge (#611)
Co-authored-by: Natallia Harshunova <nharshunova@chromium.org>
2025-11-27 08:08:47 +01:00
Natasha Gorshunova 326c279179 chore: report console issues in get_console_messages (#594)
Co-authored-by: Natallia Harshunova <nharshunova@chromium.org>
2025-11-25 11:41:14 +01:00
Alex Rudenko 80e77fd9a3 fix: include a note about selected elements missing from the snapshot (#593)
Closes https://github.com/ChromeDevTools/chrome-devtools-mcp/issues/586
2025-11-21 11:14:44 +01:00
Alex Rudenko 4a83574961 feat: fetch DOM node selected in the DevTools Elements panel (#486)
Refs https://github.com/ChromeDevTools/chrome-devtools-mcp/issues/129
2025-10-31 11:07:10 +01:00
Alex Rudenko 2f448e84ea fix: improve get_network_request description (#500)
Closes https://github.com/ChromeDevTools/chrome-devtools-mcp/issues/497
2025-10-30 11:52:09 +01:00
Alex Rudenko 796aed72b7 feat: detect network requests inspected in DevTools UI (#477)
If you manually inspect a network request in the DevTools UI, the Chrome
DevTools MCP server is now able to detect it and allow you to refer to
the selected request. The approach was tested in a couple of models.

In the list of the network requests we have a short indication about
which request is selected in DevTools UI. We refer to the DevTools as
"DevTools UI" to disambiguate from the DevTools MCP server.
2025-10-28 10:52:09 +01:00