@mozilla/firefox-devtools-mcp 0.9.15 → 0.10.1

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 CHANGED
@@ -19,7 +19,7 @@ Browser MCP servers carry inherent risks. A few key practices:
19
19
 
20
20
  - **Use a dedicated Firefox profile.** Never run the server against your regular profile — the agent has access to whatever the browser can reach, including cookies and saved sessions.
21
21
  - **Be cautious about which sites you visit.** Pages can return content designed to manipulate the agent (prompt injection). Stick to sites you control or trust.
22
- - **Enable only the tool modules you need.** Higher presets such as `--tool-preset developer` (script, debugging) and `--tool-preset mozilla` (privileged context) significantly expand what the agent can do.
22
+ - **Enable only the tool modules you need.** The default `basic` preset already includes `evaluate_script`; `--tool-preset slim` drops it. Higher presets such as `--tool-preset developer` (debugging, network, console, profiler) and `--tool-preset mozilla` (privileged context) expand what the agent can do further.
23
23
 
24
24
  See [SECURITY.md](SECURITY.md) for a full breakdown of risks and how to report vulnerabilities.
25
25
 
@@ -28,19 +28,17 @@ See [SECURITY.md](SECURITY.md) for a full breakdown of risks and how to report v
28
28
  - Node.js ≥ 20.19.0
29
29
  - Firefox 100+ installed (auto‑detected, or pass `--firefox-path`)
30
30
 
31
- ## Install and use with Claude Code (npx)
31
+ ## Install and use with Claude Code or Codex (npx)
32
32
 
33
- Recommended: use npx so you always run the latest published version from npm.
33
+ Recommended: use `npx` so you run the latest published version from npm.
34
34
 
35
- Option A — Claude Code CLI
35
+ ### Option A — CLI
36
+
37
+ #### Claude Code
36
38
 
37
39
  ```bash
38
40
  claude mcp add firefox-devtools npx @mozilla/firefox-devtools-mcp@latest
39
- ```
40
-
41
- Pass options either as args or env vars. Examples:
42
41
 
43
- ```bash
44
42
  # Headless + viewport via args
45
43
  claude mcp add firefox-devtools npx @mozilla/firefox-devtools-mcp@latest -- --headless --viewport 1280x720
46
44
 
@@ -50,13 +48,27 @@ claude mcp add firefox-devtools npx @mozilla/firefox-devtools-mcp@latest \
50
48
  --env FIREFOX_HEADLESS=true
51
49
  ```
52
50
 
53
- Option B — Edit Claude Code settings JSON
51
+ #### Codex
52
+
53
+ ```bash
54
+ codex mcp add firefox-devtools -- npx @mozilla/firefox-devtools-mcp@latest
55
+
56
+ # Headless + viewport via args
57
+ codex mcp add firefox-devtools -- \
58
+ npx @mozilla/firefox-devtools-mcp@latest -- --headless --viewport 1280x720
59
+
60
+ # Or via environment variables
61
+ codex mcp add firefox-devtools \
62
+ --env START_URL=https://example.com \
63
+ --env FIREFOX_HEADLESS=true \
64
+ -- npx @mozilla/firefox-devtools-mcp@latest
65
+ ```
66
+
67
+ ### Option B — Edit the configuration file
54
68
 
55
- Add to your Claude Code config file:
69
+ #### Claude Code
56
70
 
57
- - macOS: `~/Library/Application Support/Claude/Code/mcp_settings.json`
58
- - Linux: `~/.config/claude/code/mcp_settings.json`
59
- - Windows: `%APPDATA%\Claude\Code\mcp_settings.json`
71
+ Add to Claude Code’s mcp_settings.json:
60
72
 
61
73
  ```json
62
74
  {
@@ -72,7 +84,20 @@ Add to your Claude Code config file:
72
84
  }
73
85
  ```
74
86
 
75
- Option C — Helper script (local dev build)
87
+ #### Codex
88
+
89
+ Add to ~/.codex/config.toml:
90
+
91
+ ```toml
92
+ [mcp_servers.firefox-devtools]
93
+ command = "npx"
94
+ args = ["-y", "@mozilla/firefox-devtools-mcp@latest", "--headless", "--viewport", "1280x720"]
95
+
96
+ [mcp_servers.firefox-devtools.env]
97
+ START_URL = "about:blank"
98
+ ```
99
+
100
+ ### Option C — Helper script (local dev build)
76
101
 
77
102
  ```bash
78
103
  npm run setup
@@ -112,7 +137,9 @@ You can pass flags or environment variables (names on the right):
112
137
  - `--enable-script` — _deprecated, use `--tool-preset developer` or `--tools ... script debugging`._ Selects the `developer` tool preset. (`ENABLE_SCRIPT=true`)
113
138
  - `--enable-privileged-context` — _deprecated, use `--tool-preset mozilla` or `--tools ... privileged prefs`._ Selects the `mozilla` tool preset. Requires `MOZ_REMOTE_ALLOW_SYSTEM_ACCESS=1` (`ENABLE_PRIVILEGED_CONTEXT=true`)
114
139
  - `--android-device` — enable Firefox for Android mode; value is the ADB device serial (e.g. `emulator-5554`). Run `adb devices` to list connected devices. Omit the value or use `auto` to select the single connected device automatically.
140
+ - `--android-wipe-app-data` — confirm that Android mode wipes all data of the target app. Required together with `--android-device`. (`ANDROID_WIPE_APP_DATA=true`)
115
141
  - `--android-package` — Android app package name, default `org.mozilla.firefox`. Other packages: `org.mozilla.firefox_beta` for Firefox Beta, `org.mozilla.fenix` for Firefox Nightly, `org.mozilla.fenix.debug` for Firefox Nightly Debug, `org.mozilla.geckoview_example` for geckoview (`ANDROID_PACKAGE`)
142
+ - `--unrestricted-save-paths` — let the `saveTo` parameter write anywhere on disk instead of the default roots. See [Saving bulky output to disk](#saving-bulky-output-to-disk) and the security note in [SECURITY.md](SECURITY.md). (`UNRESTRICTED_SAVE_PATHS=true`)
116
143
  - `--log-file` — write MCP server logs to a file instead of stderr. Useful for debugging sessions with MCP clients that hide server output. Set `DEBUG=*` to also include verbose debug logs. Example: `--log-file /tmp/firefox-mcp.log`
117
144
 
118
145
 
@@ -122,20 +149,24 @@ Tools are grouped into modules. You choose which modules to expose either with a
122
149
  (`--tool-preset`) or with an explicit list (`--tools`). When both are given, `--tools` wins and
123
150
  the preset is ignored.
124
151
 
125
- Modules: `pages`, `snapshot`, `input`, `network`, `console`, `screenshot`, `utilities`,
126
- `management`, `webextension`, `profiler`, `screencast`, `script`, `debugging`, `prefs`,
127
- `privileged`.
152
+ Modules: `pages`, `snapshot`, `input`, `network`, `console`, `screenshot`, `downloads`,
153
+ `utilities`, `management`, `webextension`, `profiler`, `screencast`, `script`, `debugging`,
154
+ `prefs`, `privileged`.
128
155
 
129
156
  Presets (each is a superset of the previous):
130
157
 
131
- - `slim` — `pages`, `snapshot`, `input`, `network`, `console`
132
- - `basic` (default) — `slim` plus `screenshot`, `utilities`, `management`, `webextension`, `profiler`, `screencast`
133
- - `developer` — `basic` plus `script`, `debugging`
158
+ - `slim` — `pages`, `snapshot`, `input`, `screenshot`
159
+ - `basic` (default) — `slim` plus `downloads`, `script`, `utilities`, `management`, `webextension`, `screencast`
160
+ - `developer` — `basic` plus `debugging`, `network`, `console`, `profiler`
134
161
  - `mozilla` — `developer` plus `prefs`, `privileged`
135
162
  - `all` — every module
136
163
 
164
+ Note that `basic`, the default, includes `script` and therefore the `evaluate_script` tool.
165
+ See [SECURITY.md](SECURITY.md#tool-modules-and-presets) for what that means for the attack
166
+ surface, and use `--tool-preset slim` or an explicit `--tools` list to drop it.
167
+
137
168
  ```bash
138
- # Use the developer preset (adds script and debugging tools)
169
+ # Use the developer preset (adds network, console, debugging and profiler tools)
139
170
  npx @mozilla/firefox-devtools-mcp --tool-preset developer
140
171
 
141
172
  # Enable only the modules you need
@@ -143,7 +174,8 @@ npx @mozilla/firefox-devtools-mcp --tools pages network console
143
174
  ```
144
175
 
145
176
  The `prefs` and `privileged` modules require `MOZ_REMOTE_ALLOW_SYSTEM_ACCESS=1` and are only
146
- available in the Mozilla-internal build; the public package silently skips them even if requested.
177
+ available in the Mozilla-internal build. The public package skips them even if requested and
178
+ logs a warning naming the modules it dropped.
147
179
 
148
180
  ### Useful preferences (`--pref`)
149
181
 
@@ -155,18 +187,27 @@ available in the Mozilla-internal build; the public package silently skips them
155
187
 
156
188
  Use `--android-device` to automate Firefox running on an Android device. Requires `adb` on your PATH and geckodriver, which is managed automatically.
157
189
 
190
+ > **Warning:** Android mode wipes all data of the target app before every session.
191
+ > Tabs, history, bookmarks, passwords, cookies and settings are all lost. geckodriver runs
192
+ > `adb shell pm clear <package>` when creating the session and offers no way to skip it,
193
+ > then runs the session on its own temporary profile which is deleted afterwards.
194
+ > Because of this, `--android-device` requires `--android-wipe-app-data`, and you should
195
+ > install a build dedicated to automation rather than automating the browser you use.
196
+ > [Bug 2064088](https://bugzilla.mozilla.org/show_bug.cgi?id=2064088) tracks adding an
197
+ > option to geckodriver to keep the existing app data.
198
+
158
199
  ```bash
159
200
  # List connected devices
160
201
  adb devices
161
202
 
162
203
  # Launch Firefox for Android on the single connected device
163
- npx @mozilla/firefox-devtools-mcp --android-device auto
204
+ npx @mozilla/firefox-devtools-mcp --android-device auto --android-wipe-app-data
164
205
 
165
206
  # Target a specific device
166
- npx @mozilla/firefox-devtools-mcp --android-device <serial>
207
+ npx @mozilla/firefox-devtools-mcp --android-device <serial> --android-wipe-app-data
167
208
 
168
209
  # Use Firefox Nightly instead
169
- npx @mozilla/firefox-devtools-mcp --android-device <serial> --android-package org.mozilla.fenix
210
+ npx @mozilla/firefox-devtools-mcp --android-device <serial> --android-package org.mozilla.fenix --android-wipe-app-data
170
211
  ```
171
212
 
172
213
  Port forwarding between the host and device is handled automatically by geckodriver.
@@ -193,22 +234,18 @@ Both flags are required because the MCP uses both WebDriver Classic (`--marionet
193
234
 
194
235
  ## Tool overview
195
236
 
196
- - Pages: list/new/navigate/select/close
237
+ - Pages: list/new/navigate/select/close/get_page_text (get_page_text supports optional `saveTo`)
197
238
  - Snapshot/UID: take/resolve/clear (take supports optional `saveTo`)
198
239
  - Input: click/hover/fill/drag/upload/form fill
199
- <<<<<<< HEAD
200
240
  - Network: list/get (ID‑first, filters, always‑on capture; both support optional `saveTo`)
201
- - Console: list/clear (list supports optional `saveTo`)
202
- =======
203
- - Network: list/get (ID‑first, filters, always‑on capture)
204
241
  - Downloads: list_downloads/clear_downloads (always‑on capture), set_download_behavior (allow/deny/default)
205
- - Console: list/clear
206
- >>>>>>> 6873767 (Bug 2055949 - [firefox-devtools-mcp] expose download events to firefox devtools mcp)
242
+ - Console: list/clear (list supports optional `saveTo`)
207
243
  - Screenshot: page/by uid (with optional `saveTo` for CLI environments)
208
- - Script: evaluate_script (with optional `saveTo` for bulky results)
244
+ - Script: evaluate_script (optional `sandbox` for an isolated realm; optional `saveTo` for bulky results)
209
245
  - Privileged Context: list/select privileged ("chrome") contexts, evaluate_privileged_script (requires `MOZ_REMOTE_ALLOW_SYSTEM_ACCESS=1`)
210
246
  - WebExtension: install_extension, uninstall_extension, list_extensions (list requires `MOZ_REMOTE_ALLOW_SYSTEM_ACCESS=1`)
211
- - Firefox Management: get_firefox_info, get_firefox_output, restart_firefox, set_firefox_prefs, get_firefox_prefs
247
+ - Firefox Management: get_firefox_info, get_firefox_output, restart_firefox
248
+ - Firefox Preferences: get_firefox_prefs, set_firefox_prefs (requires `MOZ_REMOTE_ALLOW_SYSTEM_ACCESS=1`)
212
249
  - Profiler: profiler_is_active, profiler_start (preset or explicit config), profiler_stop (saves profile to downloads directory)
213
250
  - Screencast: screencast_start (records the page viewport to a video file in the downloads directory), screencast_stop (requires Firefox 154+)
214
251
  - Utilities: accept/dismiss dialog, history back/forward, set viewport
@@ -217,7 +254,8 @@ Both flags are required because the MCP uses both WebDriver Classic (`--marionet
217
254
 
218
255
  Large tool output can consume significant context in CLI clients like Claude Code. The
219
256
  `screenshot_page`, `screenshot_by_uid`, `take_snapshot`, `list_console_messages`,
220
- `list_network_requests`, `get_network_request`, `evaluate_script`, and
257
+ `list_network_requests`, `get_network_request`, `get_page_text`,
258
+ `evaluate_script`, and
221
259
  `evaluate_privileged_script` tools accept an optional `saveTo` parameter that writes the
222
260
  result to a file instead of returning it inline. `saveTo` takes one of three forms:
223
261
 
@@ -245,7 +283,7 @@ directory, and absolute paths are only allowed within `~/.firefox-devtools-mcp`.
245
283
  escape these locations are rejected. Start the server with `--unrestricted-save-paths` to
246
284
  write to arbitrary locations, including absolute paths outside that directory.
247
285
 
248
- Saved files can then be viewed with Claude Code's `Read` tool without impacting context size.
286
+ Saved files can then be viewed for instance with Claude Code's `Read` tool without impacting context size.
249
287
 
250
288
  ## Local development
251
289
 
@@ -266,7 +304,7 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for more details on local development, te
266
304
 
267
305
  - Firefox not found: pass `--firefox-path "/Applications/Firefox.app/Contents/MacOS/firefox"` (macOS) or the correct path on your OS.
268
306
  - First run is slow: Selenium sets up the BiDi session; subsequent runs are faster.
269
- - Stale UIDs after navigation: take a fresh snapshot (`take_snapshot`) before using UID tools.
307
+ - Stale UIDs: a UID stays valid until its element is removed or the page navigates; take a fresh snapshot (`take_snapshot`) when a UID tool reports one is gone.
270
308
  - Windows 10: Error during discovery for MCP server 'firefox-devtools': MCP error -32000: Connection closed
271
309
  - **Solution 1** Wrap with `cmd /c` ([details](https://github.com/modelcontextprotocol/servers/issues/1082#issuecomment-2791786310)):
272
310