mcp-browser-dev-tools 0.0.1 → 0.0.2

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Rindo Hinase <rindo.hinase@gmail.com>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,5 +1,9 @@
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 beta](https://img.shields.io/npm/v/mcp-browser-dev-tools/beta?label=beta)](https://www.npmjs.com/package/mcp-browser-dev-tools)
5
+ [![npm downloads](https://img.shields.io/npm/dm/mcp-browser-dev-tools)](https://www.npmjs.com/package/mcp-browser-dev-tools)
6
+
3
7
  `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
8
 
5
9
  It is designed for a local trust boundary:
@@ -10,112 +14,96 @@ It is designed for a local trust boundary:
10
14
 
11
15
  - A stdio MCP server for local desktop and terminal clients
12
16
  - Browser discovery and attach/detach for Chrome, Edge, other Chromium-family browsers, and Firefox
13
- - Inspection tools for DOM lookup, richer element details, console messages, network requests, screenshots, tab listing, and buffered events
17
+ - Tab lifecycle tools to create and close browser tabs through MCP
18
+ - Inspection tools for DOM lookup, richer element details, cookies, storage, console messages, network requests, HAR-like exports, screenshots, tab listing, and buffered events
14
19
  - Page interaction tools for navigation, reload, click, hover, type, select, key presses, scroll, and viewport overrides
20
+ - Wait conditions for selector visibility, URL changes, and document ready state
21
+ - One-shot debug bundle capture for page state, storage summary, recent console, recent network, and screenshots
15
22
  - Optional JavaScript evaluation behind an explicit environment flag
16
23
  - Helper commands to check browser connectivity, launch a debug-enabled browser, and relay CDP traffic across a local machine boundary
17
24
 
18
25
  ## Requirements
19
26
 
20
27
  - Node.js `24+`
21
- - A local browser exposing either CDP or BiDi
28
+ - A local browser exposing either CDP or BiDi, or permission for the broker to launch one locally
22
29
  - Loopback endpoints by default; remote endpoints require an explicit opt-in flag
23
30
 
24
- ## Install
31
+ ## Quick Start
32
+
33
+ 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.
25
34
 
26
- The published package name stays `mcp-browser-dev-tools`. The preferred installed CLI command is `mbdt`.
35
+ 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.
27
36
 
28
- One-off execution with `npx`:
37
+ ### Codex
29
38
 
30
39
  ```bash
31
- npx -y mcp-browser-dev-tools serve
40
+ codex mcp add browser-devtools -- npx -y mcp-browser-dev-tools serve
32
41
  ```
33
42
 
34
- Global install:
43
+ ### Claude Code
35
44
 
36
45
  ```bash
37
- npm install -g mcp-browser-dev-tools
38
- mbdt serve
46
+ claude mcp add browser-devtools --scope user -- npx -y mcp-browser-dev-tools serve
39
47
  ```
40
48
 
41
- Project-local install:
49
+ ### Cursor
42
50
 
43
- ```bash
44
- npm install mcp-browser-dev-tools
45
- npx mbdt serve
51
+ ```json
52
+ {
53
+ "mcpServers": {
54
+ "browser-devtools": {
55
+ "command": "npx",
56
+ "args": ["-y", "mcp-browser-dev-tools", "serve"]
57
+ }
58
+ }
59
+ }
46
60
  ```
47
61
 
48
- ## Try It Locally
49
-
50
- You can smoke-test the broker before wiring it into an MCP client.
62
+ 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
63
 
52
- For Windows, WSL, macOS, and Linux-specific setup paths, see [docs/setup.md](docs/setup.md).
64
+ ## After Setup
53
65
 
54
- Quick Chromium flow:
66
+ Once the server is registered, the normal workflow is to ask the agent for browser work directly:
55
67
 
56
- ```bash
57
- # Launch a local browser with remote debugging enabled.
58
- # open waits for the debug endpoint and prints the doctor summary automatically.
59
- npx -y mcp-browser-dev-tools open about:blank --family chromium
60
- ```
68
+ - open a browser to a URL and inspect the page
69
+ - attach to the current tab and inspect DOM, console, or network state
70
+ - take a screenshot or capture a debug report
61
71
 
62
- If you want to verify a specific app URL too:
72
+ 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
73
 
64
- ```bash
65
- npx -y mcp-browser-dev-tools doctor --url http://127.0.0.1:3000
66
- ```
74
+ 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.
67
75
 
68
- Then start the MCP server in a dedicated terminal:
76
+ Typical temporary profile locations:
69
77
 
70
- ```bash
71
- npx -y mcp-browser-dev-tools serve
72
- ```
78
+ - Windows broker: `%TEMP%\\mcp-browser-dev-tools-edge` or PowerShell `$env:TEMP\\mcp-browser-dev-tools-edge`
79
+ - macOS broker: `$HOME/Library/Caches/mcp-browser-dev-tools-profile`
80
+ - Linux or WSL broker: `$HOME/.cache/mcp-browser-dev-tools-profile`
73
81
 
74
- `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.
82
+ 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.
75
83
 
76
- 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:
84
+ Example `ensure_browser` payload for Chrome or Edge:
77
85
 
78
- ```bash
79
- MCP_BROWSER_FAMILY=auto \
80
- CDP_BASE_URL=http://127.0.0.1:9223 \
81
- FIREFOX_BIDI_WS_URL=ws://127.0.0.1:9222 \
82
- npx -y mcp-browser-dev-tools serve
86
+ ```json
87
+ {
88
+ "browserFamily": "edge",
89
+ "url": "https://example.com"
90
+ }
83
91
  ```
84
92
 
85
- Use distinct ports in `auto` mode. A practical local split is Firefox on `9222` and Chrome or Edge on `9223`.
93
+ Add `userDataDir` only if you want to force a specific profile path.
86
94
 
87
- 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:
88
-
89
- ```bash
90
- CDP_BASE_URL=http://127.0.0.1:9222 npx -y mcp-browser-dev-tools doctor
91
- ```
92
-
93
- 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).
95
+ 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.
94
96
 
95
97
  ## MCP Client Configuration
96
98
 
97
- Use the same server command across MCP clients:
98
-
99
- ```bash
100
- npx -y mcp-browser-dev-tools serve
101
- ```
102
-
103
- If you installed the package already, the shorter equivalent is:
104
-
105
- ```bash
106
- mbdt serve
107
- ```
99
+ 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.
108
100
 
109
101
  ### Codex
110
102
 
111
- Add the server with the Codex CLI:
103
+ Minimal local setup:
112
104
 
113
105
  ```bash
114
- codex mcp add browser-devtools \
115
- --env MCP_BROWSER_FAMILY=auto \
116
- --env CDP_BASE_URL=http://127.0.0.1:9223 \
117
- --env FIREFOX_BIDI_WS_URL=ws://127.0.0.1:9222 \
118
- -- npx -y mcp-browser-dev-tools serve
106
+ codex mcp add browser-devtools -- npx -y mcp-browser-dev-tools serve
119
107
  ```
120
108
 
121
109
  Equivalent `~/.codex/config.toml` entry:
@@ -124,45 +112,14 @@ Equivalent `~/.codex/config.toml` entry:
124
112
  [mcp_servers.browser-devtools]
125
113
  command = "npx"
126
114
  args = ["-y", "mcp-browser-dev-tools", "serve"]
127
-
128
- [mcp_servers.browser-devtools.env]
129
- MCP_BROWSER_FAMILY = "auto"
130
- CDP_BASE_URL = "http://127.0.0.1:9223"
131
- FIREFOX_BIDI_WS_URL = "ws://127.0.0.1:9222"
132
115
  ```
133
116
 
134
- 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.
135
-
136
- Example `~/.codex/config.toml` entry for Firefox on Windows:
137
-
138
- ```toml
139
- [mcp_servers.browser-devtools]
140
- startup_timeout_sec = 30
141
- command = "/mnt/c/nvm4w/nodejs/node.exe"
142
- 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); });"]
143
- ```
144
-
145
- Example `auto` mode entry for Firefox plus Chrome or Edge on Windows:
146
-
147
- ```toml
148
- [mcp_servers.browser-devtools]
149
- startup_timeout_sec = 30
150
- command = "/mnt/c/nvm4w/nodejs/node.exe"
151
- 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); });"]
152
- ```
153
-
154
- Replace `<wsl-distro>` and `<repo-wsl-path>` with your own WSL distro name and repository path.
155
-
156
117
  ### Claude Code
157
118
 
158
- Add the server with Claude Code:
119
+ Minimal local setup:
159
120
 
160
121
  ```bash
161
- claude mcp add browser-devtools --scope user \
162
- --env MCP_BROWSER_FAMILY=auto \
163
- --env CDP_BASE_URL=http://127.0.0.1:9223 \
164
- --env FIREFOX_BIDI_WS_URL=ws://127.0.0.1:9222 \
165
- -- npx -y mcp-browser-dev-tools serve
122
+ claude mcp add browser-devtools --scope user -- npx -y mcp-browser-dev-tools serve
166
123
  ```
167
124
 
168
125
  On native Windows, wrap `npx` with `cmd /c`:
@@ -178,12 +135,7 @@ Equivalent `.mcp.json` shape:
178
135
  "mcpServers": {
179
136
  "browser-devtools": {
180
137
  "command": "npx",
181
- "args": ["-y", "mcp-browser-dev-tools", "serve"],
182
- "env": {
183
- "MCP_BROWSER_FAMILY": "auto",
184
- "CDP_BASE_URL": "http://127.0.0.1:9223",
185
- "FIREFOX_BIDI_WS_URL": "ws://127.0.0.1:9222"
186
- }
138
+ "args": ["-y", "mcp-browser-dev-tools", "serve"]
187
139
  }
188
140
  }
189
141
  }
@@ -191,19 +143,14 @@ Equivalent `.mcp.json` shape:
191
143
 
192
144
  ### Cursor
193
145
 
194
- Cursor reads MCP servers from `mcp.json`:
146
+ Minimal local setup:
195
147
 
196
148
  ```json
197
149
  {
198
150
  "mcpServers": {
199
151
  "browser-devtools": {
200
152
  "command": "npx",
201
- "args": ["-y", "mcp-browser-dev-tools", "serve"],
202
- "env": {
203
- "MCP_BROWSER_FAMILY": "auto",
204
- "CDP_BASE_URL": "http://127.0.0.1:9223",
205
- "FIREFOX_BIDI_WS_URL": "ws://127.0.0.1:9222"
206
- }
153
+ "args": ["-y", "mcp-browser-dev-tools", "serve"]
207
154
  }
208
155
  }
209
156
  }
@@ -211,6 +158,8 @@ Cursor reads MCP servers from `mcp.json`:
211
158
 
212
159
  ### Common Variants
213
160
 
161
+ 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.
162
+
214
163
  Auto mode with both browsers attached to one MCP server:
215
164
 
216
165
  ```json
@@ -239,7 +188,7 @@ Microsoft Edge:
239
188
  }
240
189
  ```
241
190
 
242
- Windows browser bridged into WSL through the relay:
191
+ Manual Windows browser relay into WSL:
243
192
 
244
193
  ```json
245
194
  {
@@ -259,53 +208,55 @@ Enable `evaluate_js`:
259
208
  }
260
209
  ```
261
210
 
262
- ## Commands
263
-
264
- - `serve` runs the MCP broker over stdio
265
- - `doctor [--url URL]` checks browser reachability, local display state, and optional page access
266
- - `open <url>` launches a local browser with remote debugging enabled
267
- - `relay` forwards TCP traffic, useful for Windows-to-WSL DevTools bridging
268
- - `--help` and `help` print usage
269
- - `--version` and `version` print the package version
270
-
271
- Examples:
211
+ 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).
272
212
 
273
- ```bash
274
- mbdt doctor
275
- mbdt doctor --url http://127.0.0.1:3000
276
- mbdt open http://127.0.0.1:3000 --family chromium
277
- mbdt open http://127.0.0.1:3000 --family edge --port 9223 --user-data-dir /tmp/mbdt-edge
278
- mbdt open about:blank --family firefox --user-data-dir /tmp/mbdt-firefox
279
- mbdt relay --wsl
280
- ```
213
+ ## Advanced Environment Options
281
214
 
282
- ## Configuration
283
-
284
- - `MCP_BROWSER_FAMILY` defaults to `chromium`; set `edge` for Microsoft Edge, `firefox` for Firefox BiDi, or `auto` to multiplex both adapters
285
- - `CDP_BASE_URL` defaults to `http://127.0.0.1:9222`
286
- - `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
215
+ - `MCP_BROWSER_FAMILY` defaults to `auto`; set `chromium`, `edge`, or `firefox` to pin the broker to one browser family
216
+ - `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
217
+ - `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
287
218
  - in `auto` mode, assign CDP and Firefox different ports so both browsers can run at once
288
219
  - `MCP_BROWSER_EVENT_BUFFER_SIZE` sets the per-session buffered event limit
220
+ - `MCP_BROWSER_LOG_LEVEL` controls diagnostic logging to `stderr`: `error`, `warn`, `info`, or `debug`
221
+ - `MCP_BROWSER_DEBUG_STDIO=1` emits raw MCP stdio transport diagnostics to `stderr`
289
222
  - `MCP_BROWSER_ENABLE_EVAL=1` enables `evaluate_js`
290
223
  - `MCP_BROWSER_ALLOW_REMOTE_ENDPOINTS=1` allows non-loopback CDP or BiDi endpoints
291
224
  - `MCP_BROWSER_ALLOW_REMOTE_CDP=1` is still accepted as a legacy alias
225
+ - `MCP_BROWSER_WINDOWS_NODE` optionally overrides the Windows `node` executable used by `serve --bootstrap-wsl-relay`
292
226
  - `MCP_PROTOCOL_VERSION` overrides the advertised MCP protocol version
293
227
 
294
- The `open` command also requires `MCP_BROWSER_ALLOW_REMOTE_ENDPOINTS=1` before it will bind Chromium remote debugging to a non-loopback address.
295
-
296
- 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`.
297
-
298
228
  ## Exposed Tools
299
229
 
300
230
  - `browser_status` returns broker metadata too: `serverName` and `serverVersion`
301
231
  In `auto` mode it also includes per-browser adapter status under `browsers`
232
+ Protocol adapters may also include `attemptedEndpoint` when discovery retries or fallback probing occur
233
+ - `ensure_browser`
234
+ Ensures a compatible browser is reachable, launches one if needed, and can open a tab for the requested URL in a single MCP call
235
+ In `auto` mode, pass `browserFamily`
236
+ 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
237
+ - `launch_browser`
238
+ Launches a local debug-enabled browser that matches the current broker configuration and can return an inline doctor report
239
+ In `auto` mode, pass `browserFamily`
240
+ 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
302
241
  - `list_tabs`
303
242
  In `auto` mode each `targetId` is namespaced as `chromium:<id>` or `firefox:<id>`
243
+ - `new_tab`
244
+ In `auto` mode, pass `browserFamily`
245
+ - `close_tab`
304
246
  - `list_sessions`
305
247
  In `auto` mode each `sessionId` is namespaced the same way
306
248
  - `attach_tab`
307
249
  - `detach_tab`
308
250
  - `get_page_state`
251
+ - `compare_page_state`
252
+ - `compare_selector`
253
+ - `get_cookies`
254
+ - `get_storage`
255
+ - `capture_debug_report`
256
+ - `capture_session_snapshot`
257
+ - `restore_session_snapshot`
258
+ - `get_har`
259
+ - `wait_for`
309
260
  - `navigate`
310
261
  - `reload`
311
262
  - `click`
@@ -341,12 +292,22 @@ Interaction and inspection tools accept these locator forms:
341
292
 
342
293
  `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.
343
294
 
295
+ ### Session Snapshots
296
+
297
+ - `get_cookies` returns bounded page-visible cookies from the attached page context
298
+ - `get_storage` returns bounded `localStorage` and `sessionStorage` entries and can filter to one storage area
299
+ - `capture_debug_report` bundles page state, cookie/storage summaries, recent console messages, recent network requests, and an optional screenshot
300
+ - `capture_session_snapshot` exports bounded page-visible cookies plus local and session storage for later reuse
301
+ - `restore_session_snapshot` restores a captured snapshot onto the current origin and can optionally clear storage first
302
+ - `get_har` exports buffered network activity in a bounded HAR-like JSON structure
303
+ - `compare_page_state` and `compare_selector` compare bounded state across two attached sessions, which is especially useful in `auto` mode
304
+
344
305
  ## Browser Notes
345
306
 
346
307
  - Chromium uses the standard DevTools endpoints at `/json/version` and `/json/list`
347
308
  - Firefox support expects a direct BiDi websocket endpoint
348
309
  - In WSL, Linux browser executables are preferred before Windows fallback paths
349
- - For Windows Chrome + WSL, prefer the `relay` command over changing Chrome's remote debugging bind
310
+ - For Windows Chrome or Edge + WSL, prefer the broker-managed relay path over changing the browser's remote debugging bind
350
311
 
351
312
  ## Why Not Playwright?
352
313
 
@@ -355,7 +316,7 @@ Playwright is still the stronger choice for deterministic browser automation and
355
316
  `mcp-browser-dev-tools` solves a different problem:
356
317
 
357
318
  - it is MCP-native, so AI clients call a bounded tool surface instead of generating and executing Playwright scripts
358
- - it attaches to an already-open browser tab and inspects the current session state, cookies, login state, extensions, console, and network history
319
+ - it can inspect an already-open browser tab or create a fresh one, then inspect the current session state, cookies, login state, extensions, console, and network history
359
320
  - it is designed for local AI debugging workflows, including loopback-only defaults, opt-in evaluation, and the Windows-to-WSL relay path
360
321
  - it presents one MCP interface across Chromium CDP and Firefox BiDi instead of requiring the AI client to know browser protocol details
361
322
 
@@ -366,6 +327,7 @@ Use Playwright when you want reproducible automation. Use this project when you
366
327
  - `attach_tab` now seeds network history from the Performance API so already-loaded pages still show useful requests
367
328
  - console buffers include source URL, line and column where the browser reports them, plus stack frames when available
368
329
  - `get_page_state` reports the current URL, title, viewport, and scroll position without enabling `evaluate_js`
330
+ - broker diagnostics write to `stderr` so `stdout` stays reserved for MCP protocol traffic
369
331
 
370
332
  ## Safety Defaults
371
333
 
@@ -388,6 +350,6 @@ The repository uses `pnpm` for local development and CI. End-user installation a
388
350
  Additional docs:
389
351
 
390
352
  - [Architecture](docs/architecture.md)
391
- - [Setup Guide](docs/setup.md)
353
+ - [Manual Verification And Troubleshooting](docs/setup.md)
392
354
  - [Repository Settings](docs/repository-settings.md)
393
355
  - [Publishing](PUBLISHING.md)
package/package.json CHANGED
@@ -1,8 +1,9 @@
1
1
  {
2
2
  "name": "mcp-browser-dev-tools",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "description": "Local MCP server for Chromium DevTools Protocol and Firefox WebDriver BiDi",
5
5
  "author": "Hinaser <rindo.hinase@gmail.com>",
6
+ "license": "MIT",
6
7
  "type": "module",
7
8
  "packageManager": "pnpm@10.29.3",
8
9
  "homepage": "https://github.com/Hinaser/mcp-browser-dev-tools#readme",
@@ -23,6 +24,7 @@
23
24
  "src/app.mjs",
24
25
  "src/browser-adapter.mjs",
25
26
  "src/browser-launcher.mjs",
27
+ "src/browser-launch-service.mjs",
26
28
  "src/cdp-client.mjs",
27
29
  "src/cli.mjs",
28
30
  "src/config.mjs",
@@ -30,12 +32,15 @@
30
32
  "src/firefox-bidi-client.mjs",
31
33
  "src/index.mjs",
32
34
  "src/json-rpc-stdio.mjs",
35
+ "src/logger.mjs",
33
36
  "src/mcp-server.mjs",
34
37
  "src/page-context.mjs",
35
38
  "src/package-info.mjs",
39
+ "src/serve-bootstrap.mjs",
36
40
  "src/session-events.mjs",
37
41
  "src/server.mjs",
38
42
  "src/tcp-relay.mjs",
43
+ "src/wait-for.mjs",
39
44
  "README.md"
40
45
  ],
41
46
  "bin": {
package/src/app.mjs CHANGED
@@ -1,5 +1,6 @@
1
1
  import { createBrowserAdapter } from "./browser-adapter.mjs";
2
2
  import { loadConfig } from "./config.mjs";
3
+ import { createLogger } from "./logger.mjs";
3
4
  import { McpBrowserDevToolsServer } from "./mcp-server.mjs";
4
5
  import { PACKAGE_NAME } from "./package-info.mjs";
5
6
 
@@ -8,8 +9,14 @@ export function createBrowserDevToolsApp({
8
9
  input = process.stdin,
9
10
  output = process.stdout,
10
11
  errorOutput = process.stderr,
12
+ extraCloseHandlers = [],
11
13
  } = {}) {
12
14
  const config = loadConfig(env);
15
+ const logger = createLogger({
16
+ level: config.logLevel,
17
+ output: errorOutput,
18
+ name: PACKAGE_NAME,
19
+ });
13
20
  const browserAdapter = createBrowserAdapter(config);
14
21
  const server = new McpBrowserDevToolsServer({
15
22
  config,
@@ -17,6 +24,7 @@ export function createBrowserDevToolsApp({
17
24
  input,
18
25
  output,
19
26
  errorOutput,
27
+ logger,
20
28
  });
21
29
 
22
30
  let closing = false;
@@ -27,8 +35,28 @@ export function createBrowserDevToolsApp({
27
35
  }
28
36
 
29
37
  closing = true;
30
- errorOutput.write(`[${PACKAGE_NAME}] shutting down after ${signal}\n`);
31
- await browserAdapter.closeAll();
38
+ logger.info(`shutting down after ${signal}`);
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
+ }
32
60
  }
33
61
 
34
62
  function start() {
@@ -47,6 +75,7 @@ export function createBrowserDevToolsApp({
47
75
 
48
76
  return {
49
77
  config,
78
+ logger,
50
79
  browserAdapter,
51
80
  server,
52
81
  start,
@@ -161,6 +161,32 @@ export class MultiBrowserAdapter {
161
161
  );
162
162
  }
163
163
 
164
+ async createTab(url, options = {}) {
165
+ const browserFamily = options.browserFamily;
166
+ if (!browserFamily) {
167
+ throw new Error(
168
+ "browserFamily is required when multiple browsers are configured",
169
+ );
170
+ }
171
+
172
+ const result = await this.getAdapter(browserFamily).createTab(url);
173
+ return {
174
+ ...mapPrefixedFields(result, browserFamily),
175
+ browserFamily,
176
+ };
177
+ }
178
+
179
+ async closeTarget(targetId) {
180
+ const { browserFamily, localId } = resolvePrefixedId(targetId, "targetId");
181
+ return {
182
+ ...mapPrefixedFields(
183
+ await this.getAdapter(browserFamily).closeTarget(localId),
184
+ browserFamily,
185
+ ),
186
+ browserFamily,
187
+ };
188
+ }
189
+
164
190
  async delegateSession(sessionId, methodName, args = []) {
165
191
  const { browserFamily, localId } = resolvePrefixedId(
166
192
  sessionId,
@@ -188,6 +214,37 @@ export class MultiBrowserAdapter {
188
214
  return this.delegateSession(sessionId, "getPageState");
189
215
  }
190
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
+
244
+ waitFor(sessionId, options) {
245
+ return this.delegateSession(sessionId, "waitFor", [options]);
246
+ }
247
+
191
248
  navigate(sessionId, url, options) {
192
249
  return this.delegateSession(sessionId, "navigate", [url, options]);
193
250
  }