@mozilla/firefox-devtools-mcp-moz 0.9.3
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 +219 -0
- package/dist.moz/index.js +33246 -0
- package/dist.moz/snapshot.injected.global.js +1 -0
- package/package.json +79 -0
- package/plugins/claude/firefox-devtools/.claude-plugin/plugin.json +11 -0
- package/plugins/claude/firefox-devtools/.mcp.json +8 -0
- package/plugins/claude/firefox-devtools/README.md +82 -0
- package/plugins/claude/firefox-devtools/agents/e2e-tester.md +36 -0
- package/plugins/claude/firefox-devtools/agents/web-scraper.md +35 -0
- package/plugins/claude/firefox-devtools/commands/debug.md +32 -0
- package/plugins/claude/firefox-devtools/commands/navigate.md +31 -0
- package/plugins/claude/firefox-devtools/commands/screenshot.md +30 -0
- package/plugins/claude/firefox-devtools/skills/browser-automation/SKILL.md +65 -0
- package/scripts/_helpers/page-loader.js +121 -0
- package/scripts/demo-server.js +325 -0
- package/scripts/generate-moz-package.mjs +35 -0
- package/scripts/publish-moz-package.mjs +52 -0
- package/scripts/run-integration-tests-windows.mjs +188 -0
- package/scripts/setup-mcp-config.js +260 -0
- package/scripts/test-bidi-devtools.js +380 -0
- package/scripts/test-console.js +148 -0
- package/scripts/test-dialog.js +102 -0
- package/scripts/test-firefox-temp.js +21 -0
- package/scripts/test-input-tools.js +233 -0
- package/scripts/test-lifecycle-hooks.js +125 -0
- package/scripts/test-mozlog.js +112 -0
- package/scripts/test-navigation.js +57 -0
- package/scripts/test-privileged-context.js +99 -0
- package/scripts/test-screenshot.js +190 -0
package/README.md
ADDED
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
# Firefox DevTools MCP
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/firefox-devtools-mcp)
|
|
4
|
+
[](https://github.com/mozilla/firefox-devtools-mcp/actions/workflows/ci.yml)
|
|
5
|
+
[](https://codecov.io/gh/mozilla/firefox-devtools-mcp)
|
|
6
|
+
[](LICENSE-MIT) [](LICENSE-APACHE)
|
|
7
|
+
|
|
8
|
+
<a href="https://glama.ai/mcp/servers/@mozilla/firefox-devtools-mcp"><img src="https://glama.ai/mcp/servers/@mozilla/firefox-devtools-mcp/badge" height="223" alt="Glama"></a>
|
|
9
|
+
|
|
10
|
+
Model Context Protocol server for automating Firefox via WebDriver BiDi (through Selenium WebDriver). Works with Claude Code, Claude Desktop, Cursor, Cline and other MCP clients.
|
|
11
|
+
|
|
12
|
+
Repository: https://github.com/mozilla/firefox-devtools-mcp
|
|
13
|
+
|
|
14
|
+
> **Note**: This MCP server requires a local Firefox browser installation and cannot run on cloud hosting services like glama.ai. Use `npx firefox-devtools-mcp@latest` to run locally, or use Docker with the provided Dockerfile.
|
|
15
|
+
|
|
16
|
+
## Security
|
|
17
|
+
|
|
18
|
+
Browser MCP servers carry inherent risks. A few key practices:
|
|
19
|
+
|
|
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
|
+
- **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.
|
|
23
|
+
|
|
24
|
+
See [SECURITY.md](SECURITY.md) for a full breakdown of risks and how to report vulnerabilities.
|
|
25
|
+
|
|
26
|
+
## Requirements
|
|
27
|
+
|
|
28
|
+
- Node.js ≥ 20.19.0
|
|
29
|
+
- Firefox 100+ installed (auto‑detected, or pass `--firefox-path`)
|
|
30
|
+
|
|
31
|
+
## Install and use with Claude Code (npx)
|
|
32
|
+
|
|
33
|
+
Recommended: use npx so you always run the latest published version from npm.
|
|
34
|
+
|
|
35
|
+
Option A — Claude Code CLI
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
claude mcp add firefox-devtools npx firefox-devtools-mcp@latest
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Pass options either as args or env vars. Examples:
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
# Headless + viewport via args
|
|
45
|
+
claude mcp add firefox-devtools npx firefox-devtools-mcp@latest -- --headless --viewport 1280x720
|
|
46
|
+
|
|
47
|
+
# Or via environment variables
|
|
48
|
+
claude mcp add firefox-devtools npx firefox-devtools-mcp@latest \
|
|
49
|
+
--env START_URL=https://example.com \
|
|
50
|
+
--env FIREFOX_HEADLESS=true
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Option B — Edit Claude Code settings JSON
|
|
54
|
+
|
|
55
|
+
Add to your Claude Code config file:
|
|
56
|
+
|
|
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`
|
|
60
|
+
|
|
61
|
+
```json
|
|
62
|
+
{
|
|
63
|
+
"mcpServers": {
|
|
64
|
+
"firefox-devtools": {
|
|
65
|
+
"command": "npx",
|
|
66
|
+
"args": ["-y", "firefox-devtools-mcp@latest", "--headless", "--viewport", "1280x720"],
|
|
67
|
+
"env": {
|
|
68
|
+
"START_URL": "about:home"
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
Option C — Helper script (local dev build)
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
npm run setup
|
|
79
|
+
# Choose Claude Code; the script saves JSON to the right path
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## Try it with MCP Inspector
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
npx @modelcontextprotocol/inspector npx firefox-devtools-mcp@latest --start-url https://example.com --headless
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
Then call tools like:
|
|
89
|
+
|
|
90
|
+
- `list_pages`, `select_page`, `navigate_page`
|
|
91
|
+
- `take_snapshot` then `click_by_uid` / `fill_by_uid`
|
|
92
|
+
- `list_network_requests` (always‑on capture), `get_network_request`
|
|
93
|
+
- `screenshot_page`, `list_console_messages`
|
|
94
|
+
|
|
95
|
+
## CLI options
|
|
96
|
+
|
|
97
|
+
You can pass flags or environment variables (names on the right):
|
|
98
|
+
|
|
99
|
+
- `--firefox-path` — absolute path to Firefox binary
|
|
100
|
+
- `--headless` — run without UI (`FIREFOX_HEADLESS=true`)
|
|
101
|
+
- `--viewport 1280x720` — initial window size
|
|
102
|
+
- `--profile-path` — use a specific Firefox profile
|
|
103
|
+
- `--firefox-arg` — extra Firefox arguments (repeatable)
|
|
104
|
+
- `--start-url` — open this URL on start (`START_URL`)
|
|
105
|
+
- `--accept-insecure-certs` — ignore TLS errors (`ACCEPT_INSECURE_CERTS=true`)
|
|
106
|
+
- `--connect-existing` — attach to an already-running Firefox instead of launching a new one (`CONNECT_EXISTING=true`)
|
|
107
|
+
- `--marionette-port` — Marionette port for connect-existing mode, default 2828 (`MARIONETTE_PORT`)
|
|
108
|
+
- `--pref name=value` — set Firefox preference at startup via `moz:firefoxOptions` (repeatable)
|
|
109
|
+
- `--enable-script` — enable the `evaluate_script` tool, which executes arbitrary JavaScript in the page context (`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`)
|
|
111
|
+
|
|
112
|
+
> **Note on `--pref`:** 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. The `--pref` option allows overriding these defaults when needed.
|
|
113
|
+
|
|
114
|
+
### Connect to existing Firefox
|
|
115
|
+
|
|
116
|
+
Use `--connect-existing` to automate your real browsing session — with cookies, logins, and open tabs intact:
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
# Start Firefox with Marionette enabled
|
|
120
|
+
firefox --marionette
|
|
121
|
+
|
|
122
|
+
# Run the MCP server
|
|
123
|
+
npx firefox-devtools-mcp --connect-existing --marionette-port 2828
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
Or set `marionette.enabled` to `true` in `about:config` (or `user.js`) to enable Marionette on every launch.
|
|
127
|
+
|
|
128
|
+
BiDi-dependent features (console events, network events) are not available in connect-existing mode; all other features work normally.
|
|
129
|
+
|
|
130
|
+
> **Warning:** Do not leave Marionette enabled during normal browsing. It sets
|
|
131
|
+
> `navigator.webdriver = true` and changes other browser fingerprint signals,
|
|
132
|
+
> which can trigger bot detection on sites protected by Cloudflare, Akamai, etc.
|
|
133
|
+
> Only enable Marionette when you need MCP automation, then restart Firefox
|
|
134
|
+
> normally afterward.
|
|
135
|
+
|
|
136
|
+
## Tool overview
|
|
137
|
+
|
|
138
|
+
- Pages: list/new/navigate/select/close
|
|
139
|
+
- Snapshot/UID: take/resolve/clear
|
|
140
|
+
- Input: click/hover/fill/drag/upload/form fill
|
|
141
|
+
- Network: list/get (ID‑first, filters, always‑on capture)
|
|
142
|
+
- Console: list/clear
|
|
143
|
+
- Screenshot: page/by uid (with optional `saveTo` for CLI environments)
|
|
144
|
+
- Script: evaluate_script
|
|
145
|
+
- Privileged Context: list/select privileged ("chrome") contexts, evaluate_privileged_script (requires `MOZ_REMOTE_ALLOW_SYSTEM_ACCESS=1`)
|
|
146
|
+
- WebExtension: install_extension, uninstall_extension, list_extensions (list requires `MOZ_REMOTE_ALLOW_SYSTEM_ACCESS=1`)
|
|
147
|
+
- Firefox Management: get_firefox_info, get_firefox_output, restart_firefox, set_firefox_prefs, get_firefox_prefs
|
|
148
|
+
- Utilities: accept/dismiss dialog, history back/forward, set viewport
|
|
149
|
+
|
|
150
|
+
### Screenshot optimization for Claude Code
|
|
151
|
+
|
|
152
|
+
When using screenshots in Claude Code CLI, the base64 image data can consume significant context.
|
|
153
|
+
Use the `saveTo` parameter to save screenshots to disk instead:
|
|
154
|
+
|
|
155
|
+
```
|
|
156
|
+
screenshot_page({ saveTo: "/tmp/page.png" })
|
|
157
|
+
screenshot_by_uid({ uid: "abc123", saveTo: "/tmp/element.png" })
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
The file can then be viewed with Claude Code's `Read` tool without impacting context size.
|
|
161
|
+
|
|
162
|
+
## Local development
|
|
163
|
+
|
|
164
|
+
```bash
|
|
165
|
+
npm install
|
|
166
|
+
npm run build
|
|
167
|
+
|
|
168
|
+
# Run with Inspector against local build
|
|
169
|
+
npx @modelcontextprotocol/inspector node dist/index.js --headless --viewport 1280x720
|
|
170
|
+
|
|
171
|
+
# Or run in dev with hot reload
|
|
172
|
+
npm run inspector:dev
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md) for more details on local development, testing, and CI.
|
|
176
|
+
|
|
177
|
+
## Troubleshooting
|
|
178
|
+
|
|
179
|
+
- Firefox not found: pass `--firefox-path "/Applications/Firefox.app/Contents/MacOS/firefox"` (macOS) or the correct path on your OS.
|
|
180
|
+
- First run is slow: Selenium sets up the BiDi session; subsequent runs are faster.
|
|
181
|
+
- Stale UIDs after navigation: take a fresh snapshot (`take_snapshot`) before using UID tools.
|
|
182
|
+
- Windows 10: Error during discovery for MCP server 'firefox-devtools': MCP error -32000: Connection closed
|
|
183
|
+
- **Solution 1** Wrap with `cmd /c` ([details](https://github.com/modelcontextprotocol/servers/issues/1082#issuecomment-2791786310)):
|
|
184
|
+
|
|
185
|
+
```json
|
|
186
|
+
"mcpServers": {
|
|
187
|
+
"firefox-devtools": {
|
|
188
|
+
"command": "cmd",
|
|
189
|
+
"args": ["/c", "npx", "-y", "firefox-devtools-mcp@latest"]
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
- **Solution 2** Use the absolute path to `npx` (adjust extension — `.cmd`, `.bat`, `.exe`, or `.ps1` — to match your setup):
|
|
195
|
+
|
|
196
|
+
```json
|
|
197
|
+
"mcpServers": {
|
|
198
|
+
"firefox-devtools": {
|
|
199
|
+
"command": "C:\\nvm4w\\nodejs\\npx.ps1",
|
|
200
|
+
"args": ["-y", "firefox-devtools-mcp@latest"]
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
## Versioning
|
|
206
|
+
|
|
207
|
+
- Pre‑1.0 API: versions start at `0.x`. Use `@latest` with npx for the newest release.
|
|
208
|
+
|
|
209
|
+
## Contributing
|
|
210
|
+
|
|
211
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md) for how to file issues, run tests, and work on the project locally.
|
|
212
|
+
|
|
213
|
+
## Author
|
|
214
|
+
|
|
215
|
+
Maintained by [Mozilla](https://www.mozilla.org).
|
|
216
|
+
|
|
217
|
+
## License
|
|
218
|
+
|
|
219
|
+
Licensed under either of [MIT](LICENSE-MIT) or [Apache 2.0](LICENSE-APACHE) at your option.
|