brave-mcp 0.4.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (120) hide show
  1. package/README.md +97 -29
  2. package/build/src/HeapSnapshotManager.js +55 -18
  3. package/build/src/McpContext.js +94 -32
  4. package/build/src/McpPage.js +9 -9
  5. package/build/src/McpResponse.js +167 -63
  6. package/build/src/PageCollector.js +8 -8
  7. package/build/src/ServiceWorkerCollector.js +171 -0
  8. package/build/src/TextSnapshot.js +1 -1
  9. package/build/src/ToolHandler.js +223 -0
  10. package/build/src/WaitForHelper.js +20 -6
  11. package/build/src/bin/brave-devtools-cli-options.js +136 -40
  12. package/build/src/bin/brave-devtools-mcp-cli-options.js +22 -11
  13. package/build/src/bin/brave-devtools-mcp-main.js +45 -6
  14. package/build/src/bin/brave-devtools.js +22 -7
  15. package/build/src/bin/check-latest-version.js +25 -1
  16. package/build/src/browser.js +61 -7
  17. package/build/src/daemon/client.js +19 -13
  18. package/build/src/daemon/daemon.js +74 -17
  19. package/build/src/daemon/utils.js +2 -2
  20. package/build/src/{DevToolsConnectionAdapter.js → devtools/DevToolsConnectionAdapter.js} +1 -1
  21. package/build/src/{DevtoolsUtils.js → devtools/DevtoolsUtils.js} +94 -19
  22. package/build/src/formatters/ConsoleFormatter.js +1 -1
  23. package/build/src/formatters/HeapSnapshotFormatter.js +44 -9
  24. package/build/src/formatters/IssueFormatter.js +4 -4
  25. package/build/src/index.js +24 -165
  26. package/build/src/telemetry/ClearcutLogger.js +35 -119
  27. package/build/src/telemetry/WatchdogClient.js +4 -4
  28. package/build/src/telemetry/errors.js +18 -0
  29. package/build/src/telemetry/flagUtils.js +4 -3
  30. package/build/src/telemetry/{toolMetricsUtils.js → metricsRegistry.js} +3 -3
  31. package/build/src/telemetry/persistence.js +21 -3
  32. package/build/src/telemetry/transformation.js +134 -0
  33. package/build/src/telemetry/types.js +0 -8
  34. package/build/src/telemetry/watchdog/ClearcutSender.js +10 -10
  35. package/build/src/telemetry/watchdog/main.js +5 -5
  36. package/build/src/third_party/THIRD_PARTY_NOTICES +3637 -0
  37. package/build/src/third_party/bundled-packages.json +12 -0
  38. package/build/src/third_party/devtools-formatter-worker.js +15300 -7
  39. package/build/src/third_party/devtools-heap-snapshot-worker.js +9817 -7
  40. package/build/src/third_party/index.js +159331 -27
  41. package/build/src/third_party/issue-descriptions/emailVerificationRequestAccountsEmptyList.md +1 -0
  42. package/build/src/third_party/issue-descriptions/emailVerificationRequestAccountsHttpNotFound.md +1 -0
  43. package/build/src/third_party/issue-descriptions/emailVerificationRequestAccountsInvalidContentType.md +1 -0
  44. package/build/src/third_party/issue-descriptions/emailVerificationRequestAccountsInvalidResponse.md +1 -0
  45. package/build/src/third_party/issue-descriptions/emailVerificationRequestAccountsNoResponse.md +1 -0
  46. package/build/src/third_party/issue-descriptions/emailVerificationRequestDnsFetchFailed.md +1 -0
  47. package/build/src/third_party/issue-descriptions/emailVerificationRequestDnsInvalidRecord.md +1 -0
  48. package/build/src/third_party/issue-descriptions/emailVerificationRequestEmailVerificationWellKnownHttpNotFound.md +1 -0
  49. package/build/src/third_party/issue-descriptions/emailVerificationRequestEmailVerificationWellKnownInvalidContentType.md +1 -0
  50. package/build/src/third_party/issue-descriptions/emailVerificationRequestEmailVerificationWellKnownInvalidResponse.md +1 -0
  51. package/build/src/third_party/issue-descriptions/emailVerificationRequestEmailVerificationWellKnownNoResponse.md +1 -0
  52. package/build/src/third_party/issue-descriptions/emailVerificationRequestInvalidEmail.md +1 -0
  53. package/build/src/third_party/issue-descriptions/emailVerificationRequestJwksHttpNotFound.md +1 -0
  54. package/build/src/third_party/issue-descriptions/emailVerificationRequestJwksInvalidResponse.md +1 -0
  55. package/build/src/third_party/issue-descriptions/emailVerificationRequestKeyBindingSigningFailed.md +1 -0
  56. package/build/src/third_party/issue-descriptions/emailVerificationRequestRpOriginIsOpaque.md +1 -0
  57. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenHttpNotFound.md +1 -0
  58. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenInvalidContentType.md +1 -0
  59. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenInvalidResponse.md +1 -0
  60. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenInvalidSdJwt.md +1 -0
  61. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenMalformedSdJwt.md +1 -0
  62. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenNoResponse.md +1 -0
  63. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationKbInvalidAudience.md +1 -0
  64. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationKbInvalidIssuedAt.md +1 -0
  65. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationKbInvalidNonce.md +1 -0
  66. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationKbInvalidSdHash.md +1 -0
  67. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationKbInvalidTyp.md +1 -0
  68. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationKbMissingAud.md +1 -0
  69. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationKbMissingCnf.md +1 -0
  70. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationKbMissingIat.md +1 -0
  71. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationKbMissingNonce.md +1 -0
  72. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationKbMissingSdHash.md +1 -0
  73. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationKbSignatureFailed.md +1 -0
  74. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationSdJwtInvalidEmail.md +1 -0
  75. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationSdJwtInvalidEmailVerified.md +1 -0
  76. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationSdJwtInvalidHolderKey.md +1 -0
  77. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationSdJwtInvalidIssuedAt.md +1 -0
  78. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationSdJwtInvalidIssuer.md +1 -0
  79. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationSdJwtJwksMissingKeys.md +1 -0
  80. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationSdJwtMissingCnf.md +1 -0
  81. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationSdJwtMissingEmail.md +1 -0
  82. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationSdJwtMissingIat.md +1 -0
  83. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationSdJwtMissingIss.md +1 -0
  84. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationSdJwtSignatureFailed.md +1 -0
  85. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationSdJwtUnsupportedHeaderAlg.md +1 -0
  86. package/build/src/third_party/issue-descriptions/emailVerificationRequestUserLoggedOut.md +1 -0
  87. package/build/src/third_party/issue-descriptions/emailVerificationRequestWellKnownAccountsEndpointCrossOrigin.md +1 -0
  88. package/build/src/third_party/issue-descriptions/emailVerificationRequestWellKnownHttpNotFound.md +1 -0
  89. package/build/src/third_party/issue-descriptions/emailVerificationRequestWellKnownInvalidContentType.md +1 -0
  90. package/build/src/third_party/issue-descriptions/emailVerificationRequestWellKnownInvalidResponse.md +1 -0
  91. package/build/src/third_party/issue-descriptions/emailVerificationRequestWellKnownIssuanceEndpointCrossOrigin.md +1 -0
  92. package/build/src/third_party/issue-descriptions/emailVerificationRequestWellKnownListEmpty.md +1 -0
  93. package/build/src/third_party/issue-descriptions/emailVerificationRequestWellKnownMissingAccountsEndpoint.md +1 -0
  94. package/build/src/third_party/issue-descriptions/emailVerificationRequestWellKnownMissingIssuanceEndpoint.md +1 -0
  95. package/build/src/third_party/issue-descriptions/emailVerificationRequestWellKnownNoResponse.md +1 -0
  96. package/build/src/third_party/issue-descriptions/emailVerificationRequestWellKnownUnsupportedSigningAlgorithm.md +1 -0
  97. package/build/src/third_party/issue-descriptions/genericBackUINavigationWouldSkipAd.md +4 -0
  98. package/build/src/third_party/lighthouse-devtools-mcp-bundle.js +4236 -4219
  99. package/build/src/tools/ToolDefinition.js +2 -2
  100. package/build/src/tools/console.js +7 -0
  101. package/build/src/tools/emulation.js +29 -2
  102. package/build/src/tools/extensions.js +5 -0
  103. package/build/src/tools/input.js +57 -19
  104. package/build/src/tools/lighthouse.js +18 -13
  105. package/build/src/tools/memory.js +97 -21
  106. package/build/src/tools/network.js +2 -2
  107. package/build/src/tools/pages.js +13 -5
  108. package/build/src/tools/performance.js +15 -11
  109. package/build/src/tools/screencast.js +2 -1
  110. package/build/src/tools/screenshot.js +1 -1
  111. package/build/src/tools/script.js +33 -11
  112. package/build/src/tools/slim/tools.js +3 -0
  113. package/build/src/tools/snapshot.js +3 -2
  114. package/build/src/tools/thirdPartyDeveloper.js +12 -2
  115. package/build/src/tools/webmcp.js +2 -0
  116. package/build/src/trace-processing/parse.js +7 -7
  117. package/build/src/utils/files.js +43 -0
  118. package/build/src/version.js +4 -1
  119. package/package.json +21 -17
  120. package/build/src/telemetry/metricUtils.js +0 -15
package/README.md CHANGED
@@ -38,7 +38,7 @@ You can explicitly enable them with `--usage-statistics` if desired.
38
38
 
39
39
  ## Requirements
40
40
 
41
- - [Node.js](https://nodejs.org/) v20.19 or a newer [latest maintenance LTS](https://github.com/nodejs/Release#release-schedule) version.
41
+ - [Node.js](https://nodejs.org/) [LTS](https://github.com/nodejs/Release#release-schedule) version.
42
42
  - [Brave Browser](https://brave.com/) current release version or newer.
43
43
  - [npm](https://www.npmjs.com/)
44
44
 
@@ -96,7 +96,9 @@ If Brave is not detected automatically, set `BRAVE_PATH`:
96
96
  "mcpServers": {
97
97
  "brave-devtools": {
98
98
  "command": "node",
99
- "args": ["/absolute/path/to/brave-devtools-mcp/build/src/bin/brave-devtools-mcp.js"],
99
+ "args": [
100
+ "/absolute/path/to/brave-devtools-mcp/build/src/bin/brave-devtools-mcp.js"
101
+ ],
100
102
  "env": {
101
103
  "BRAVE_PATH": "/Applications/Brave Browser.app/Contents/MacOS/Brave Browser"
102
104
  }
@@ -139,7 +141,12 @@ brave-browser --remote-debugging-port=9222
139
141
  "mcpServers": {
140
142
  "brave-devtools": {
141
143
  "command": "npx",
142
- "args": ["-y", "brave-mcp@latest", "--browserUrl", "http://localhost:9222"]
144
+ "args": [
145
+ "-y",
146
+ "brave-mcp@latest",
147
+ "--browserUrl",
148
+ "http://localhost:9222"
149
+ ]
143
150
  }
144
151
  }
145
152
  }
@@ -154,7 +161,8 @@ Or if running from source:
154
161
  "command": "node",
155
162
  "args": [
156
163
  "/absolute/path/to/brave-devtools-mcp/build/src/bin/brave-devtools-mcp.js",
157
- "--browserUrl", "http://localhost:9222"
164
+ "--browserUrl",
165
+ "http://localhost:9222"
158
166
  ]
159
167
  }
160
168
  }
@@ -198,7 +206,8 @@ If you are interested in only basic browser tasks, use `--slim` mode:
198
206
  "command": "node",
199
207
  "args": [
200
208
  "/absolute/path/to/brave-devtools-mcp/build/src/bin/brave-devtools-mcp.js",
201
- "--slim", "--headless"
209
+ "--slim",
210
+ "--headless"
202
211
  ]
203
212
  }
204
213
  }
@@ -270,7 +279,7 @@ To install Chrome DevTools MCP with skills, add the marketplace registry in Clau
270
279
  Then, install the plugin:
271
280
 
272
281
  ```sh
273
- /plugin install chrome-devtools-mcp
282
+ /plugin install chrome-devtools-mcp@chrome-devtools-plugins
274
283
  ```
275
284
 
276
285
  Restart Claude Code to have the MCP server and skills load (check with `/skills`).
@@ -358,7 +367,7 @@ and the expert guidance it needs to use them effectively.
358
367
 
359
368
  1. Open the **Command Palette** (`Cmd+Shift+P` on macOS or `Ctrl+Shift+P` on Windows/Linux).
360
369
  2. Search for and run the **Chat: Install Plugin From Source** command.
361
- 3. Paste in our repository URL: `https://github.com/ChromeDevTools/chrome-devtools-mcp`
370
+ 3. Paste in our repository name: `ChromeDevTools/chrome-devtools-mcp`.
362
371
 
363
372
  That's it! Your agent is now supercharged with Chrome DevTools capabilities.
364
373
 
@@ -623,11 +632,14 @@ If you run into any issues, checkout our [troubleshooting guide](./docs/troubles
623
632
  - [`take_snapshot`](docs/tool-reference.md#take_snapshot)
624
633
  - [`screencast_start`](docs/tool-reference.md#screencast_start)
625
634
  - [`screencast_stop`](docs/tool-reference.md#screencast_stop)
626
- - **Memory** (4 tools)
627
- - [`take_memory_snapshot`](docs/tool-reference.md#take_memory_snapshot)
628
- - [`get_memory_snapshot_details`](docs/tool-reference.md#get_memory_snapshot_details)
629
- - [`get_nodes_by_class`](docs/tool-reference.md#get_nodes_by_class)
630
- - [`load_memory_snapshot`](docs/tool-reference.md#load_memory_snapshot)
635
+ - **Memory** (7 tools)
636
+ - [`take_heapsnapshot`](docs/tool-reference.md#take_heapsnapshot)
637
+ - [`close_heapsnapshot`](docs/tool-reference.md#close_heapsnapshot)
638
+ - [`get_heapsnapshot_class_nodes`](docs/tool-reference.md#get_heapsnapshot_class_nodes)
639
+ - [`get_heapsnapshot_details`](docs/tool-reference.md#get_heapsnapshot_details)
640
+ - [`get_heapsnapshot_retainers`](docs/tool-reference.md#get_heapsnapshot_retainers)
641
+ - [`get_heapsnapshot_retaining_paths`](docs/tool-reference.md#get_heapsnapshot_retaining_paths)
642
+ - [`get_heapsnapshot_summary`](docs/tool-reference.md#get_heapsnapshot_summary)
631
643
  - **Extensions** (5 tools)
632
644
  - [`install_extension`](docs/tool-reference.md#install_extension)
633
645
  - [`list_extensions`](docs/tool-reference.md#list_extensions)
@@ -650,16 +662,16 @@ The Brave DevTools MCP server supports the following configuration options:
650
662
  <!-- BEGIN AUTO GENERATED OPTIONS -->
651
663
 
652
664
  - **`--autoConnect`/ `--auto-connect`**
653
- If specified, automatically connects to a browser (Chrome 144+) running locally from the user data directory identified by the channel param (default channel is stable). Requires the remote debugging server to be started in the Chrome instance via chrome://inspect/#remote-debugging.
665
+ If specified, automatically connects to a Brave instance running locally from the user data directory identified by the channel param (default channel is release). Requires the remote debugging server to be started in the Brave instance via brave://inspect/#remote-debugging.
654
666
  - **Type:** boolean
655
667
  - **Default:** `false`
656
668
 
657
669
  - **`--browserUrl`/ `--browser-url`, `-u`**
658
- Connect to a running, debuggable Chrome instance (e.g. `http://127.0.0.1:9222`). For more details see: https://github.com/ChromeDevTools/chrome-devtools-mcp#connecting-to-a-running-chrome-instance.
670
+ Connect to a running, debuggable Brave instance (e.g. `http://127.0.0.1:9222`).
659
671
  - **Type:** string
660
672
 
661
673
  - **`--wsEndpoint`/ `--ws-endpoint`, `-w`**
662
- WebSocket endpoint to connect to a running Chrome instance (e.g., ws://127.0.0.1:9222/devtools/browser/<id>). Alternative to --browserUrl.
674
+ WebSocket endpoint to connect to a running Brave instance (e.g., ws://127.0.0.1:9222/devtools/browser/<id>). Alternative to --browserUrl.
663
675
  - **Type:** string
664
676
 
665
677
  - **`--wsHeaders`/ `--ws-headers`**
@@ -672,7 +684,7 @@ The Brave DevTools MCP server supports the following configuration options:
672
684
  - **Default:** `false`
673
685
 
674
686
  - **`--executablePath`/ `--executable-path`, `-e`**
675
- Path to custom Chrome executable.
687
+ Path to custom Brave executable. Can also be set via BRAVE_PATH environment variable.
676
688
  - **Type:** string
677
689
 
678
690
  - **`--isolated`**
@@ -680,34 +692,54 @@ The Brave DevTools MCP server supports the following configuration options:
680
692
  - **Type:** boolean
681
693
 
682
694
  - **`--userDataDir`/ `--user-data-dir`**
683
- Path to the user data directory for Chrome. Default is $HOME/.cache/chrome-devtools-mcp/chrome-profile$CHANNEL_SUFFIX_IF_NON_STABLE
695
+ Path to the user data directory for Brave. Default is $HOME/.cache/brave-devtools-mcp/brave-profile$CHANNEL_SUFFIX_IF_NON_RELEASE
684
696
  - **Type:** string
685
697
 
686
698
  - **`--channel`**
687
- Specify a different Chrome channel that should be used. The default is the stable channel version.
699
+ Specify a different Brave channel that should be used. The default is the release channel.
688
700
  - **Type:** string
689
- - **Choices:** `canary`, `dev`, `beta`, `stable`
701
+ - **Choices:** `release`, `beta`, `nightly`, `dev`
690
702
 
691
703
  - **`--logFile`/ `--log-file`**
692
704
  Path to a file to write debug logs to. Set the env variable `DEBUG` to `*` to enable verbose logs. Useful for submitting bug reports.
693
705
  - **Type:** string
694
706
 
695
707
  - **`--viewport`**
696
- Initial viewport size for the Chrome instances started by the server. For example, `1280x720`. In headless mode, max size is 3840x2160px.
708
+ Initial viewport size for the Brave instances started by the server. For example, `1280x720`. In headless mode, max size is 3840x2160px.
697
709
  - **Type:** string
698
710
 
699
711
  - **`--proxyServer`/ `--proxy-server`**
700
- Proxy server configuration for Chrome passed as --proxy-server when launching the browser. See https://www.chromium.org/developers/design-documents/network-settings/ for details.
712
+ Proxy server configuration for Brave passed as --proxy-server when launching the browser. See https://www.chromium.org/developers/design-documents/network-settings/ for details.
701
713
  - **Type:** string
702
714
 
703
715
  - **`--acceptInsecureCerts`/ `--accept-insecure-certs`**
704
716
  If enabled, ignores errors relative to self-signed and expired certificates. Use with caution.
705
717
  - **Type:** boolean
706
718
 
719
+ - **`--experimentalPageIdRouting`/ `--experimental-page-id-routing`**
720
+ Whether to expose pageId on page-scoped tools and route requests by page ID (useful for concurrent agent sessions).
721
+ - **Type:** boolean
722
+
723
+ - **`--experimentalDevtools`/ `--experimental-devtools`**
724
+ Whether to enable automation over DevTools targets
725
+ - **Type:** boolean
726
+
707
727
  - **`--experimentalVision`/ `--experimental-vision`**
708
728
  Whether to enable coordinate-based tools such as click_at(x,y). Usually requires a computer-use model able to produce accurate coordinates by looking at screenshots.
709
729
  - **Type:** boolean
710
730
 
731
+ - **`--memoryDebugging`/ `--memory-debugging`, `-experimentalMemory`**
732
+ Whether to enable memory debugging tools.
733
+ - **Type:** boolean
734
+
735
+ - **`--experimentalStructuredContent`/ `--experimental-structured-content`**
736
+ Whether to output structured formatted content.
737
+ - **Type:** boolean
738
+
739
+ - **`--experimentalIncludeAllPages`/ `--experimental-include-all-pages`**
740
+ Whether to include all kinds of pages such as webviews or background pages as pages.
741
+ - **Type:** boolean
742
+
711
743
  - **`--experimentalScreencast`/ `--experimental-screencast`**
712
744
  Exposes experimental screencast tools (requires ffmpeg). Install ffmpeg https://www.ffmpeg.org/download.html and ensure it is available in the MCP server PATH.
713
745
  - **Type:** boolean
@@ -717,15 +749,23 @@ The Brave DevTools MCP server supports the following configuration options:
717
749
  - **Type:** string
718
750
 
719
751
  - **`--categoryExperimentalWebmcp`/ `--category-experimental-webmcp`**
720
- Set to true to enable debugging WebMCP tools. Requires Chrome 149+ with the following flags: `--enable-features=WebMCPTesting,DevToolsWebMCPSupport`
752
+ Set to true to enable debugging WebMCP tools. Requires Brave with the following flags: `--enable-features=WebMCPTesting,DevToolsWebMCPSupport`
721
753
  - **Type:** boolean
722
754
 
723
- - **`--chromeArg`/ `--chrome-arg`**
724
- Additional arguments for Chrome. Only applies when Chrome is launched by chrome-devtools-mcp.
755
+ - **`--braveArg`/ `--brave-arg`**
756
+ Additional arguments for Brave. Only applies when Brave is launched by brave-devtools-mcp.
757
+ - **Type:** array
758
+
759
+ - **`--blockedUrlPattern`/ `--blocked-url-pattern`**
760
+ Restricts network access by blocking specified URL patterns (uses https://urlpattern.spec.whatwg.org/). Silently detaches from targets with blocked URLs upon connection, and blocks runtime requests (including navigations and subresources). Accepts an array of patterns.
761
+ - **Type:** array
762
+
763
+ - **`--allowedUrlPattern`/ `--allowed-url-pattern`**
764
+ Restricts network access by allowing only specified URL patterns (uses https://urlpattern.spec.whatwg.org/). Requires Chrome 149+. Silently detaches from targets with unallowed URLs upon connection, and blocks runtime requests (including navigations and subresources). Accepts an array of patterns.
725
765
  - **Type:** array
726
766
 
727
- - **`--ignoreDefaultChromeArg`/ `--ignore-default-chrome-arg`**
728
- Explicitly disable default arguments for Chrome. Only applies when Chrome is launched by chrome-devtools-mcp.
767
+ - **`--ignoreDefaultBraveArg`/ `--ignore-default-brave-arg`**
768
+ Explicitly disable default arguments for Brave. Only applies when Brave is launched by brave-devtools-mcp.
729
769
  - **Type:** array
730
770
 
731
771
  - **`--categoryEmulation`/ `--category-emulation`**
@@ -759,16 +799,16 @@ The Brave DevTools MCP server supports the following configuration options:
759
799
  - **Default:** `true`
760
800
 
761
801
  - **`--usageStatistics`/ `--usage-statistics`**
762
- Set to false to opt-out of usage statistics collection. Google collects usage data to improve the tool, handled under the Google Privacy Policy (https://policies.google.com/privacy). This is independent from Chrome browser metrics. Disabled if `CHROME_DEVTOOLS_MCP_NO_USAGE_STATISTICS` or `CI` env variables are set.
802
+ Usage statistics collection (disabled by default in this fork).
763
803
  - **Type:** boolean
764
- - **Default:** `true`
804
+ - **Default:** `false`
765
805
 
766
806
  - **`--slim`**
767
807
  Exposes a "slim" set of 3 tools covering navigation, script execution and screenshots only. Useful for basic browser tasks.
768
808
  - **Type:** boolean
769
809
 
770
810
  - **`--redactNetworkHeaders`/ `--redact-network-headers`**
771
- If true, redacts some of the network headers considered senstive before returning to the client.
811
+ If true, redacts some of the network headers considered sensitive before returning to the client.
772
812
  - **Type:** boolean
773
813
  - **Default:** `false`
774
814
 
@@ -817,6 +857,34 @@ You can also run `npx chrome-devtools-mcp@latest --help` to see all available co
817
857
 
818
858
  ## Concepts
819
859
 
860
+ ### Concurrent sessions
861
+
862
+ Most MCP clients start one Chrome DevTools MCP server per conversation. If your
863
+ client shares a single server instance across concurrent agents or subagents,
864
+ start the server with `--experimentalPageIdRouting`. This exposes `pageId` on
865
+ page-scoped tools so each agent can route tool calls to the tab it is working
866
+ with.
867
+
868
+ ```json
869
+ {
870
+ "mcpServers": {
871
+ "chrome-devtools": {
872
+ "command": "npx",
873
+ "args": [
874
+ "-y",
875
+ "chrome-devtools-mcp@latest",
876
+ "--experimentalPageIdRouting"
877
+ ]
878
+ }
879
+ }
880
+ }
881
+ ```
882
+
883
+ If you run multiple independent MCP client sessions and want each session to
884
+ launch its own temporary Chrome profile, also pass `--isolated`. This avoids
885
+ sharing the default Chrome DevTools MCP user data directory between those
886
+ server instances.
887
+
820
888
  ### User data directory
821
889
 
822
890
  `brave-devtools-mcp` starts a Brave release channel instance using the following user
@@ -5,6 +5,7 @@
5
5
  */
6
6
  import fsSync from 'node:fs';
7
7
  import path from 'node:path';
8
+ import { isNodeLike } from './formatters/HeapSnapshotFormatter.js';
8
9
  import { DevTools } from './third_party/index.js';
9
10
  import { createIdGenerator, stableIdSymbol, } from './utils/id.js';
10
11
  export class HeapSnapshotManager {
@@ -19,8 +20,8 @@ export class HeapSnapshotManager {
19
20
  this.#snapshots.set(absolutePath, {
20
21
  snapshot,
21
22
  worker,
22
- uidToClassKey: new Map(),
23
- classKeyToUid: new Map(),
23
+ idToClassKey: new Map(),
24
+ classKeyToId: new Map(),
24
25
  idGenerator: createIdGenerator(),
25
26
  });
26
27
  return snapshot;
@@ -30,10 +31,10 @@ export class HeapSnapshotManager {
30
31
  const filter = new DevTools.HeapSnapshotModel.HeapSnapshotModel.NodeFilter();
31
32
  const aggregates = await snapshot.aggregatesWithFilter(filter);
32
33
  for (const key of Object.keys(aggregates)) {
33
- const uid = await this.getOrCreateUidForClassKey(filePath, key);
34
+ const id = await this.getOrCreateIdForClassKey(filePath, key);
34
35
  const aggregate = aggregates[key];
35
36
  if (aggregate) {
36
- aggregate[stableIdSymbol] = uid;
37
+ aggregate[stableIdSymbol] = id;
37
38
  }
38
39
  }
39
40
  return aggregates;
@@ -46,26 +47,57 @@ export class HeapSnapshotManager {
46
47
  const snapshot = await this.getSnapshot(filePath);
47
48
  return snapshot.staticData;
48
49
  }
49
- async getOrCreateUidForClassKey(filePath, classKey) {
50
+ async getOrCreateIdForClassKey(filePath, classKey) {
50
51
  const cached = this.#getCachedSnapshot(filePath);
51
- let uid = cached.classKeyToUid.get(classKey);
52
- if (!uid) {
53
- uid = cached.idGenerator();
54
- cached.classKeyToUid.set(classKey, uid);
55
- cached.uidToClassKey.set(uid, classKey);
52
+ let id = cached.classKeyToId.get(classKey);
53
+ if (!id) {
54
+ id = cached.idGenerator();
55
+ cached.classKeyToId.set(classKey, id);
56
+ cached.idToClassKey.set(id, classKey);
56
57
  }
57
- return uid;
58
+ return id;
58
59
  }
59
- async getNodesByUid(filePath, uid) {
60
+ async getNodesById(filePath, id) {
60
61
  const snapshot = await this.getSnapshot(filePath);
61
62
  const filter = new DevTools.HeapSnapshotModel.HeapSnapshotModel.NodeFilter();
62
- const className = await this.resolveClassKeyFromUid(filePath, uid);
63
+ const className = await this.resolveClassKeyFromId(filePath, id);
63
64
  if (!className) {
64
- throw new Error(`Class with UID ${uid} not found in heap snapshot`);
65
+ throw new Error(`Class with ID ${id} not found in heap snapshot`);
65
66
  }
66
67
  const provider = snapshot.createNodesProviderForClass(className, filter);
67
- const range = await provider.serializeItemsRange(0, 1);
68
- return await provider.serializeItemsRange(0, range.totalLength);
68
+ return await provider.serializeItemsRange(0, Infinity);
69
+ }
70
+ async findNodeIndexById(filePath, nodeId) {
71
+ const snapshot = await this.getSnapshot(filePath);
72
+ const aggregates = await this.getAggregates(filePath);
73
+ const filter = new DevTools.HeapSnapshotModel.HeapSnapshotModel.NodeFilter();
74
+ for (const classKey of Object.keys(aggregates)) {
75
+ const provider = snapshot.createNodesProviderForClass(classKey, filter);
76
+ const range = await provider.serializeItemsRange(0, Infinity);
77
+ for (const item of range.items) {
78
+ if (isNodeLike(item) && item.id === nodeId) {
79
+ return item.nodeIndex;
80
+ }
81
+ }
82
+ }
83
+ return undefined;
84
+ }
85
+ async getRetainers(filePath, nodeId) {
86
+ const nodeIndex = await this.findNodeIndexById(filePath, nodeId);
87
+ if (nodeIndex === undefined) {
88
+ throw new Error(`Node with ID ${nodeId} not found`);
89
+ }
90
+ const snapshot = await this.getSnapshot(filePath);
91
+ const provider = snapshot.createRetainingEdgesProvider(nodeIndex);
92
+ return await provider.serializeItemsRange(0, Infinity);
93
+ }
94
+ async getRetainingPaths(filePath, nodeId, maxDepth, maxNodes, maxSiblings) {
95
+ const nodeIndex = await this.findNodeIndexById(filePath, nodeId);
96
+ if (nodeIndex === undefined) {
97
+ throw new Error(`Node with ID ${nodeId} not found`);
98
+ }
99
+ const snapshot = await this.getSnapshot(filePath);
100
+ return await snapshot.getRetainingPaths(nodeIndex, maxDepth, maxNodes, maxSiblings);
69
101
  }
70
102
  #getCachedSnapshot(filePath) {
71
103
  const absolutePath = path.resolve(filePath);
@@ -75,9 +107,9 @@ export class HeapSnapshotManager {
75
107
  }
76
108
  return cached;
77
109
  }
78
- async resolveClassKeyFromUid(filePath, uid) {
110
+ async resolveClassKeyFromId(filePath, id) {
79
111
  const cached = this.#getCachedSnapshot(filePath);
80
- return cached.uidToClassKey.get(uid);
112
+ return cached.idToClassKey.get(id);
81
113
  }
82
114
  async #loadSnapshot(absolutePath) {
83
115
  const workerProxy = new DevTools.HeapSnapshotModel.HeapSnapshotProxy.HeapSnapshotWorkerProxy(() => {
@@ -98,13 +130,18 @@ export class HeapSnapshotManager {
98
130
  const snapshot = await snapshotPromise;
99
131
  return { snapshot, worker: workerProxy };
100
132
  }
133
+ hasSnapshots() {
134
+ return this.#snapshots.size > 0;
135
+ }
101
136
  dispose(filePath) {
102
137
  const absolutePath = path.resolve(filePath);
103
138
  const cached = this.#snapshots.get(absolutePath);
104
139
  if (cached) {
105
140
  cached.worker.dispose();
106
141
  this.#snapshots.delete(absolutePath);
142
+ return true;
107
143
  }
144
+ return false;
108
145
  }
109
146
  }
110
147
  //# sourceMappingURL=HeapSnapshotManager.js.map