mcp-browser-dev-tools 0.0.1-beta.2 → 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 +166 -14
- package/package.json +3 -1
- package/src/cdp-client.mjs +518 -83
- package/src/cli.mjs +64 -2
- package/src/firefox-bidi-client.mjs +362 -80
- package/src/json-rpc-stdio.mjs +130 -21
- package/src/mcp-server.mjs +355 -4
- package/src/page-context.mjs +719 -0
- package/src/session-events.mjs +16 -2
package/README.md
CHANGED
|
@@ -10,7 +10,8 @@ It is designed for a local trust boundary:
|
|
|
10
10
|
|
|
11
11
|
- A stdio MCP server for local desktop and terminal clients
|
|
12
12
|
- Browser discovery and attach/detach for Chromium-family browsers and Firefox
|
|
13
|
-
-
|
|
13
|
+
- Inspection tools for DOM lookup, richer element details, console messages, network requests, screenshots, tab listing, and buffered events
|
|
14
|
+
- Page interaction tools for navigation, reload, click, hover, type, select, key presses, scroll, and viewport overrides
|
|
14
15
|
- Optional JavaScript evaluation behind an explicit environment flag
|
|
15
16
|
- Helper commands to check browser connectivity, launch a debug-enabled browser, and relay CDP traffic across a local machine boundary
|
|
16
17
|
|
|
@@ -24,6 +25,8 @@ It is designed for a local trust boundary:
|
|
|
24
25
|
|
|
25
26
|
If you are trying the prerelease from npm, replace `mcp-browser-dev-tools` below with `mcp-browser-dev-tools@beta`.
|
|
26
27
|
|
|
28
|
+
The published package name stays `mcp-browser-dev-tools`. The preferred installed CLI command is `mbdt`.
|
|
29
|
+
|
|
27
30
|
One-off execution with `npx`:
|
|
28
31
|
|
|
29
32
|
```bash
|
|
@@ -34,14 +37,14 @@ Global install:
|
|
|
34
37
|
|
|
35
38
|
```bash
|
|
36
39
|
npm install -g mcp-browser-dev-tools
|
|
37
|
-
|
|
40
|
+
mbdt serve
|
|
38
41
|
```
|
|
39
42
|
|
|
40
43
|
Project-local install:
|
|
41
44
|
|
|
42
45
|
```bash
|
|
43
46
|
npm install mcp-browser-dev-tools
|
|
44
|
-
npx
|
|
47
|
+
npx mbdt serve
|
|
45
48
|
```
|
|
46
49
|
|
|
47
50
|
## Try It Locally
|
|
@@ -53,13 +56,20 @@ For Windows, WSL, macOS, and Linux-specific setup paths, see [docs/setup.md](doc
|
|
|
53
56
|
Quick Chromium flow:
|
|
54
57
|
|
|
55
58
|
```bash
|
|
56
|
-
# Launch a local browser with remote debugging enabled
|
|
57
|
-
|
|
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:
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
npx -y mcp-browser-dev-tools@beta doctor --url http://127.0.0.1:3000
|
|
68
|
+
```
|
|
58
69
|
|
|
59
|
-
|
|
60
|
-
npx -y mcp-browser-dev-tools@beta doctor --url https://example.com
|
|
70
|
+
Then start the MCP server in a dedicated terminal:
|
|
61
71
|
|
|
62
|
-
|
|
72
|
+
```bash
|
|
63
73
|
npx -y mcp-browser-dev-tools@beta serve
|
|
64
74
|
```
|
|
65
75
|
|
|
@@ -75,7 +85,78 @@ If you need to bridge Windows Chrome into WSL without changing WSL networking mo
|
|
|
75
85
|
|
|
76
86
|
## MCP Client Configuration
|
|
77
87
|
|
|
78
|
-
|
|
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`:
|
|
79
160
|
|
|
80
161
|
```json
|
|
81
162
|
{
|
|
@@ -92,7 +173,34 @@ Generic stdio client configuration:
|
|
|
92
173
|
}
|
|
93
174
|
```
|
|
94
175
|
|
|
95
|
-
|
|
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
|
+
```
|
|
96
204
|
|
|
97
205
|
## Commands
|
|
98
206
|
|
|
@@ -106,10 +214,10 @@ For Firefox, switch `MCP_BROWSER_FAMILY` to `firefox` and set `FIREFOX_BIDI_WS_U
|
|
|
106
214
|
Examples:
|
|
107
215
|
|
|
108
216
|
```bash
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
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
|
|
113
221
|
```
|
|
114
222
|
|
|
115
223
|
## Configuration
|
|
@@ -134,6 +242,16 @@ The `relay` command defaults to `127.0.0.1:9223 -> 127.0.0.1:9222`. Non-loopback
|
|
|
134
242
|
- `list_sessions`
|
|
135
243
|
- `attach_tab`
|
|
136
244
|
- `detach_tab`
|
|
245
|
+
- `get_page_state`
|
|
246
|
+
- `navigate`
|
|
247
|
+
- `reload`
|
|
248
|
+
- `click`
|
|
249
|
+
- `hover`
|
|
250
|
+
- `type`
|
|
251
|
+
- `select`
|
|
252
|
+
- `press_key`
|
|
253
|
+
- `scroll`
|
|
254
|
+
- `set_viewport`
|
|
137
255
|
- `get_console_messages`
|
|
138
256
|
- `get_network_requests`
|
|
139
257
|
- `get_document`
|
|
@@ -145,6 +263,21 @@ The `relay` command defaults to `127.0.0.1:9223 -> 127.0.0.1:9222`. Non-loopback
|
|
|
145
263
|
|
|
146
264
|
For tools that take `sessionId`, call `attach_tab` first and reuse the returned session.
|
|
147
265
|
|
|
266
|
+
### Locator Syntax
|
|
267
|
+
|
|
268
|
+
Interaction and inspection tools accept these locator forms:
|
|
269
|
+
|
|
270
|
+
- CSS selectors such as `#app button.primary` or `css=.modal button`
|
|
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`
|
|
274
|
+
|
|
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.
|
|
276
|
+
|
|
277
|
+
### Screenshot Output
|
|
278
|
+
|
|
279
|
+
`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.
|
|
280
|
+
|
|
148
281
|
## Browser Notes
|
|
149
282
|
|
|
150
283
|
- Chromium uses the standard DevTools endpoints at `/json/version` and `/json/list`
|
|
@@ -152,6 +285,25 @@ For tools that take `sessionId`, call `attach_tab` first and reuse the returned
|
|
|
152
285
|
- In WSL, Linux browser executables are preferred before Windows fallback paths
|
|
153
286
|
- For Windows Chrome + WSL, prefer the `relay` command over changing Chrome's remote debugging bind
|
|
154
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
|
+
|
|
301
|
+
## Debugging Notes
|
|
302
|
+
|
|
303
|
+
- `attach_tab` now seeds network history from the Performance API so already-loaded pages still show useful requests
|
|
304
|
+
- console buffers include source URL, line and column where the browser reports them, plus stack frames when available
|
|
305
|
+
- `get_page_state` reports the current URL, title, viewport, and scroll position without enabling `evaluate_js`
|
|
306
|
+
|
|
155
307
|
## Safety Defaults
|
|
156
308
|
|
|
157
309
|
- The broker only allows loopback browser endpoints unless you opt in
|
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",
|
|
@@ -31,6 +31,7 @@
|
|
|
31
31
|
"src/index.mjs",
|
|
32
32
|
"src/json-rpc-stdio.mjs",
|
|
33
33
|
"src/mcp-server.mjs",
|
|
34
|
+
"src/page-context.mjs",
|
|
34
35
|
"src/package-info.mjs",
|
|
35
36
|
"src/session-events.mjs",
|
|
36
37
|
"src/server.mjs",
|
|
@@ -38,6 +39,7 @@
|
|
|
38
39
|
"README.md"
|
|
39
40
|
],
|
|
40
41
|
"bin": {
|
|
42
|
+
"mbdt": "cli.mjs",
|
|
41
43
|
"mcp-browser-dev-tools": "cli.mjs"
|
|
42
44
|
},
|
|
43
45
|
"keywords": [
|