@mozilla/firefox-devtools-mcp 0.9.12 → 0.10.0

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
- - **Avoid enabling extra flags unless needed.** `--enable-script` and `--enable-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
@@ -90,6 +115,7 @@ Then call tools like:
90
115
  - `list_pages`, `select_page`, `navigate_page`
91
116
  - `take_snapshot` then `click_by_uid` / `fill_by_uid`
92
117
  - `list_network_requests` (always‑on capture), `get_network_request`
118
+ - `list_downloads` (always‑on capture), `set_download_behavior`
93
119
  - `screenshot_page`, `list_console_messages`
94
120
 
95
121
  ## CLI options
@@ -106,13 +132,51 @@ You can pass flags or environment variables (names on the right):
106
132
  - `--connect-existing` — attach to an already-running Firefox instead of launching a new one (`CONNECT_EXISTING=true`)
107
133
  - `--marionette-port` — Marionette port for connect-existing mode, default 2828 (`MARIONETTE_PORT`)
108
134
  - `--pref name=value` — set Firefox preference at startup via `moz:firefoxOptions` (repeatable)
109
- - `--enable-script` — enable the `evaluate_script` tool (executes arbitrary JavaScript in the page context) and debugging tools (list scripts, inspect source, set logpoints). Debugging tools require Firefox 153+. (`ENABLE_SCRIPT=true`)
110
- - `--enable-privileged-context` — enable privileged context tools: list/select privileged contexts, evaluate privileged scripts, get/set Firefox prefs, and list extensions. Requires `MOZ_REMOTE_ALLOW_SYSTEM_ACCESS=1` (`ENABLE_PRIVILEGED_CONTEXT=true`)
135
+ - `--tool-preset` — select which tool modules to enable: `slim`, `basic` (default), `developer`, `mozilla`, or `all`. See [Tool modules and presets](#tool-modules-and-presets). (`TOOL_PRESET`)
136
+ - `--tools` — explicit list of tool modules to enable, overriding `--tool-preset` entirely (e.g. `--tools pages network script`). See [Tool modules and presets](#tool-modules-and-presets).
137
+ - `--enable-script` — _deprecated, use `--tool-preset developer` or `--tools ... script debugging`._ Selects the `developer` tool preset. (`ENABLE_SCRIPT=true`)
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`)
111
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`)
112
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`)
113
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`
114
144
 
115
145
 
146
+ ### Tool modules and presets
147
+
148
+ Tools are grouped into modules. You choose which modules to expose either with a named preset
149
+ (`--tool-preset`) or with an explicit list (`--tools`). When both are given, `--tools` wins and
150
+ the preset is ignored.
151
+
152
+ Modules: `pages`, `snapshot`, `input`, `network`, `console`, `screenshot`, `downloads`,
153
+ `utilities`, `management`, `webextension`, `profiler`, `screencast`, `script`, `debugging`,
154
+ `prefs`, `privileged`.
155
+
156
+ Presets (each is a superset of the previous):
157
+
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`
161
+ - `mozilla` — `developer` plus `prefs`, `privileged`
162
+ - `all` — every module
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
+
168
+ ```bash
169
+ # Use the developer preset (adds network, console, debugging and profiler tools)
170
+ npx @mozilla/firefox-devtools-mcp --tool-preset developer
171
+
172
+ # Enable only the modules you need
173
+ npx @mozilla/firefox-devtools-mcp --tools pages network console
174
+ ```
175
+
176
+ The `prefs` and `privileged` modules require `MOZ_REMOTE_ALLOW_SYSTEM_ACCESS=1` and are only
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.
179
+
116
180
  ### Useful preferences (`--pref`)
117
181
 
118
182
  - remote.prefs.recommended=false. When Firefox runs in automation, it applies [RecommendedPreferences](https://searchfox.org/firefox-main/source/remote/shared/RecommendedPreferences.sys.mjs) that modify browser behavior for testing. Set remote.prefs.recommended to false to skip those and have a configuration closer to a regular Firefox instance.
@@ -123,37 +187,44 @@ You can pass flags or environment variables (names on the right):
123
187
 
124
188
  Use `--android-device` to automate Firefox running on an Android device. Requires `adb` on your PATH and geckodriver, which is managed automatically.
125
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
+
126
199
  ```bash
127
200
  # List connected devices
128
201
  adb devices
129
202
 
130
203
  # Launch Firefox for Android on the single connected device
131
- npx @mozilla/firefox-devtools-mcp --android-device auto
204
+ npx @mozilla/firefox-devtools-mcp --android-device auto --android-wipe-app-data
132
205
 
133
206
  # Target a specific device
134
- npx @mozilla/firefox-devtools-mcp --android-device <serial>
207
+ npx @mozilla/firefox-devtools-mcp --android-device <serial> --android-wipe-app-data
135
208
 
136
209
  # Use Firefox Nightly instead
137
- 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
138
211
  ```
139
212
 
140
213
  Port forwarding between the host and device is handled automatically by geckodriver.
141
214
 
142
215
  ### Connect to existing Firefox
143
216
 
144
- Use `--connect-existing` to automate your real browsing session with cookies, logins, and open tabs intact:
217
+ Use `--connect-existing` to automate your real browsing session, with cookies, logins, and open tabs intact:
145
218
 
146
219
  ```bash
147
- # Start Firefox with Marionette enabled
148
- firefox --marionette
220
+ # Start Firefox with Marionette and the Remote Agent (BiDi)
221
+ firefox --marionette --remote-debugging-port
149
222
 
150
223
  # Run the MCP server
151
224
  npx @mozilla/firefox-devtools-mcp --connect-existing --marionette-port 2828
152
225
  ```
153
226
 
154
- Or set `marionette.enabled` to `true` in `about:config` (or `user.js`) to enable Marionette on every launch.
155
-
156
- BiDi-dependent features (console events, network events) are not available in connect-existing mode; all other features work normally.
227
+ Both flags are required because the MCP uses both WebDriver Classic (`--marionette`) and WebDriver BiDi (`--remote-debugging-port`). If Firefox is only started with `--marionette`, the MCP server fails to connect and asks you to restart Firefox with both flags.
157
228
 
158
229
  > **Warning:** Do not leave Marionette enabled during normal browsing. It sets
159
230
  > `navigator.webdriver = true` and changes other browser fingerprint signals,
@@ -163,30 +234,56 @@ BiDi-dependent features (console events, network events) are not available in co
163
234
 
164
235
  ## Tool overview
165
236
 
166
- - Pages: list/new/navigate/select/close
167
- - Snapshot/UID: take/resolve/clear
237
+ - Pages: list/new/navigate/select/close/get_page_text (get_page_text supports optional `saveTo`)
238
+ - Snapshot/UID: take/resolve/clear (take supports optional `saveTo`)
168
239
  - Input: click/hover/fill/drag/upload/form fill
169
- - Network: list/get (ID‑first, filters, always‑on capture)
170
- - Console: list/clear
240
+ - Network: list/get (ID‑first, filters, always‑on capture; both support optional `saveTo`)
241
+ - Downloads: list_downloads/clear_downloads (always‑on capture), set_download_behavior (allow/deny/default)
242
+ - Console: list/clear (list supports optional `saveTo`)
171
243
  - Screenshot: page/by uid (with optional `saveTo` for CLI environments)
172
- - Script: evaluate_script
244
+ - Script: evaluate_script (optional `sandbox` for an isolated realm; optional `saveTo` for bulky results)
173
245
  - Privileged Context: list/select privileged ("chrome") contexts, evaluate_privileged_script (requires `MOZ_REMOTE_ALLOW_SYSTEM_ACCESS=1`)
174
246
  - WebExtension: install_extension, uninstall_extension, list_extensions (list requires `MOZ_REMOTE_ALLOW_SYSTEM_ACCESS=1`)
175
- - 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`)
176
249
  - Profiler: profiler_is_active, profiler_start (preset or explicit config), profiler_stop (saves profile to downloads directory)
250
+ - Screencast: screencast_start (records the page viewport to a video file in the downloads directory), screencast_stop (requires Firefox 154+)
177
251
  - Utilities: accept/dismiss dialog, history back/forward, set viewport
178
252
 
179
- ### Screenshot optimization for Claude Code
253
+ ### Saving bulky output to disk
180
254
 
181
- When using screenshots in Claude Code CLI, the base64 image data can consume significant context.
182
- Use the `saveTo` parameter to save screenshots to disk instead:
255
+ Large tool output can consume significant context in CLI clients like Claude Code. The
256
+ `screenshot_page`, `screenshot_by_uid`, `take_snapshot`, `list_console_messages`,
257
+ `list_network_requests`, `get_network_request`, `get_page_text`,
258
+ `evaluate_script`, and
259
+ `evaluate_privileged_script` tools accept an optional `saveTo` parameter that writes the
260
+ result to a file instead of returning it inline. `saveTo` takes one of three forms:
261
+
262
+ - a file path (relative to the current working directory, or absolute within `~/.firefox-devtools-mcp`; parent directories are created)
263
+ - an existing directory (a timestamped file is generated inside it)
264
+ - `true` (a timestamped file is generated under `~/.firefox-devtools-mcp/output/`)
265
+
266
+ The response returns the path and byte size. The saved file always holds the full,
267
+ untruncated data: the inline size safeguards (console message caps, network header
268
+ truncation, snapshot line caps) never apply to it.
269
+
270
+ The text-producing tools (everything except the screenshots) also accept `preview`, a number
271
+ of characters of the saved output to echo back inline as a short excerpt. Screenshots have no
272
+ preview.
183
273
 
184
274
  ```
185
- screenshot_page({ saveTo: "/tmp/page.png" })
186
- screenshot_by_uid({ uid: "abc123", saveTo: "/tmp/element.png" })
275
+ screenshot_page({ saveTo: "page.png" })
276
+ take_snapshot({ saveTo: true })
277
+ list_network_requests({ urlContains: "api", saveTo: "network.json" })
278
+ evaluate_script({ function: "() => performance.getEntries()", saveTo: true, preview: 2000 })
187
279
  ```
188
280
 
189
- The file can then be viewed with Claude Code's `Read` tool without impacting context size.
281
+ By default, save paths are restricted: relative paths resolve against the current working
282
+ directory, and absolute paths are only allowed within `~/.firefox-devtools-mcp`. Paths that
283
+ escape these locations are rejected. Start the server with `--unrestricted-save-paths` to
284
+ write to arbitrary locations, including absolute paths outside that directory.
285
+
286
+ Saved files can then be viewed for instance with Claude Code's `Read` tool without impacting context size.
190
287
 
191
288
  ## Local development
192
289
 
@@ -207,7 +304,7 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for more details on local development, te
207
304
 
208
305
  - Firefox not found: pass `--firefox-path "/Applications/Firefox.app/Contents/MacOS/firefox"` (macOS) or the correct path on your OS.
209
306
  - First run is slow: Selenium sets up the BiDi session; subsequent runs are faster.
210
- - 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.
211
308
  - Windows 10: Error during discovery for MCP server 'firefox-devtools': MCP error -32000: Connection closed
212
309
  - **Solution 1** Wrap with `cmd /c` ([details](https://github.com/modelcontextprotocol/servers/issues/1082#issuecomment-2791786310)):
213
310