mcp-browser-dev-tools 0.0.2-beta.0 → 0.0.3

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.
package/README.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # mcp-browser-dev-tools
2
2
 
3
+ [![npm version](https://img.shields.io/npm/v/mcp-browser-dev-tools?label=npm)](https://www.npmjs.com/package/mcp-browser-dev-tools)
4
+ [![npm downloads](https://img.shields.io/npm/dm/mcp-browser-dev-tools)](https://www.npmjs.com/package/mcp-browser-dev-tools)
5
+
3
6
  `mcp-browser-dev-tools` is a local MCP server that lets AI clients inspect browser state through Chromium DevTools Protocol or Firefox WebDriver BiDi.
4
7
 
5
8
  It is designed for a local trust boundary:
@@ -11,113 +14,95 @@ It is designed for a local trust boundary:
11
14
  - A stdio MCP server for local desktop and terminal clients
12
15
  - Browser discovery and attach/detach for Chrome, Edge, other Chromium-family browsers, and Firefox
13
16
  - Tab lifecycle tools to create and close browser tabs through MCP
14
- - Inspection tools for DOM lookup, richer element details, console messages, network requests, screenshots, tab listing, and buffered events
17
+ - Inspection tools for DOM lookup, richer element details, cookies, storage, console messages, network requests, HAR-like exports, screenshots, tab listing, and buffered events
15
18
  - Page interaction tools for navigation, reload, click, hover, type, select, key presses, scroll, and viewport overrides
16
19
  - Wait conditions for selector visibility, URL changes, and document ready state
20
+ - One-shot debug bundle capture for page state, storage summary, recent console, recent network, and screenshots
17
21
  - Optional JavaScript evaluation behind an explicit environment flag
18
22
  - Helper commands to check browser connectivity, launch a debug-enabled browser, and relay CDP traffic across a local machine boundary
19
23
 
20
24
  ## Requirements
21
25
 
22
26
  - Node.js `24+`
23
- - A local browser exposing either CDP or BiDi
27
+ - A local browser exposing either CDP or BiDi, or permission for the broker to launch one locally
24
28
  - Loopback endpoints by default; remote endpoints require an explicit opt-in flag
25
29
 
26
- ## Install
30
+ ## Quick Start
31
+
32
+ In normal use, the only thing a user should need to do is register this MCP server in their agent client. After that, let the agent drive the browser through MCP.
27
33
 
28
- The published package name stays `mcp-browser-dev-tools`. The preferred installed CLI command is `mbdt`.
34
+ If you want the simplest local path, start with the default `auto` setup. The broker can auto-discover loopback CDP and BiDi ports, launch a compatible browser through MCP, and in WSL bootstrap the Windows Chrome or Edge relay when your config asks it to.
29
35
 
30
- One-off execution with `npx`:
36
+ ### Codex
31
37
 
32
38
  ```bash
33
- npx -y mcp-browser-dev-tools serve
39
+ codex mcp add browser-devtools -- npx -y mcp-browser-dev-tools serve
34
40
  ```
35
41
 
36
- Global install:
42
+ ### Claude Code
37
43
 
38
44
  ```bash
39
- npm install -g mcp-browser-dev-tools
40
- mbdt serve
45
+ claude mcp add browser-devtools --scope user -- npx -y mcp-browser-dev-tools serve
41
46
  ```
42
47
 
43
- Project-local install:
48
+ ### Cursor
44
49
 
45
- ```bash
46
- npm install mcp-browser-dev-tools
47
- npx mbdt serve
50
+ ```json
51
+ {
52
+ "mcpServers": {
53
+ "browser-devtools": {
54
+ "command": "npx",
55
+ "args": ["-y", "mcp-browser-dev-tools", "serve"]
56
+ }
57
+ }
58
+ }
48
59
  ```
49
60
 
50
- ## Try It Locally
61
+ These commands intentionally do not include a profile flag. They only start the MCP broker. Browser launch options belong to the later `ensure_browser` or `launch_browser` call that the agent makes after the broker is running, and the broker can auto-create a temporary Chromium-family profile when that is needed.
51
62
 
52
- You can smoke-test the broker before wiring it into an MCP client.
63
+ ## After Setup
53
64
 
54
- For Windows, WSL, macOS, and Linux-specific setup paths, see [docs/setup.md](docs/setup.md).
65
+ Once the server is registered, the normal workflow is to ask the agent for browser work directly:
55
66
 
56
- Quick Chromium flow:
67
+ - open a browser to a URL and inspect the page
68
+ - attach to the current tab and inspect DOM, console, or network state
69
+ - take a screenshot or capture a debug report
57
70
 
58
- ```bash
59
- # Launch a local browser with remote debugging enabled.
60
- # open waits for the debug endpoint and prints the doctor summary automatically.
61
- npx -y mcp-browser-dev-tools open about:blank --family chromium
62
- ```
71
+ The agent should usually start with `ensure_browser`. That tool can confirm browser availability, launch one if needed, and optionally open the requested URL in one step.
63
72
 
64
- If you want to verify a specific app URL too:
73
+ If the agent launches Chrome or Edge without `userDataDir`, the broker checks whether the same browser family is already running. If it is, the broker automatically creates a temporary profile directory before launching so the new debug flags are not swallowed by the already-running profile.
65
74
 
66
- ```bash
67
- npx -y mcp-browser-dev-tools doctor --url http://127.0.0.1:3000
68
- ```
75
+ Typical temporary profile locations:
69
76
 
70
- Then start the MCP server in a dedicated terminal:
71
-
72
- ```bash
73
- npx -y mcp-browser-dev-tools serve
74
- ```
77
+ - Windows broker: `%TEMP%\\mcp-browser-dev-tools-edge` or PowerShell `$env:TEMP\\mcp-browser-dev-tools-edge`
78
+ - macOS broker: `$HOME/Library/Caches/mcp-browser-dev-tools-profile`
79
+ - Linux or WSL broker: `$HOME/.cache/mcp-browser-dev-tools-profile`
75
80
 
76
- `serve` stays attached to stdio because MCP clients talk to it over standard input and output. Run it in its own terminal or let your MCP client spawn it directly.
81
+ Use a path that matches the OS running the broker process. If you want a stable or reusable profile path, still pass `userDataDir` explicitly. If a browser is already open and already exposing a debug endpoint, the broker can still attach to it. If Chrome or Edge is already open without a debug endpoint, the automatic temporary profile is the default safety path for launches initiated through `ensure_browser`, `launch_browser`, or the manual `open` command.
77
82
 
78
- If you want one broker to handle Chromium and Firefox at the same time, run it in `auto` mode and point each adapter at its own endpoint:
83
+ Example `ensure_browser` payload for Chrome or Edge:
79
84
 
80
- ```bash
81
- MCP_BROWSER_FAMILY=auto \
82
- CDP_BASE_URL=http://127.0.0.1:9223 \
83
- FIREFOX_BIDI_WS_URL=ws://127.0.0.1:9222 \
84
- npx -y mcp-browser-dev-tools serve
85
+ ```json
86
+ {
87
+ "browserFamily": "edge",
88
+ "url": "https://example.com"
89
+ }
85
90
  ```
86
91
 
87
- Use distinct ports in `auto` mode. A practical local split is Firefox on `9222` and Chrome or Edge on `9223`.
88
-
89
- If you already have a browser listening on `http://127.0.0.1:9222`, `doctor` is enough to confirm that the broker can reach it:
92
+ Add `userDataDir` only if you want to force a specific profile path.
90
93
 
91
- ```bash
92
- CDP_BASE_URL=http://127.0.0.1:9222 npx -y mcp-browser-dev-tools doctor
93
- ```
94
-
95
- If you need to bridge Windows Chrome into WSL without changing WSL networking mode, run the relay on Windows and point WSL at the relay port instead. The full procedure is in [docs/setup.md](docs/setup.md).
94
+ When the broker launches a browser, the result reports the selected `userDataDir`, `profileStrategy`, and `existingBrowserProcess` state so the agent can see whether a temporary profile was chosen automatically.
96
95
 
97
96
  ## MCP Client Configuration
98
97
 
99
- Use the same server command across MCP clients:
100
-
101
- ```bash
102
- npx -y mcp-browser-dev-tools serve
103
- ```
104
-
105
- If you installed the package already, the shorter equivalent is:
106
-
107
- ```bash
108
- mbdt serve
109
- ```
98
+ The same launch-profile advice applies to every MCP client config below: if you later ask the agent to launch Chrome or Edge, you can pass `userDataDir` to force a specific profile path, but if you omit it the broker can auto-create a temporary profile when an already-running Chromium-family browser would otherwise swallow the new debug flags. The config commands themselves still only launch `serve`; they do not carry browser launch arguments.
110
99
 
111
100
  ### Codex
112
101
 
113
- Add the server with the Codex CLI:
102
+ Minimal local setup:
114
103
 
115
104
  ```bash
116
- codex mcp add browser-devtools \
117
- --env MCP_BROWSER_FAMILY=auto \
118
- --env CDP_BASE_URL=http://127.0.0.1:9223 \
119
- --env FIREFOX_BIDI_WS_URL=ws://127.0.0.1:9222 \
120
- -- npx -y mcp-browser-dev-tools serve
105
+ codex mcp add browser-devtools -- npx -y mcp-browser-dev-tools serve
121
106
  ```
122
107
 
123
108
  Equivalent `~/.codex/config.toml` entry:
@@ -126,45 +111,14 @@ Equivalent `~/.codex/config.toml` entry:
126
111
  [mcp_servers.browser-devtools]
127
112
  command = "npx"
128
113
  args = ["-y", "mcp-browser-dev-tools", "serve"]
129
-
130
- [mcp_servers.browser-devtools.env]
131
- MCP_BROWSER_FAMILY = "auto"
132
- CDP_BASE_URL = "http://127.0.0.1:9223"
133
- FIREFOX_BIDI_WS_URL = "ws://127.0.0.1:9222"
134
- ```
135
-
136
- If Codex runs in WSL but the browser runs on Windows, run the broker on Windows too so it can connect to Windows loopback directly. This avoids relay and WSL networking issues.
137
-
138
- Example `~/.codex/config.toml` entry for Firefox on Windows:
139
-
140
- ```toml
141
- [mcp_servers.browser-devtools]
142
- startup_timeout_sec = 30
143
- command = "/mnt/c/nvm4w/nodejs/node.exe"
144
- args = ["-e", "process.env.MCP_BROWSER_FAMILY='firefox';process.env.FIREFOX_BIDI_WS_URL='ws://127.0.0.1:9222';import('//wsl.localhost/<wsl-distro>/<repo-wsl-path>/src/cli.mjs').then(({ runCli }) => runCli(['serve'])).catch((error) => { console.error(error?.stack || String(error)); process.exit(1); });"]
145
114
  ```
146
115
 
147
- Example `auto` mode entry for Firefox plus Chrome or Edge on Windows:
148
-
149
- ```toml
150
- [mcp_servers.browser-devtools]
151
- startup_timeout_sec = 30
152
- command = "/mnt/c/nvm4w/nodejs/node.exe"
153
- args = ["-e", "process.env.MCP_BROWSER_FAMILY='auto';process.env.CDP_BASE_URL='http://127.0.0.1:9223';process.env.FIREFOX_BIDI_WS_URL='ws://127.0.0.1:9222';import('//wsl.localhost/<wsl-distro>/<repo-wsl-path>/src/cli.mjs').then(({ runCli }) => runCli(['serve'])).catch((error) => { console.error(error?.stack || String(error)); process.exit(1); });"]
154
- ```
155
-
156
- Replace `<wsl-distro>` and `<repo-wsl-path>` with your own WSL distro name and repository path.
157
-
158
116
  ### Claude Code
159
117
 
160
- Add the server with Claude Code:
118
+ Minimal local setup:
161
119
 
162
120
  ```bash
163
- claude mcp add browser-devtools --scope user \
164
- --env MCP_BROWSER_FAMILY=auto \
165
- --env CDP_BASE_URL=http://127.0.0.1:9223 \
166
- --env FIREFOX_BIDI_WS_URL=ws://127.0.0.1:9222 \
167
- -- npx -y mcp-browser-dev-tools serve
121
+ claude mcp add browser-devtools --scope user -- npx -y mcp-browser-dev-tools serve
168
122
  ```
169
123
 
170
124
  On native Windows, wrap `npx` with `cmd /c`:
@@ -180,12 +134,7 @@ Equivalent `.mcp.json` shape:
180
134
  "mcpServers": {
181
135
  "browser-devtools": {
182
136
  "command": "npx",
183
- "args": ["-y", "mcp-browser-dev-tools", "serve"],
184
- "env": {
185
- "MCP_BROWSER_FAMILY": "auto",
186
- "CDP_BASE_URL": "http://127.0.0.1:9223",
187
- "FIREFOX_BIDI_WS_URL": "ws://127.0.0.1:9222"
188
- }
137
+ "args": ["-y", "mcp-browser-dev-tools", "serve"]
189
138
  }
190
139
  }
191
140
  }
@@ -193,19 +142,14 @@ Equivalent `.mcp.json` shape:
193
142
 
194
143
  ### Cursor
195
144
 
196
- Cursor reads MCP servers from `mcp.json`:
145
+ Minimal local setup:
197
146
 
198
147
  ```json
199
148
  {
200
149
  "mcpServers": {
201
150
  "browser-devtools": {
202
151
  "command": "npx",
203
- "args": ["-y", "mcp-browser-dev-tools", "serve"],
204
- "env": {
205
- "MCP_BROWSER_FAMILY": "auto",
206
- "CDP_BASE_URL": "http://127.0.0.1:9223",
207
- "FIREFOX_BIDI_WS_URL": "ws://127.0.0.1:9222"
208
- }
152
+ "args": ["-y", "mcp-browser-dev-tools", "serve"]
209
153
  }
210
154
  }
211
155
  }
@@ -213,6 +157,8 @@ Cursor reads MCP servers from `mcp.json`:
213
157
 
214
158
  ### Common Variants
215
159
 
160
+ The default broker mode is `auto`. If you want to pin the broker to one browser family or one set of endpoints, change the environment in your MCP client config.
161
+
216
162
  Auto mode with both browsers attached to one MCP server:
217
163
 
218
164
  ```json
@@ -241,7 +187,7 @@ Microsoft Edge:
241
187
  }
242
188
  ```
243
189
 
244
- Windows browser bridged into WSL through the relay:
190
+ Manual Windows browser relay into WSL:
245
191
 
246
192
  ```json
247
193
  {
@@ -261,57 +207,65 @@ Enable `evaluate_js`:
261
207
  }
262
208
  ```
263
209
 
264
- ## Commands
265
-
266
- - `serve` runs the MCP broker over stdio
267
- - `doctor [--url URL]` checks browser reachability, local display state, and optional page access
268
- - `open <url>` launches a local browser with remote debugging enabled
269
- - `relay` forwards TCP traffic, useful for Windows-to-WSL DevTools bridging
270
- - `--help` and `help` print usage
271
- - `--version` and `version` print the package version
210
+ Enable unsafe browser launch args for `launch_browser` and `ensure_browser`:
272
211
 
273
- Examples:
274
-
275
- ```bash
276
- mbdt doctor
277
- mbdt doctor --url http://127.0.0.1:3000
278
- mbdt open http://127.0.0.1:3000 --family chromium
279
- mbdt open http://127.0.0.1:3000 --family edge --port 9223 --user-data-dir /tmp/mbdt-edge
280
- mbdt open about:blank --family firefox --user-data-dir /tmp/mbdt-firefox
281
- mbdt relay --wsl
212
+ ```json
213
+ {
214
+ "MCP_BROWSER_ENABLE_UNSAFE_LAUNCH_ARGS": "1"
215
+ }
282
216
  ```
283
217
 
284
- ## Configuration
218
+ If you use WSL with a Windows Chrome or Edge browser, prefer `serve --bootstrap-wsl-relay` in the configured args instead of manually wiring `relay`. If you use Windows Firefox from WSL, or `auto` mode with both Windows Firefox and Windows Chrome or Edge, run the broker on Windows instead. Full examples are in [docs/setup.md](docs/setup.md).
219
+
220
+ ## Advanced Environment Options
285
221
 
286
- - `MCP_BROWSER_FAMILY` defaults to `chromium`; set `edge` for Microsoft Edge, `firefox` for Firefox BiDi, or `auto` to multiplex both adapters
287
- - `CDP_BASE_URL` defaults to `http://127.0.0.1:9222`
288
- - `FIREFOX_BIDI_WS_URL` defaults to `ws://127.0.0.1:9222`; when pointed at the root Firefox remote debugging port, the broker connects to the `/session` websocket and creates a BiDi session there
222
+ - `MCP_BROWSER_FAMILY` defaults to `auto`; set `chromium`, `edge`, or `firefox` to pin the broker to one browser family
223
+ - `CDP_BASE_URL` defaults to `http://127.0.0.1:9222`; when left at that default the broker probes loopback ports `9222` through `9226` for a reachable CDP browser endpoint
224
+ - `FIREFOX_BIDI_WS_URL` defaults to `ws://127.0.0.1:9222`; when left at that default the broker probes loopback ports `9222` through `9226`, and when pointed at the root Firefox remote debugging port it connects to the `/session` websocket and creates a BiDi session there
289
225
  - in `auto` mode, assign CDP and Firefox different ports so both browsers can run at once
290
226
  - `MCP_BROWSER_EVENT_BUFFER_SIZE` sets the per-session buffered event limit
291
227
  - `MCP_BROWSER_LOG_LEVEL` controls diagnostic logging to `stderr`: `error`, `warn`, `info`, or `debug`
292
228
  - `MCP_BROWSER_DEBUG_STDIO=1` emits raw MCP stdio transport diagnostics to `stderr`
293
229
  - `MCP_BROWSER_ENABLE_EVAL=1` enables `evaluate_js`
230
+ - `MCP_BROWSER_ENABLE_UNSAFE_LAUNCH_ARGS=1` exposes the `unsafeArgs` launch option on `launch_browser` and `ensure_browser`
294
231
  - `MCP_BROWSER_ALLOW_REMOTE_ENDPOINTS=1` allows non-loopback CDP or BiDi endpoints
295
232
  - `MCP_BROWSER_ALLOW_REMOTE_CDP=1` is still accepted as a legacy alias
233
+ - `MCP_BROWSER_WINDOWS_NODE` optionally overrides the Windows `node` executable used by `serve --bootstrap-wsl-relay`
296
234
  - `MCP_PROTOCOL_VERSION` overrides the advertised MCP protocol version
297
235
 
298
- The `open` command also requires `MCP_BROWSER_ALLOW_REMOTE_ENDPOINTS=1` before it will bind Chromium remote debugging to a non-loopback address.
299
-
300
- The `relay` command defaults to `127.0.0.1:9223 -> 127.0.0.1:9222`. Non-loopback relay binds require either `--wsl` on Windows or `MCP_BROWSER_ALLOW_REMOTE_ENDPOINTS=1`.
301
-
302
236
  ## Exposed Tools
303
237
 
304
238
  - `browser_status` returns broker metadata too: `serverName` and `serverVersion`
305
239
  In `auto` mode it also includes per-browser adapter status under `browsers`
240
+ Protocol adapters may also include `attemptedEndpoint` when discovery retries or fallback probing occur
241
+ - `ensure_browser`
242
+ Ensures a compatible browser is reachable, launches one if needed, and can open a tab for the requested URL in a single MCP call
243
+ In `auto` mode, pass `browserFamily`
244
+ For Chrome or Edge launches, `userDataDir` is optional; if omitted, the broker auto-creates a temporary profile when an already-running browser process makes that necessary
245
+ When `MCP_BROWSER_ENABLE_UNSAFE_LAUNCH_ARGS=1`, this tool also accepts `unsafeArgs` as an array of browser flags. Broker-managed launch flags such as the debug port and profile path still cannot be overridden.
246
+ - `launch_browser`
247
+ Launches a local debug-enabled browser that matches the current broker configuration and can return an inline doctor report
248
+ In `auto` mode, pass `browserFamily`
249
+ For Chrome or Edge launches, `userDataDir` is optional; if omitted, the broker auto-creates a temporary profile when an already-running browser process makes that necessary
250
+ When `MCP_BROWSER_ENABLE_UNSAFE_LAUNCH_ARGS=1`, this tool also accepts `unsafeArgs` as an array of browser flags. Broker-managed launch flags such as the debug port and profile path still cannot be overridden.
306
251
  - `list_tabs`
307
252
  In `auto` mode each `targetId` is namespaced as `chromium:<id>` or `firefox:<id>`
308
253
  - `new_tab`
254
+ In `auto` mode, pass `browserFamily`
309
255
  - `close_tab`
310
256
  - `list_sessions`
311
257
  In `auto` mode each `sessionId` is namespaced the same way
312
258
  - `attach_tab`
313
259
  - `detach_tab`
314
260
  - `get_page_state`
261
+ - `compare_page_state`
262
+ - `compare_selector`
263
+ - `get_cookies`
264
+ - `get_storage`
265
+ - `capture_debug_report`
266
+ - `capture_session_snapshot`
267
+ - `restore_session_snapshot`
268
+ - `get_har`
315
269
  - `wait_for`
316
270
  - `navigate`
317
271
  - `reload`
@@ -331,6 +285,8 @@ The `relay` command defaults to `127.0.0.1:9223 -> 127.0.0.1:9222`. Non-loopback
331
285
 
332
286
  `evaluate_js` is intentionally disabled by default. Enable it only when you want the broker to allow page-side code execution.
333
287
 
288
+ Unsafe browser launch flags are also disabled by default. If you enable `MCP_BROWSER_ENABLE_UNSAFE_LAUNCH_ARGS=1`, pass only full flag strings such as `--remote-allow-origins=http://localhost:9222`. This does not enable `evaluate_js`, and it still does not let callers replace broker-managed launch flags like `--remote-debugging-port` or `--user-data-dir`.
289
+
334
290
  For tools that take `sessionId`, call `attach_tab` first and reuse the returned session.
335
291
 
336
292
  ### Locator Syntax
@@ -348,12 +304,22 @@ Interaction and inspection tools accept these locator forms:
348
304
 
349
305
  `take_screenshot` returns base64 image data plus metadata such as `mimeType`, `byteLength`, and `scope`. Pass `selector` to capture a single element instead of the full page.
350
306
 
307
+ ### Session Snapshots
308
+
309
+ - `get_cookies` returns bounded page-visible cookies from the attached page context
310
+ - `get_storage` returns bounded `localStorage` and `sessionStorage` entries and can filter to one storage area
311
+ - `capture_debug_report` bundles page state, cookie/storage summaries, recent console messages, recent network requests, and an optional screenshot
312
+ - `capture_session_snapshot` exports bounded page-visible cookies plus local and session storage for later reuse
313
+ - `restore_session_snapshot` restores a captured snapshot onto the current origin and can optionally clear storage first
314
+ - `get_har` exports buffered network activity in a bounded HAR-like JSON structure
315
+ - `compare_page_state` and `compare_selector` compare bounded state across two attached sessions, which is especially useful in `auto` mode
316
+
351
317
  ## Browser Notes
352
318
 
353
319
  - Chromium uses the standard DevTools endpoints at `/json/version` and `/json/list`
354
320
  - Firefox support expects a direct BiDi websocket endpoint
355
321
  - In WSL, Linux browser executables are preferred before Windows fallback paths
356
- - For Windows Chrome + WSL, prefer the `relay` command over changing Chrome's remote debugging bind
322
+ - For Windows Chrome or Edge + WSL, prefer the broker-managed relay path over changing the browser's remote debugging bind
357
323
 
358
324
  ## Why Not Playwright?
359
325
 
@@ -396,6 +362,6 @@ The repository uses `pnpm` for local development and CI. End-user installation a
396
362
  Additional docs:
397
363
 
398
364
  - [Architecture](docs/architecture.md)
399
- - [Setup Guide](docs/setup.md)
365
+ - [Manual Verification And Troubleshooting](docs/setup.md)
400
366
  - [Repository Settings](docs/repository-settings.md)
401
367
  - [Publishing](PUBLISHING.md)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mcp-browser-dev-tools",
3
- "version": "0.0.2-beta.0",
3
+ "version": "0.0.3",
4
4
  "description": "Local MCP server for Chromium DevTools Protocol and Firefox WebDriver BiDi",
5
5
  "author": "Hinaser <rindo.hinase@gmail.com>",
6
6
  "license": "MIT",
@@ -24,6 +24,7 @@
24
24
  "src/app.mjs",
25
25
  "src/browser-adapter.mjs",
26
26
  "src/browser-launcher.mjs",
27
+ "src/browser-launch-service.mjs",
27
28
  "src/cdp-client.mjs",
28
29
  "src/cli.mjs",
29
30
  "src/config.mjs",
@@ -35,6 +36,7 @@
35
36
  "src/mcp-server.mjs",
36
37
  "src/page-context.mjs",
37
38
  "src/package-info.mjs",
39
+ "src/serve-bootstrap.mjs",
38
40
  "src/session-events.mjs",
39
41
  "src/server.mjs",
40
42
  "src/tcp-relay.mjs",
package/src/app.mjs CHANGED
@@ -9,6 +9,7 @@ export function createBrowserDevToolsApp({
9
9
  input = process.stdin,
10
10
  output = process.stdout,
11
11
  errorOutput = process.stderr,
12
+ extraCloseHandlers = [],
12
13
  } = {}) {
13
14
  const config = loadConfig(env);
14
15
  const logger = createLogger({
@@ -35,7 +36,27 @@ export function createBrowserDevToolsApp({
35
36
 
36
37
  closing = true;
37
38
  logger.info(`shutting down after ${signal}`);
38
- await browserAdapter.closeAll();
39
+ let firstError = null;
40
+
41
+ try {
42
+ await browserAdapter.closeAll();
43
+ } catch (error) {
44
+ firstError = error;
45
+ }
46
+
47
+ for (const handler of extraCloseHandlers) {
48
+ try {
49
+ await handler(signal);
50
+ } catch (error) {
51
+ if (!firstError) {
52
+ firstError = error;
53
+ }
54
+ }
55
+ }
56
+
57
+ if (firstError) {
58
+ throw firstError;
59
+ }
39
60
  }
40
61
 
41
62
  function start() {
@@ -214,6 +214,33 @@ export class MultiBrowserAdapter {
214
214
  return this.delegateSession(sessionId, "getPageState");
215
215
  }
216
216
 
217
+ getCookies(sessionId) {
218
+ return this.delegateSession(sessionId, "getCookies");
219
+ }
220
+
221
+ getStorage(sessionId) {
222
+ return this.delegateSession(sessionId, "getStorage");
223
+ }
224
+
225
+ captureDebugReport(sessionId, options) {
226
+ return this.delegateSession(sessionId, "captureDebugReport", [options]);
227
+ }
228
+
229
+ getHar(sessionId, options) {
230
+ return this.delegateSession(sessionId, "getHar", [options]);
231
+ }
232
+
233
+ captureSessionSnapshot(sessionId) {
234
+ return this.delegateSession(sessionId, "captureSessionSnapshot");
235
+ }
236
+
237
+ restoreSessionSnapshot(sessionId, snapshot, options) {
238
+ return this.delegateSession(sessionId, "restoreSessionSnapshot", [
239
+ snapshot,
240
+ options,
241
+ ]);
242
+ }
243
+
217
244
  waitFor(sessionId, options) {
218
245
  return this.delegateSession(sessionId, "waitFor", [options]);
219
246
  }