mcp-browser-dev-tools 0.0.2-beta.0 → 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/README.md +93 -139
- package/package.json +3 -1
- package/src/app.mjs +22 -1
- package/src/browser-adapter.mjs +27 -0
- package/src/browser-launch-service.mjs +515 -0
- package/src/cdp-client.mjs +261 -5
- package/src/cli.mjs +57 -202
- package/src/config.mjs +1 -1
- package/src/firefox-bidi-client.mjs +180 -16
- package/src/mcp-server.mjs +553 -0
- package/src/page-context.mjs +217 -0
- package/src/serve-bootstrap.mjs +290 -0
- package/src/session-events.mjs +83 -0
package/README.md
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
# mcp-browser-dev-tools
|
|
2
2
|
|
|
3
|
+
[](https://www.npmjs.com/package/mcp-browser-dev-tools)
|
|
4
|
+
[](https://www.npmjs.com/package/mcp-browser-dev-tools)
|
|
5
|
+
[](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:
|
|
@@ -11,113 +15,95 @@ It is designed for a local trust boundary:
|
|
|
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
17
|
- 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
|
|
18
|
+
- Inspection tools for DOM lookup, richer element details, cookies, storage, console messages, network requests, HAR-like exports, screenshots, tab listing, and buffered events
|
|
15
19
|
- Page interaction tools for navigation, reload, click, hover, type, select, key presses, scroll, and viewport overrides
|
|
16
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
|
|
17
22
|
- Optional JavaScript evaluation behind an explicit environment flag
|
|
18
23
|
- Helper commands to check browser connectivity, launch a debug-enabled browser, and relay CDP traffic across a local machine boundary
|
|
19
24
|
|
|
20
25
|
## Requirements
|
|
21
26
|
|
|
22
27
|
- Node.js `24+`
|
|
23
|
-
- 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
|
|
24
29
|
- Loopback endpoints by default; remote endpoints require an explicit opt-in flag
|
|
25
30
|
|
|
26
|
-
##
|
|
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.
|
|
27
34
|
|
|
28
|
-
|
|
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.
|
|
29
36
|
|
|
30
|
-
|
|
37
|
+
### Codex
|
|
31
38
|
|
|
32
39
|
```bash
|
|
33
|
-
npx -y mcp-browser-dev-tools serve
|
|
40
|
+
codex mcp add browser-devtools -- npx -y mcp-browser-dev-tools serve
|
|
34
41
|
```
|
|
35
42
|
|
|
36
|
-
|
|
43
|
+
### Claude Code
|
|
37
44
|
|
|
38
45
|
```bash
|
|
39
|
-
|
|
40
|
-
mbdt serve
|
|
46
|
+
claude mcp add browser-devtools --scope user -- npx -y mcp-browser-dev-tools serve
|
|
41
47
|
```
|
|
42
48
|
|
|
43
|
-
|
|
49
|
+
### Cursor
|
|
44
50
|
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
|
|
51
|
+
```json
|
|
52
|
+
{
|
|
53
|
+
"mcpServers": {
|
|
54
|
+
"browser-devtools": {
|
|
55
|
+
"command": "npx",
|
|
56
|
+
"args": ["-y", "mcp-browser-dev-tools", "serve"]
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
48
60
|
```
|
|
49
61
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
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.
|
|
53
63
|
|
|
54
|
-
|
|
64
|
+
## After Setup
|
|
55
65
|
|
|
56
|
-
|
|
66
|
+
Once the server is registered, the normal workflow is to ask the agent for browser work directly:
|
|
57
67
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
npx -y mcp-browser-dev-tools open about:blank --family chromium
|
|
62
|
-
```
|
|
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
|
|
63
71
|
|
|
64
|
-
|
|
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.
|
|
65
73
|
|
|
66
|
-
|
|
67
|
-
npx -y mcp-browser-dev-tools doctor --url http://127.0.0.1:3000
|
|
68
|
-
```
|
|
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.
|
|
69
75
|
|
|
70
|
-
|
|
76
|
+
Typical temporary profile locations:
|
|
71
77
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
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`
|
|
75
81
|
|
|
76
|
-
`
|
|
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.
|
|
77
83
|
|
|
78
|
-
|
|
84
|
+
Example `ensure_browser` payload for Chrome or Edge:
|
|
79
85
|
|
|
80
|
-
```
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
86
|
+
```json
|
|
87
|
+
{
|
|
88
|
+
"browserFamily": "edge",
|
|
89
|
+
"url": "https://example.com"
|
|
90
|
+
}
|
|
85
91
|
```
|
|
86
92
|
|
|
87
|
-
|
|
93
|
+
Add `userDataDir` only if you want to force a specific profile path.
|
|
88
94
|
|
|
89
|
-
|
|
90
|
-
|
|
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).
|
|
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.
|
|
96
96
|
|
|
97
97
|
## MCP Client Configuration
|
|
98
98
|
|
|
99
|
-
|
|
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
|
-
```
|
|
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.
|
|
110
100
|
|
|
111
101
|
### Codex
|
|
112
102
|
|
|
113
|
-
|
|
103
|
+
Minimal local setup:
|
|
114
104
|
|
|
115
105
|
```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
|
|
106
|
+
codex mcp add browser-devtools -- npx -y mcp-browser-dev-tools serve
|
|
121
107
|
```
|
|
122
108
|
|
|
123
109
|
Equivalent `~/.codex/config.toml` entry:
|
|
@@ -126,45 +112,14 @@ Equivalent `~/.codex/config.toml` entry:
|
|
|
126
112
|
[mcp_servers.browser-devtools]
|
|
127
113
|
command = "npx"
|
|
128
114
|
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
115
|
```
|
|
135
116
|
|
|
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
|
-
```
|
|
146
|
-
|
|
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
117
|
### Claude Code
|
|
159
118
|
|
|
160
|
-
|
|
119
|
+
Minimal local setup:
|
|
161
120
|
|
|
162
121
|
```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
|
|
122
|
+
claude mcp add browser-devtools --scope user -- npx -y mcp-browser-dev-tools serve
|
|
168
123
|
```
|
|
169
124
|
|
|
170
125
|
On native Windows, wrap `npx` with `cmd /c`:
|
|
@@ -180,12 +135,7 @@ Equivalent `.mcp.json` shape:
|
|
|
180
135
|
"mcpServers": {
|
|
181
136
|
"browser-devtools": {
|
|
182
137
|
"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
|
-
}
|
|
138
|
+
"args": ["-y", "mcp-browser-dev-tools", "serve"]
|
|
189
139
|
}
|
|
190
140
|
}
|
|
191
141
|
}
|
|
@@ -193,19 +143,14 @@ Equivalent `.mcp.json` shape:
|
|
|
193
143
|
|
|
194
144
|
### Cursor
|
|
195
145
|
|
|
196
|
-
|
|
146
|
+
Minimal local setup:
|
|
197
147
|
|
|
198
148
|
```json
|
|
199
149
|
{
|
|
200
150
|
"mcpServers": {
|
|
201
151
|
"browser-devtools": {
|
|
202
152
|
"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
|
-
}
|
|
153
|
+
"args": ["-y", "mcp-browser-dev-tools", "serve"]
|
|
209
154
|
}
|
|
210
155
|
}
|
|
211
156
|
}
|
|
@@ -213,6 +158,8 @@ Cursor reads MCP servers from `mcp.json`:
|
|
|
213
158
|
|
|
214
159
|
### Common Variants
|
|
215
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
|
+
|
|
216
163
|
Auto mode with both browsers attached to one MCP server:
|
|
217
164
|
|
|
218
165
|
```json
|
|
@@ -241,7 +188,7 @@ Microsoft Edge:
|
|
|
241
188
|
}
|
|
242
189
|
```
|
|
243
190
|
|
|
244
|
-
Windows browser
|
|
191
|
+
Manual Windows browser relay into WSL:
|
|
245
192
|
|
|
246
193
|
```json
|
|
247
194
|
{
|
|
@@ -261,31 +208,13 @@ Enable `evaluate_js`:
|
|
|
261
208
|
}
|
|
262
209
|
```
|
|
263
210
|
|
|
264
|
-
|
|
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
|
|
272
|
-
|
|
273
|
-
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).
|
|
274
212
|
|
|
275
|
-
|
|
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
|
|
282
|
-
```
|
|
213
|
+
## Advanced Environment Options
|
|
283
214
|
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
- `
|
|
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
|
|
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
|
|
289
218
|
- in `auto` mode, assign CDP and Firefox different ports so both browsers can run at once
|
|
290
219
|
- `MCP_BROWSER_EVENT_BUFFER_SIZE` sets the per-session buffered event limit
|
|
291
220
|
- `MCP_BROWSER_LOG_LEVEL` controls diagnostic logging to `stderr`: `error`, `warn`, `info`, or `debug`
|
|
@@ -293,25 +222,40 @@ mbdt relay --wsl
|
|
|
293
222
|
- `MCP_BROWSER_ENABLE_EVAL=1` enables `evaluate_js`
|
|
294
223
|
- `MCP_BROWSER_ALLOW_REMOTE_ENDPOINTS=1` allows non-loopback CDP or BiDi endpoints
|
|
295
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`
|
|
296
226
|
- `MCP_PROTOCOL_VERSION` overrides the advertised MCP protocol version
|
|
297
227
|
|
|
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
228
|
## Exposed Tools
|
|
303
229
|
|
|
304
230
|
- `browser_status` returns broker metadata too: `serverName` and `serverVersion`
|
|
305
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
|
|
306
241
|
- `list_tabs`
|
|
307
242
|
In `auto` mode each `targetId` is namespaced as `chromium:<id>` or `firefox:<id>`
|
|
308
243
|
- `new_tab`
|
|
244
|
+
In `auto` mode, pass `browserFamily`
|
|
309
245
|
- `close_tab`
|
|
310
246
|
- `list_sessions`
|
|
311
247
|
In `auto` mode each `sessionId` is namespaced the same way
|
|
312
248
|
- `attach_tab`
|
|
313
249
|
- `detach_tab`
|
|
314
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`
|
|
315
259
|
- `wait_for`
|
|
316
260
|
- `navigate`
|
|
317
261
|
- `reload`
|
|
@@ -348,12 +292,22 @@ Interaction and inspection tools accept these locator forms:
|
|
|
348
292
|
|
|
349
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.
|
|
350
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
|
+
|
|
351
305
|
## Browser Notes
|
|
352
306
|
|
|
353
307
|
- Chromium uses the standard DevTools endpoints at `/json/version` and `/json/list`
|
|
354
308
|
- Firefox support expects a direct BiDi websocket endpoint
|
|
355
309
|
- In WSL, Linux browser executables are preferred before Windows fallback paths
|
|
356
|
-
- For Windows Chrome + WSL, prefer the
|
|
310
|
+
- For Windows Chrome or Edge + WSL, prefer the broker-managed relay path over changing the browser's remote debugging bind
|
|
357
311
|
|
|
358
312
|
## Why Not Playwright?
|
|
359
313
|
|
|
@@ -396,6 +350,6 @@ The repository uses `pnpm` for local development and CI. End-user installation a
|
|
|
396
350
|
Additional docs:
|
|
397
351
|
|
|
398
352
|
- [Architecture](docs/architecture.md)
|
|
399
|
-
- [
|
|
353
|
+
- [Manual Verification And Troubleshooting](docs/setup.md)
|
|
400
354
|
- [Repository Settings](docs/repository-settings.md)
|
|
401
355
|
- [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
|
|
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
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
|
-
|
|
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() {
|
package/src/browser-adapter.mjs
CHANGED
|
@@ -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
|
}
|