mcp-browser-dev-tools 0.0.1-beta.3 → 0.0.1-beta.4
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 +136 -16
- package/package.json +2 -1
- package/src/cli.mjs +64 -2
package/README.md
CHANGED
|
@@ -25,6 +25,8 @@ It is designed for a local trust boundary:
|
|
|
25
25
|
|
|
26
26
|
If you are trying the prerelease from npm, replace `mcp-browser-dev-tools` below with `mcp-browser-dev-tools@beta`.
|
|
27
27
|
|
|
28
|
+
The published package name stays `mcp-browser-dev-tools`. The preferred installed CLI command is `mbdt`.
|
|
29
|
+
|
|
28
30
|
One-off execution with `npx`:
|
|
29
31
|
|
|
30
32
|
```bash
|
|
@@ -35,14 +37,14 @@ Global install:
|
|
|
35
37
|
|
|
36
38
|
```bash
|
|
37
39
|
npm install -g mcp-browser-dev-tools
|
|
38
|
-
|
|
40
|
+
mbdt serve
|
|
39
41
|
```
|
|
40
42
|
|
|
41
43
|
Project-local install:
|
|
42
44
|
|
|
43
45
|
```bash
|
|
44
46
|
npm install mcp-browser-dev-tools
|
|
45
|
-
npx
|
|
47
|
+
npx mbdt serve
|
|
46
48
|
```
|
|
47
49
|
|
|
48
50
|
## Try It Locally
|
|
@@ -54,13 +56,20 @@ For Windows, WSL, macOS, and Linux-specific setup paths, see [docs/setup.md](doc
|
|
|
54
56
|
Quick Chromium flow:
|
|
55
57
|
|
|
56
58
|
```bash
|
|
57
|
-
# Launch a local browser with remote debugging enabled
|
|
58
|
-
|
|
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@beta open about:blank --family chromium
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
If you want to verify a specific app URL too:
|
|
59
65
|
|
|
60
|
-
|
|
61
|
-
npx -y mcp-browser-dev-tools@beta doctor --url
|
|
66
|
+
```bash
|
|
67
|
+
npx -y mcp-browser-dev-tools@beta doctor --url http://127.0.0.1:3000
|
|
68
|
+
```
|
|
62
69
|
|
|
63
|
-
|
|
70
|
+
Then start the MCP server in a dedicated terminal:
|
|
71
|
+
|
|
72
|
+
```bash
|
|
64
73
|
npx -y mcp-browser-dev-tools@beta serve
|
|
65
74
|
```
|
|
66
75
|
|
|
@@ -76,7 +85,78 @@ If you need to bridge Windows Chrome into WSL without changing WSL networking mo
|
|
|
76
85
|
|
|
77
86
|
## MCP Client Configuration
|
|
78
87
|
|
|
79
|
-
|
|
88
|
+
Use the same server command across MCP clients:
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
npx -y mcp-browser-dev-tools@beta serve
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
If you installed the package already, the shorter equivalent is:
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
mbdt serve
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### Codex
|
|
101
|
+
|
|
102
|
+
Add the server with the Codex CLI:
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
codex mcp add browser-devtools \
|
|
106
|
+
--env MCP_BROWSER_FAMILY=chromium \
|
|
107
|
+
--env CDP_BASE_URL=http://127.0.0.1:9222 \
|
|
108
|
+
-- npx -y mcp-browser-dev-tools@beta serve
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
Equivalent `~/.codex/config.toml` entry:
|
|
112
|
+
|
|
113
|
+
```toml
|
|
114
|
+
[mcp_servers.browser-devtools]
|
|
115
|
+
command = "npx"
|
|
116
|
+
args = ["-y", "mcp-browser-dev-tools@beta", "serve"]
|
|
117
|
+
|
|
118
|
+
[mcp_servers.browser-devtools.env]
|
|
119
|
+
MCP_BROWSER_FAMILY = "chromium"
|
|
120
|
+
CDP_BASE_URL = "http://127.0.0.1:9222"
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
### Claude Code
|
|
124
|
+
|
|
125
|
+
Add the server with Claude Code:
|
|
126
|
+
|
|
127
|
+
```bash
|
|
128
|
+
claude mcp add browser-devtools --scope user \
|
|
129
|
+
--env MCP_BROWSER_FAMILY=chromium \
|
|
130
|
+
--env CDP_BASE_URL=http://127.0.0.1:9222 \
|
|
131
|
+
-- npx -y mcp-browser-dev-tools@beta serve
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
On native Windows, wrap `npx` with `cmd /c`:
|
|
135
|
+
|
|
136
|
+
```powershell
|
|
137
|
+
claude mcp add browser-devtools --scope user --env MCP_BROWSER_FAMILY=chromium --env CDP_BASE_URL=http://127.0.0.1:9222 -- cmd /c npx -y mcp-browser-dev-tools@beta serve
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
Equivalent `.mcp.json` shape:
|
|
141
|
+
|
|
142
|
+
```json
|
|
143
|
+
{
|
|
144
|
+
"mcpServers": {
|
|
145
|
+
"browser-devtools": {
|
|
146
|
+
"command": "npx",
|
|
147
|
+
"args": ["-y", "mcp-browser-dev-tools@beta", "serve"],
|
|
148
|
+
"env": {
|
|
149
|
+
"MCP_BROWSER_FAMILY": "chromium",
|
|
150
|
+
"CDP_BASE_URL": "http://127.0.0.1:9222"
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
### Cursor
|
|
158
|
+
|
|
159
|
+
Cursor reads MCP servers from `mcp.json`:
|
|
80
160
|
|
|
81
161
|
```json
|
|
82
162
|
{
|
|
@@ -93,7 +173,34 @@ Generic stdio client configuration:
|
|
|
93
173
|
}
|
|
94
174
|
```
|
|
95
175
|
|
|
96
|
-
|
|
176
|
+
### Common Variants
|
|
177
|
+
|
|
178
|
+
Firefox:
|
|
179
|
+
|
|
180
|
+
```json
|
|
181
|
+
{
|
|
182
|
+
"MCP_BROWSER_FAMILY": "firefox",
|
|
183
|
+
"FIREFOX_BIDI_WS_URL": "ws://127.0.0.1:9222"
|
|
184
|
+
}
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
Windows browser bridged into WSL through the relay:
|
|
188
|
+
|
|
189
|
+
```json
|
|
190
|
+
{
|
|
191
|
+
"MCP_BROWSER_FAMILY": "chromium",
|
|
192
|
+
"MCP_BROWSER_ALLOW_REMOTE_ENDPOINTS": "1",
|
|
193
|
+
"CDP_BASE_URL": "http://<windows-host-ip>:9223"
|
|
194
|
+
}
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
Enable `evaluate_js`:
|
|
198
|
+
|
|
199
|
+
```json
|
|
200
|
+
{
|
|
201
|
+
"MCP_BROWSER_ENABLE_EVAL": "1"
|
|
202
|
+
}
|
|
203
|
+
```
|
|
97
204
|
|
|
98
205
|
## Commands
|
|
99
206
|
|
|
@@ -107,10 +214,10 @@ For Firefox, switch `MCP_BROWSER_FAMILY` to `firefox` and set `FIREFOX_BIDI_WS_U
|
|
|
107
214
|
Examples:
|
|
108
215
|
|
|
109
216
|
```bash
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
217
|
+
mbdt doctor
|
|
218
|
+
mbdt doctor --url http://127.0.0.1:3000
|
|
219
|
+
mbdt open http://127.0.0.1:3000 --family chromium
|
|
220
|
+
mbdt relay --wsl
|
|
114
221
|
```
|
|
115
222
|
|
|
116
223
|
## Configuration
|
|
@@ -161,9 +268,9 @@ For tools that take `sessionId`, call `attach_tab` first and reuse the returned
|
|
|
161
268
|
Interaction and inspection tools accept these locator forms:
|
|
162
269
|
|
|
163
270
|
- CSS selectors such as `#app button.primary` or `css=.modal button`
|
|
164
|
-
- visible-text lookup such as `text
|
|
165
|
-
- role plus accessible name such as `role=button[name="
|
|
166
|
-
- accessible-name lookup such as `name
|
|
271
|
+
- visible-text lookup such as `text=Open settings`
|
|
272
|
+
- role plus accessible name such as `role=button[name="Open settings"]`
|
|
273
|
+
- accessible-name lookup such as `name=Open settings`
|
|
167
274
|
|
|
168
275
|
`inspect_element` returns layout and accessibility-focused metadata including bounding box, visibility flags, interactivity flags, accessible name, inferred role, and a subset of computed styles. Invalid CSS selectors now return an explicit locator error instead of a generic DOM failure.
|
|
169
276
|
|
|
@@ -178,6 +285,19 @@ Interaction and inspection tools accept these locator forms:
|
|
|
178
285
|
- In WSL, Linux browser executables are preferred before Windows fallback paths
|
|
179
286
|
- For Windows Chrome + WSL, prefer the `relay` command over changing Chrome's remote debugging bind
|
|
180
287
|
|
|
288
|
+
## Why Not Playwright?
|
|
289
|
+
|
|
290
|
+
Playwright is still the stronger choice for deterministic browser automation and end-to-end tests. It has a more mature locator model, assertions, waiting semantics, tracing, and CI story.
|
|
291
|
+
|
|
292
|
+
`mcp-browser-dev-tools` solves a different problem:
|
|
293
|
+
|
|
294
|
+
- it is MCP-native, so AI clients call a bounded tool surface instead of generating and executing Playwright scripts
|
|
295
|
+
- it attaches to an already-open browser tab and inspects the current session state, cookies, login state, extensions, console, and network history
|
|
296
|
+
- it is designed for local AI debugging workflows, including loopback-only defaults, opt-in evaluation, and the Windows-to-WSL relay path
|
|
297
|
+
- it presents one MCP interface across Chromium CDP and Firefox BiDi instead of requiring the AI client to know browser protocol details
|
|
298
|
+
|
|
299
|
+
Use Playwright when you want reproducible automation. Use this project when you want an AI assistant to inspect and manipulate a live browser session through MCP.
|
|
300
|
+
|
|
181
301
|
## Debugging Notes
|
|
182
302
|
|
|
183
303
|
- `attach_tab` now seeds network history from the Performance API so already-loaded pages still show useful requests
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mcp-browser-dev-tools",
|
|
3
|
-
"version": "0.0.1-beta.
|
|
3
|
+
"version": "0.0.1-beta.4",
|
|
4
4
|
"description": "Local MCP server for Chromium DevTools Protocol and Firefox WebDriver BiDi",
|
|
5
5
|
"author": "Hinaser <rindo.hinase@gmail.com>",
|
|
6
6
|
"type": "module",
|
|
@@ -39,6 +39,7 @@
|
|
|
39
39
|
"README.md"
|
|
40
40
|
],
|
|
41
41
|
"bin": {
|
|
42
|
+
"mbdt": "cli.mjs",
|
|
42
43
|
"mcp-browser-dev-tools": "cli.mjs"
|
|
43
44
|
},
|
|
44
45
|
"keywords": [
|
package/src/cli.mjs
CHANGED
|
@@ -69,6 +69,8 @@ function printUsage() {
|
|
|
69
69
|
" --port <port> remote debugging port",
|
|
70
70
|
" --address <host> remote debugging address for Chromium",
|
|
71
71
|
" --user-data-dir <p> optional browser profile directory",
|
|
72
|
+
" --wait-ms <ms> wait for the debug endpoint and print doctor output",
|
|
73
|
+
" --no-doctor skip the post-launch doctor check",
|
|
72
74
|
"",
|
|
73
75
|
"Relay options:",
|
|
74
76
|
" --listen-host <host> relay bind host (defaults to 127.0.0.1)",
|
|
@@ -85,6 +87,21 @@ function printVersion() {
|
|
|
85
87
|
process.stdout.write(`${PACKAGE_VERSION}\n`);
|
|
86
88
|
}
|
|
87
89
|
|
|
90
|
+
function sleep(ms) {
|
|
91
|
+
return new Promise((resolve) => {
|
|
92
|
+
setTimeout(resolve, ms);
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function isHttpLikeUrl(value) {
|
|
97
|
+
try {
|
|
98
|
+
const url = new URL(value);
|
|
99
|
+
return url.protocol === "http:" || url.protocol === "https:";
|
|
100
|
+
} catch {
|
|
101
|
+
return false;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
88
105
|
async function runServe() {
|
|
89
106
|
const app = createBrowserDevToolsApp();
|
|
90
107
|
app.installSignalHandlers();
|
|
@@ -137,12 +154,13 @@ async function runOpen(positional, options) {
|
|
|
137
154
|
family === "firefox"
|
|
138
155
|
? new URL(config.firefoxBidiWsUrl).port || "9222"
|
|
139
156
|
: new URL(config.cdpBaseUrl).port || "9222";
|
|
157
|
+
const resolvedPort =
|
|
158
|
+
typeof options.port === "string" ? options.port : defaultPort;
|
|
140
159
|
|
|
141
160
|
const args = buildBrowserLaunchArgs({
|
|
142
161
|
family,
|
|
143
162
|
url,
|
|
144
|
-
remoteDebuggingPort:
|
|
145
|
-
typeof options.port === "string" ? options.port : defaultPort,
|
|
163
|
+
remoteDebuggingPort: resolvedPort,
|
|
146
164
|
remoteDebuggingAddress: requestedAddress || undefined,
|
|
147
165
|
userDataDir:
|
|
148
166
|
family === "chromium" && typeof options["user-data-dir"] === "string"
|
|
@@ -159,6 +177,50 @@ async function runOpen(positional, options) {
|
|
|
159
177
|
process.stdout.write(
|
|
160
178
|
`launched ${family} browser: ${executable} ${args.join(" ")}\n`,
|
|
161
179
|
);
|
|
180
|
+
|
|
181
|
+
if (options["no-doctor"] === true) {
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
const waitMs =
|
|
186
|
+
typeof options["wait-ms"] === "string"
|
|
187
|
+
? Number.parseInt(options["wait-ms"], 10)
|
|
188
|
+
: 5000;
|
|
189
|
+
const timeoutMs = Number.isInteger(waitMs) && waitMs >= 0 ? waitMs : 5000;
|
|
190
|
+
const startedAt = Date.now();
|
|
191
|
+
const doctorEnv = {
|
|
192
|
+
...process.env,
|
|
193
|
+
MCP_BROWSER_FAMILY: family,
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
if (family === "firefox") {
|
|
197
|
+
doctorEnv.FIREFOX_BIDI_WS_URL = `ws://127.0.0.1:${resolvedPort}`;
|
|
198
|
+
} else {
|
|
199
|
+
const address = requestedAddress || "127.0.0.1";
|
|
200
|
+
doctorEnv.CDP_BASE_URL = `http://${address}:${resolvedPort}`;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
let report = await collectDoctorReport({
|
|
204
|
+
env: doctorEnv,
|
|
205
|
+
url: isHttpLikeUrl(url) ? url : null,
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
while (
|
|
209
|
+
!report.browserStatus.available &&
|
|
210
|
+
Date.now() - startedAt < timeoutMs
|
|
211
|
+
) {
|
|
212
|
+
await sleep(250);
|
|
213
|
+
report = await collectDoctorReport({
|
|
214
|
+
env: doctorEnv,
|
|
215
|
+
url: isHttpLikeUrl(url) ? url : null,
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
process.stdout.write(`${renderDoctorReport(report)}\n`);
|
|
220
|
+
|
|
221
|
+
if (!report.browserStatus.available) {
|
|
222
|
+
process.exitCode = 1;
|
|
223
|
+
}
|
|
162
224
|
}
|
|
163
225
|
|
|
164
226
|
async function runRelay(options) {
|