firefox-devtools-mcp
Firefox DevTools MCP
Servidor del Protocolo de Contexto de Modelo (MCP) para automatizar Firefox mediante WebDriver BiDi (a través de Selenium WebDriver). Funciona con Claude Code, Claude Desktop, Cursor, Cline y otros clientes MCP.
Repositorio: https://github.com/mozilla/firefox-devtools-mcp
Nota: Este servidor MCP requiere una instalación local del navegador Firefox y no puede ejecutarse en servicios de alojamiento en la nube como glama.ai. Utilice
npx firefox-devtools-mcp@latestpara ejecutarlo localmente, o utilice Docker con el Dockerfile proporcionado.
Requisitos
Node.js ≥ 20.19.0
Firefox 100+ instalado (detectado automáticamente, o pase
--firefox-path)
Related MCP server: gecko-mcp
Instalación y uso con Claude Code (npx)
Recomendado: use npx para ejecutar siempre la última versión publicada desde npm.
Opción A — CLI de Claude Code
claude mcp add firefox-devtools npx firefox-devtools-mcp@latestPase las opciones como argumentos o variables de entorno. Ejemplos:
# 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=trueOpción B — Editar el JSON de configuración de Claude Code
Agréguelo a su archivo de configuración de Claude Code:
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"
}
}
}
}Opción C — Script auxiliar (compilación de desarrollo local)
npm run setup
# Choose Claude Code; the script saves JSON to the right pathPruébelo con MCP Inspector
npx @modelcontextprotocol/inspector npx firefox-devtools-mcp@latest --start-url https://example.com --headlessLuego llame a herramientas como:
list_pages,select_page,navigate_pagetake_snapshoty luegoclick_by_uid/fill_by_uidlist_network_requests(captura siempre activa),get_network_requestscreenshot_page,list_console_messages
Opciones de CLI
Puede pasar indicadores o variables de entorno (nombres a la derecha):
--firefox-path— ruta absoluta al binario de Firefox--headless— ejecutar sin interfaz de usuario (FIREFOX_HEADLESS=true)--viewport 1280x720— tamaño inicial de la ventana--profile-path— usar un perfil de Firefox específico--firefox-arg— argumentos adicionales de Firefox (repetible)--start-url— abrir esta URL al iniciar (START_URL)--accept-insecure-certs— ignorar errores TLS (ACCEPT_INSECURE_CERTS=true)--connect-existing— conectarse a un Firefox ya en ejecución en lugar de iniciar uno nuevo (CONNECT_EXISTING=true)--marionette-port— puerto de Marionette para el modo de conexión existente, predeterminado 2828 (MARIONETTE_PORT)--pref name=value— establecer la preferencia de Firefox al inicio mediantemoz:firefoxOptions(repetible)--enable-script— habilitar la herramientaevaluate_script, que ejecuta JavaScript arbitrario en el contexto de la página (ENABLE_SCRIPT=true)--enable-privileged-context— habilitar herramientas de contexto privilegiado: listar/seleccionar contextos privilegiados, evaluar scripts privilegiados, obtener/establecer preferencias de Firefox y listar extensiones. RequiereMOZ_REMOTE_ALLOW_SYSTEM_ACCESS=1(ENABLE_PRIVILEGED_CONTEXT=true)
Nota sobre
--pref: Cuando Firefox se ejecuta en automatización, aplica RecommendedPreferences que modifican el comportamiento del navegador para las pruebas. La opción--prefpermite anular estos valores predeterminados cuando sea necesario.
Conectarse a un Firefox existente
Use --connect-existing para automatizar su sesión de navegación real, con cookies, inicios de sesión y pestañas abiertas intactas:
# Start Firefox with Marionette enabled
firefox --marionette
# Run the MCP server
npx firefox-devtools-mcp --connect-existing --marionette-port 2828O establezca marionette.enabled en true en about:config (o user.js) para habilitar Marionette en cada inicio.
Las funciones que dependen de BiDi (eventos de consola, eventos de red) no están disponibles en el modo de conexión existente; todas las demás funciones funcionan normalmente.
Advertencia: No deje Marionette habilitado durante la navegación normal. Establece
navigator.webdriver = truey cambia otras señales de huella digital del navegador, lo que puede activar la detección de bots en sitios protegidos por Cloudflare, Akamai, etc. Solo habilite Marionette cuando necesite la automatización de MCP, luego reinicie Firefox normalmente después.
Descripción general de las herramientas
Páginas: listar/nueva/navegar/seleccionar/cerrar
Instantánea/UID: tomar/resolver/borrar
Entrada: hacer clic/pasar el ratón/rellenar/arrastrar/subir/rellenar formulario
Red: listar/obtener (ID primero, filtros, captura siempre activa)
Consola: listar/borrar
Captura de pantalla: página/por uid (con
saveToopcional para entornos CLI)Script: evaluate_script
Contexto privilegiado: listar/seleccionar contextos privilegiados ("chrome"), evaluate_privileged_script (requiere
MOZ_REMOTE_ALLOW_SYSTEM_ACCESS=1)WebExtension: install_extension, uninstall_extension, list_extensions (listar requiere
MOZ_REMOTE_ALLOW_SYSTEM_ACCESS=1)Gestión de Firefox: get_firefox_info, get_firefox_output, restart_firefox, set_firefox_prefs, get_firefox_prefs
Utilidades: aceptar/descartar diálogo, historial atrás/adelante, establecer viewport
Optimización de capturas de pantalla para Claude Code
Al usar capturas de pantalla en la CLI de Claude Code, los datos de imagen en base64 pueden consumir un contexto significativo.
Use el parámetro saveTo para guardar las capturas de pantalla en el disco en su lugar:
screenshot_page({ saveTo: "/tmp/page.png" })
screenshot_by_uid({ uid: "abc123", saveTo: "/tmp/element.png" })El archivo se puede ver con la herramienta Read de Claude Code sin afectar el tamaño del contexto.
Desarrollo local
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:devPruebas
npm run test:run # all tests once (unit + integration)
npm test # watch modeConsulte docs/testing.md para obtener detalles completos sobre la ejecución de conjuntos de pruebas específicos, la cobertura de escenarios e2e y los problemas conocidos.
Solución de problemas
Firefox no encontrado: pase
--firefox-path "/Applications/Firefox.app/Contents/MacOS/firefox"(macOS) o la ruta correcta en su sistema operativo.La primera ejecución es lenta: Selenium configura la sesión BiDi; las ejecuciones posteriores son más rápidas.
UIDs obsoletos después de la navegación: tome una instantánea nueva (
take_snapshot) antes de usar las herramientas de UID.Windows 10: Error durante el descubrimiento del servidor MCP 'firefox-devtools': Error MCP -32000: Conexión cerrada
Solución 1 Envuelva con
cmd /c(detalles):"mcpServers": { "firefox-devtools": { "command": "cmd", "args": ["/c", "npx", "-y", "firefox-devtools-mcp@latest"] } }Solución 2 Use la ruta absoluta a
npx(ajuste la extensión —.cmd,.bat,.exeo.ps1— para que coincida con su configuración):"mcpServers": { "firefox-devtools": { "command": "C:\\nvm4w\\nodejs\\npx.ps1", "args": ["-y", "firefox-devtools-mcp@latest"] } }
Versionado
API anterior a 1.0: las versiones comienzan en
0.x. Use@latestcon npx para la versión más reciente.
CI y lanzamiento
Se incluyen GitHub Actions para CI, lanzamiento y publicación en npm. Consulte docs/ci-and-release.md para obtener detalles y los secretos requeridos.
Problemas y contribuciones
Los problemas se rastrean en Bugzilla bajo product: Developer Infrastructure, component: AI for Development.
Para preguntas y debates, únase a la sala de Matrix #firefox-devtools-mcp.
Autor
Mantenido por 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