mcp-browser-dev-tools 0.0.1-beta.10 → 0.0.1-beta.11
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 +30 -4
- package/package.json +1 -1
- package/src/cdp-client.mjs +2 -0
package/README.md
CHANGED
|
@@ -79,11 +79,13 @@ If you want one broker to handle Chromium and Firefox at the same time, run it i
|
|
|
79
79
|
|
|
80
80
|
```bash
|
|
81
81
|
MCP_BROWSER_FAMILY=auto \
|
|
82
|
-
CDP_BASE_URL=http://127.0.0.1:
|
|
83
|
-
FIREFOX_BIDI_WS_URL=ws://127.0.0.1:
|
|
82
|
+
CDP_BASE_URL=http://127.0.0.1:9223 \
|
|
83
|
+
FIREFOX_BIDI_WS_URL=ws://127.0.0.1:9222 \
|
|
84
84
|
npx -y mcp-browser-dev-tools@beta serve
|
|
85
85
|
```
|
|
86
86
|
|
|
87
|
+
Use distinct ports in `auto` mode. A practical local split is Firefox on `9222` and Chrome or Edge on `9223`.
|
|
88
|
+
|
|
87
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:
|
|
88
90
|
|
|
89
91
|
```bash
|
|
@@ -129,6 +131,28 @@ MCP_BROWSER_FAMILY = "chromium"
|
|
|
129
131
|
CDP_BASE_URL = "http://127.0.0.1:9222"
|
|
130
132
|
```
|
|
131
133
|
|
|
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
|
+
|
|
132
156
|
### Claude Code
|
|
133
157
|
|
|
134
158
|
Add the server with Claude Code:
|
|
@@ -189,8 +213,8 @@ Auto mode with both browsers attached to one MCP server:
|
|
|
189
213
|
```json
|
|
190
214
|
{
|
|
191
215
|
"MCP_BROWSER_FAMILY": "auto",
|
|
192
|
-
"CDP_BASE_URL": "http://127.0.0.1:
|
|
193
|
-
"FIREFOX_BIDI_WS_URL": "ws://127.0.0.1:
|
|
216
|
+
"CDP_BASE_URL": "http://127.0.0.1:9223",
|
|
217
|
+
"FIREFOX_BIDI_WS_URL": "ws://127.0.0.1:9222"
|
|
194
218
|
}
|
|
195
219
|
```
|
|
196
220
|
|
|
@@ -245,6 +269,7 @@ Examples:
|
|
|
245
269
|
mbdt doctor
|
|
246
270
|
mbdt doctor --url http://127.0.0.1:3000
|
|
247
271
|
mbdt open http://127.0.0.1:3000 --family chromium
|
|
272
|
+
mbdt open http://127.0.0.1:3000 --family edge --port 9223 --user-data-dir /tmp/mbdt-edge
|
|
248
273
|
mbdt open about:blank --family firefox --user-data-dir /tmp/mbdt-firefox
|
|
249
274
|
mbdt relay --wsl
|
|
250
275
|
```
|
|
@@ -254,6 +279,7 @@ mbdt relay --wsl
|
|
|
254
279
|
- `MCP_BROWSER_FAMILY` defaults to `chromium`; set `edge` for Microsoft Edge, `firefox` for Firefox BiDi, or `auto` to multiplex both adapters
|
|
255
280
|
- `CDP_BASE_URL` defaults to `http://127.0.0.1:9222`
|
|
256
281
|
- `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
|
|
282
|
+
- in `auto` mode, assign CDP and Firefox different ports so both browsers can run at once
|
|
257
283
|
- `MCP_BROWSER_EVENT_BUFFER_SIZE` sets the per-session buffered event limit
|
|
258
284
|
- `MCP_BROWSER_ENABLE_EVAL=1` enables `evaluate_js`
|
|
259
285
|
- `MCP_BROWSER_ALLOW_REMOTE_ENDPOINTS=1` allows non-loopback CDP or BiDi endpoints
|
package/package.json
CHANGED
package/src/cdp-client.mjs
CHANGED
|
@@ -298,6 +298,7 @@ async function readWebSocketData(data) {
|
|
|
298
298
|
export class CdpSession {
|
|
299
299
|
constructor(target, options = {}) {
|
|
300
300
|
this.id = crypto.randomUUID();
|
|
301
|
+
this.config = options.config ?? { browserFamily: "chromium" };
|
|
301
302
|
this.target = target;
|
|
302
303
|
this.eventBufferSize = options.eventBufferSize ?? 200;
|
|
303
304
|
this.onClosed = options.onClosed ?? null;
|
|
@@ -932,6 +933,7 @@ export class CdpSessionManager {
|
|
|
932
933
|
}
|
|
933
934
|
|
|
934
935
|
const session = new CdpSession(target, {
|
|
936
|
+
config: this.config,
|
|
935
937
|
eventBufferSize: this.config.eventBufferSize,
|
|
936
938
|
onClosed: (closedSession) => {
|
|
937
939
|
this.sessions.delete(closedSession.id);
|