firefox-devtools-mcp
Firefox DevTools MCP
Model Context Protocol-Server zur Automatisierung von Firefox via WebDriver BiDi (durch Selenium WebDriver). Funktioniert mit Claude Code, Claude Desktop, Cursor, Cline und anderen MCP-Clients.
Repository: https://github.com/mozilla/firefox-devtools-mcp
Hinweis: Dieser MCP-Server erfordert eine lokale Firefox-Browser-Installation und kann nicht auf Cloud-Hosting-Diensten wie glama.ai ausgeführt werden. Verwenden Sie
npx firefox-devtools-mcp@latest, um ihn lokal auszuführen, oder nutzen Sie Docker mit dem bereitgestellten Dockerfile.
Anforderungen
Node.js ≥ 20.19.0
Firefox 100+ installiert (wird automatisch erkannt oder über
--firefox-pathübergeben)
Related MCP server: gecko-mcp
Installation und Verwendung mit Claude Code (npx)
Empfohlen: Verwenden Sie npx, damit Sie immer die neueste veröffentlichte Version von npm ausführen.
Option A — Claude Code CLI
claude mcp add firefox-devtools npx firefox-devtools-mcp@latestÜbergeben Sie Optionen entweder als Argumente oder Umgebungsvariablen. Beispiele:
# Headless + viewport via args
claude mcp add firefox-devtools npx firefox-devtools-mcp@latest -- --headless --viewport 1280x720
# Or via environment variables
claude mcp add firefox-devtools npx firefox-devtools-mcp@latest \
--env START_URL=https://example.com \
--env FIREFOX_HEADLESS=trueOption B — Claude Code-Einstellungen (JSON) bearbeiten
Fügen Sie dies zu Ihrer Claude Code-Konfigurationsdatei hinzu:
macOS:
~/Library/Application Support/Claude/Code/mcp_settings.jsonLinux:
~/.config/claude/code/mcp_settings.jsonWindows:
%APPDATA%\Claude\Code\mcp_settings.json
{
"mcpServers": {
"firefox-devtools": {
"command": "npx",
"args": ["-y", "firefox-devtools-mcp@latest", "--headless", "--viewport", "1280x720"],
"env": {
"START_URL": "about:home"
}
}
}
}Option C — Hilfsskript (lokaler Entwicklungs-Build)
npm run setup
# Choose Claude Code; the script saves JSON to the right pathAusprobieren mit dem MCP Inspector
npx @modelcontextprotocol/inspector npx firefox-devtools-mcp@latest --start-url https://example.com --headlessAnschließend können Sie Tools aufrufen wie:
list_pages,select_page,navigate_pagetake_snapshotund dannclick_by_uid/fill_by_uidlist_network_requests(ständige Erfassung),get_network_requestscreenshot_page,list_console_messages
CLI-Optionen
Sie können Flags oder Umgebungsvariablen übergeben (Namen rechts):
--firefox-path— absoluter Pfad zur Firefox-Binärdatei--headless— Ausführung ohne UI (FIREFOX_HEADLESS=true)--viewport 1280x720— anfängliche Fenstergröße--profile-path— Verwendung eines bestimmten Firefox-Profils--firefox-arg— zusätzliche Firefox-Argumente (wiederholbar)--start-url— öffnet diese URL beim Start (START_URL)--accept-insecure-certs— TLS-Fehler ignorieren (ACCEPT_INSECURE_CERTS=true)--connect-existing— an einen bereits laufenden Firefox anhängen, anstatt einen neuen zu starten (CONNECT_EXISTING=true)--marionette-port— Marionette-Port für den Modus "connect-existing", Standard 2828 (MARIONETTE_PORT)--pref name=value— Firefox-Einstellung beim Start übermoz:firefoxOptionsfestlegen (wiederholbar)--enable-script— aktiviert das Toolevaluate_script, das beliebiges JavaScript im Seitenkontext ausführt (ENABLE_SCRIPT=true)--enable-privileged-context— aktiviert Tools für privilegierte Kontexte: privilegierte Kontexte auflisten/auswählen, privilegierte Skripte ausführen, Firefox-Einstellungen abrufen/festlegen und Erweiterungen auflisten. ErfordertMOZ_REMOTE_ALLOW_SYSTEM_ACCESS=1(ENABLE_PRIVILEGED_CONTEXT=true)
Hinweis zu
--pref: Wenn Firefox in der Automatisierung läuft, wendet er RecommendedPreferences an, die das Browserverhalten für Tests modifizieren. Die Option--prefermöglicht es, diese Standardeinstellungen bei Bedarf zu überschreiben.
Verbindung zu einem bestehenden Firefox
Verwenden Sie --connect-existing, um Ihre echte Browsersitzung zu automatisieren – mit intakten Cookies, Logins und offenen Tabs:
# Start Firefox with Marionette enabled
firefox --marionette
# Run the MCP server
npx firefox-devtools-mcp --connect-existing --marionette-port 2828Oder setzen Sie marionette.enabled in about:config (oder user.js) auf true, um Marionette bei jedem Start zu aktivieren.
BiDi-abhängige Funktionen (Konsolenereignisse, Netzwerkereignisse) sind im Modus "connect-existing" nicht verfügbar; alle anderen Funktionen funktionieren normal.
Warnung: Lassen Sie Marionette nicht während des normalen Surfens aktiviert. Es setzt
navigator.webdriver = trueund ändert andere Browser-Fingerabdruck-Signale, was bei Websites, die durch Cloudflare, Akamai usw. geschützt sind, eine Bot-Erkennung auslösen kann. Aktivieren Sie Marionette nur, wenn Sie MCP-Automatisierung benötigen, und starten Sie Firefox danach normal neu.
Tool-Übersicht
Seiten: auflisten/neu/navigieren/auswählen/schließen
Snapshot/UID: erstellen/auflösen/löschen
Eingabe: klicken/hovern/ausfüllen/ziehen/hochladen/Formular ausfüllen
Netzwerk: auflisten/abrufen (ID-basiert, Filter, ständige Erfassung)
Konsole: auflisten/löschen
Screenshot: Seite/nach UID (mit optionalem
saveTofür CLI-Umgebungen)Skript: evaluate_script
Privilegierter Kontext: privilegierte ("chrome") Kontexte auflisten/auswählen, evaluate_privileged_script (erfordert
MOZ_REMOTE_ALLOW_SYSTEM_ACCESS=1)WebExtension: install_extension, uninstall_extension, list_extensions (auflisten erfordert
MOZ_REMOTE_ALLOW_SYSTEM_ACCESS=1)Firefox-Verwaltung: get_firefox_info, get_firefox_output, restart_firefox, set_firefox_prefs, get_firefox_prefs
Dienstprogramme: Dialog akzeptieren/verwerfen, Verlauf zurück/vor, Viewport festlegen
Screenshot-Optimierung für Claude Code
Bei der Verwendung von Screenshots in der Claude Code CLI können die Base64-Bilddaten erheblichen Kontext verbrauchen. Verwenden Sie stattdessen den Parameter saveTo, um Screenshots auf der Festplatte zu speichern:
screenshot_page({ saveTo: "/tmp/page.png" })
screenshot_by_uid({ uid: "abc123", saveTo: "/tmp/element.png" })Die Datei kann dann mit dem Read-Tool von Claude Code betrachtet werden, ohne die Kontextgröße zu beeinträchtigen.
Lokale Entwicklung
npm install
npm run build
# Run with Inspector against local build
npx @modelcontextprotocol/inspector node dist/index.js --headless --viewport 1280x720
# Or run in dev with hot reload
npm run inspector:devTesten
npm run test:run # all tests once (unit + integration)
npm test # watch modeSiehe docs/testing.md für vollständige Details zum Ausführen spezifischer Testsuiten, der E2E-Szenarioabdeckung und bekannter Probleme.
Fehlerbehebung
Firefox nicht gefunden: Übergeben Sie
--firefox-path "/Applications/Firefox.app/Contents/MacOS/firefox"(macOS) oder den korrekten Pfad auf Ihrem Betriebssystem.Erster Start ist langsam: Selenium richtet die BiDi-Sitzung ein; nachfolgende Starts sind schneller.
Veraltete UIDs nach Navigation: Erstellen Sie einen neuen Snapshot (
take_snapshot), bevor Sie UID-Tools verwenden.Windows 10: Fehler bei der Erkennung für MCP-Server 'firefox-devtools': MCP error -32000: Connection closed
Lösung 1 Mit
cmd /cumschließen (Details):"mcpServers": { "firefox-devtools": { "command": "cmd", "args": ["/c", "npx", "-y", "firefox-devtools-mcp@latest"] } }Lösung 2 Verwenden Sie den absoluten Pfad zu
npx(passen Sie die Erweiterung –.cmd,.bat,.exeoder.ps1– an Ihr Setup an):"mcpServers": { "firefox-devtools": { "command": "C:\\nvm4w\\nodejs\\npx.ps1", "args": ["-y", "firefox-devtools-mcp@latest"] } }
Versionierung
Pre-1.0 API: Versionen beginnen bei
0.x. Verwenden Sie@latestmit npx für die neueste Version.
CI und Release
GitHub Actions für CI, Release und npm-Veröffentlichung sind enthalten. Siehe docs/ci-and-release.md für Details und erforderliche Secrets.
Probleme und Mitwirkung
Probleme werden auf Bugzilla unter product: Developer Infrastructure, component: AI for Development verfolgt.
Für Fragen und Diskussionen treten Sie dem #firefox-devtools-mcp Matrix-Raum bei.
Autor
Gewartet von Mozilla.
Available Tools
36 toolsaccept_dialogA
Accept browser dialog. Provide promptText for prompts.
Inputs: promptText.
clear_downloadsA
Clear the tracked downloads buffer.
Inputs: no named parameters.
clear_snapshotC
Clear snapshot UIDs. Usually not needed.
Inputs: no named parameters.
click_by_uidA
Click element by UID. Set dblClick for double-click.
Inputs: uid (required), dblClick.
close_firefox_sessionA
Ends the browser session. If the server connected to your existing Firefox, this releases the connection and leaves Firefox running. If the server started Firefox itself, this closes it. Call this when the browser task is complete and no further browser interaction is expected.
Inputs: no named parameters.
close_pageA
Close tab by index.
Inputs: pageIdx (required).
dismiss_dialogA
Dismiss browser dialog.
Inputs: no named parameters.
drag_by_uid_to_uidB
Drag element to another (HTML5 drag events).
Inputs: toUid (required), fromUid (required).
evaluate_scriptA
Run a JS function in the page and return its result. Prefer this for targeted reads (a value, text, computed style, whether an element exists) instead of a full take_snapshot. Use the UID interaction tools for clicking, typing, and filling.
Inputs: function (required), args, saveTo, preview, +2 more.
fill_by_uidA
Fill text input/textarea or pick a select option by UID.
Inputs: uid (required), value (required).
fill_form_by_uidA
Fill multiple form fields at once.
Inputs: elements (required).
get_firefox_infoARead-only
Get information about the current Firefox instance configuration, including binary path, environment variables, and output file location.
Inputs: no named parameters.
get_firefox_outputARead-only
Retrieve Firefox output (stdout/stderr including MOZ_LOG, warnings, crashes, stack traces). Returns recent output from the capture file. Use filters to focus on specific content.
Inputs: grep, lines, since.
get_page_textARead-only
Get the visible text of the page (document.body.innerText). Caps at maxLength (default 20000 chars); saveTo saves the full text to a file.
Inputs: saveTo, preview, maxLength.
hover_by_uidB
Hover over element by UID.
Inputs: uid (required).
install_extensionA
Install a Firefox extension using WebDriver BiDi webExtension.install command. Supports installing from archive (.xpi/.zip), base64-encoded data, or unpacked directory.
Inputs: type (required), path, value, permanent.
list_downloadsARead-only
List downloads tracked since startup, including status and saved file path.
Inputs: limit, format, status, urlContains.
list_extensionsBRead-only
List installed Firefox extensions using the WebDriver BiDi webExtension.moz:listExtensions command.
Inputs: ids, name, isActive.
list_pagesARead-only
List open tabs (index, title, URL). Selected tab is marked.
Inputs: no named parameters.
new_pageB
Open new tab at URL. Returns tab index.
Inputs: url (required), wait.
press_keyA
Press a single key, optionally with modifiers, to submit, dismiss, navigate or trigger a shortcut. Not for entering text: use fill_by_uid instead.
Inputs: key (required), uid.
print_pageARead-only
Print the current page to a PDF file using print CSS. Returns the saved file path.
Inputs: saveTo, landscape, background.
resolve_uid_to_selectorARead-only
Resolve UID to CSS selector. Fails if the element is gone.
Inputs: uid (required).
screencast_startA
Start recording a screencast (video) of the current page viewport, saving the output to a file in the downloads directory. Returns a screencast id to pass to screencast_stop. Multiple recordings can run at once.
Inputs: width, height, context, mimeType, +1 more.
screencast_stopA
Stop an in-progress screencast recording started with screencast_start and finalize the video file. Returns the path to the saved file.
Inputs: screencast.
screenshot_by_uidBRead-only
Capture element screenshot by UID as base64 PNG.
Inputs: uid (required), saveTo.
screenshot_pageBRead-only
Capture viewport screenshot as base64 PNG. Set fullPage for the whole scrollable document.
Inputs: saveTo, fullPage.
select_pageA
Select active tab by index, URL, or title. Index takes precedence.
Inputs: url, title, pageIdx.
set_download_behaviorA
Control how downloads are handled: allow (save to a destination folder), deny (cancel), or reset to default. Avoids the native save-file dialog. Requires a recent Firefox.
Inputs: behavior (required), downloadFolder.
set_viewport_sizeA
Set viewport dimensions in pixels. Applies to the selected tab only.
Inputs: width (required), height (required).
take_snapshotARead-only
Capture DOM snapshot with stable UIDs. A UID stays valid across snapshots until its element is removed or the page navigates. Output caps at maxLines (default 100); scope with selector or dump the full tree with saveTo.
Inputs: saveTo, preview, maxDepth, maxLines, +4 more.
type_textA
Type text key by key into the focused element, optionally followed by a key such as Enter. Use fill_by_uid to set the value of a known input; use this for elements that only react to real typing, such as autocomplete fields and rich text editors.
Inputs: text (required), uid, submitKey.
uninstall_extensionA
Uninstall a Firefox extension using WebDriver BiDi webExtension.uninstall command. Requires the extension ID returned by install_extension or obtained from list_extensions.
Inputs: id (required).
upload_file_by_uidB
Upload file to file input by UID.
Inputs: uid (required), filePath (required).
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 36 tools
Most tools target a distinct resource+action, and the descriptions actively steer between near-neighbors (fill_by_uid vs type_text vs press_key, screenshot_page vs screenshot_by_uid, take_snapshot vs get_page_text vs evaluate_script). The only real overlaps are the fill family (fill_by_uid, fill_form_by_uid, type_text) and the three 'read the page' tools, but each carries explicit guidance on when to use it.
The majority follow verb_noun (click_by_uid, list_pages, take_snapshot, install_extension), but there are deviations: noun-first forms like screencast_start/screencast_stop (vs the otherwise dominant verb_noun, cf. navigate_history), set_download_behavior/set_viewport_size, and noun-as-verb names like screenshot_by_uid, screenshot_page, drag_by_uid_to_uid. Still readable and predictable in spirit, but not a single consistent convention.
36 tools is heavy for a browser automation surface; most earn their place, but there is clear consolidation headroom (clear_snapshot, resolve_uid_to_selector, clear_downloads, get_firefox_info are marginal, and the fill/type/screenshot variants could be merged). The count pushes well past the 15-tool comfort zone into territory where selection cost is real.
Core lifecycle is well covered: tabs, navigation, history, viewport, UID-based interaction, forms, uploads, dialogs, downloads, extensions, screenshots, PDF printing, screencast, and session teardown. Notable devtools gaps remain: no console message retrieval distinct from raw Firefox stdout/stderr, no network request inspection/interception, no explicit wait-for-element/condition, and no frame/iframe or cookie/storage management.
Maintenance
Related MCP Connectors
Official Browserless MCP server: browser automation, scraping, screenshots and PDFs for AI agents.
Cloud browser, web extraction, screenshots, and remote CDP tools for AI agents.
Unofficial Browserless MCP — wraps the Browserless headless-Chromium REST API (browserless.io)
Automate cloud Chrome—navigate, click, type, screenshot, run code, record screen video
Related MCP Servers
- AlicenseCqualityDmaintenanceProvides Firefox browser automation capabilities through Playwright, allowing control of Firefox from MCP-enabled applications with features for basic automation and advanced multi-tab debugging.2930MIT
- AlicenseAqualityCmaintenanceDrive Firefox-based browsers (Floorp, LibreWolf, Zen, Waterfox, Mullvad, Firefox) from any MCP client — read pages, screenshot, click, fill forms and manage tabs in your real session, over Marionette/WebDriver. OS input & JS eval locked by default.4163 npm2MIT
- FlicenseAqualityDmaintenanceModel Context Protocol server for automating Firefox via WebDriver BiDi, enabling page navigation, snapshots, input, network monitoring, and console debugging for AI agents in MCP clients.31-
- AlicenseBqualityBmaintenanceEnables AI agents to drive a user-launched Firefox instance via its native Marionette protocol, providing precise DOM actuation like clicking, typing, uploading files, taking screenshots, and evaluating JavaScript.1811 npm1GPL 2.0