firefox-devtools-mcp
Firefox DevTools MCP
WebDriver BiDi(Selenium WebDriver 経由)を使用して Firefox を自動化するための Model Context Protocol サーバーです。Claude Code、Claude Desktop、Cursor、Cline などの MCP クライアントで動作します。
リポジトリ: https://github.com/mozilla/firefox-devtools-mcp
注: この MCP サーバーはローカルの Firefox ブラウザのインストールを必要とし、glama.ai のようなクラウドホスティングサービス上では実行できません。ローカルで実行するには
npx firefox-devtools-mcp@latestを使用するか、提供されている Dockerfile を使用して Docker を利用してください。
要件
Node.js ≥ 20.19.0
Firefox 100 以上がインストールされていること(自動検出されます。または
--firefox-pathを渡してください)
Related MCP server: gecko-mcp
Claude Code でのインストールと使用 (npx)
npm から公開されている最新バージョンを常に実行できるように、npx の使用を推奨します。
オプション A — Claude Code CLI
claude mcp add firefox-devtools npx firefox-devtools-mcp@latestオプションは引数または環境変数として渡します。例:
# 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=trueオプション B — Claude Code 設定 JSON の編集
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"
}
}
}
}オプション C — ヘルパースクリプト (ローカル開発ビルド)
npm run setup
# Choose Claude Code; the script saves JSON to the right pathMCP Inspector で試す
npx @modelcontextprotocol/inspector npx firefox-devtools-mcp@latest --start-url https://example.com --headlessその後、以下のようなツールを呼び出します:
list_pages,select_page,navigate_pagetake_snapshotを実行してからclick_by_uid/fill_by_uidlist_network_requests(常時キャプチャ),get_network_requestscreenshot_page,list_console_messages
CLI オプション
フラグまたは環境変数(右側に記載)を渡すことができます:
--firefox-path— Firefox バイナリへの絶対パス--headless— UI なしで実行 (FIREFOX_HEADLESS=true)--viewport 1280x720— 初期ウィンドウサイズ--profile-path— 特定の Firefox プロファイルを使用--firefox-arg— 追加の Firefox 引数(繰り返し可能)--start-url— 開始時にこの URL を開く (START_URL)--accept-insecure-certs— TLS エラーを無視 (ACCEPT_INSECURE_CERTS=true)--connect-existing— 新しく起動する代わりに、既に実行中の Firefox に接続 (CONNECT_EXISTING=true)--marionette-port— 既存接続モード用の Marionette ポート、デフォルト 2828 (MARIONETTE_PORT)--pref name=value—moz:firefoxOptionsを介して起動時に Firefox 設定を設定(繰り返し可能)--enable-script— ページコンテキストで任意の JavaScript を実行するevaluate_scriptツールを有効化 (ENABLE_SCRIPT=true)--enable-privileged-context— 特権コンテキストツールを有効化: 特権コンテキストのリスト/選択、特権スクリプトの評価、Firefox 設定の取得/設定、拡張機能のリスト。MOZ_REMOTE_ALLOW_SYSTEM_ACCESS=1が必要 (ENABLE_PRIVILEGED_CONTEXT=true)
--prefに関する注意: Firefox が自動化で実行される際、テスト用にブラウザの動作を変更する RecommendedPreferences が適用されます。--prefオプションを使用すると、必要に応じてこれらのデフォルトを上書きできます。
既存の Firefox への接続
--connect-existing を使用して、Cookie、ログイン情報、開いているタブを維持したまま、実際のブラウジングセッションを自動化します:
# Start Firefox with Marionette enabled
firefox --marionette
# Run the MCP server
npx firefox-devtools-mcp --connect-existing --marionette-port 2828または、起動のたびに Marionette を有効にするには、about:config (または user.js) で marionette.enabled を true に設定してください。
BiDi 依存機能(コンソールイベント、ネットワークイベント)は既存接続モードでは利用できません。その他の機能はすべて通常通り動作します。
警告: 通常のブラウジング中に Marionette を有効にしたままにしないでください。
navigator.webdriver = trueが設定され、他のブラウザフィンガープリント信号が変更されるため、Cloudflare や Akamai などで保護されたサイトでボット検出がトリガーされる可能性があります。MCP 自動化が必要なときのみ Marionette を有効にし、その後 Firefox を通常通り再起動してください。
ツール概要
ページ: list/new/navigate/select/close
スナップショット/UID: take/resolve/clear
入力: click/hover/fill/drag/upload/form fill
ネットワーク: list/get (ID 優先、フィルタ、常時キャプチャ)
コンソール: list/clear
スクリーンショット: page/by uid (CLI 環境用にオプションで
saveToを指定可能)スクリプト: evaluate_script
特権コンテキスト: 特権("chrome")コンテキストのリスト/選択、evaluate_privileged_script (
MOZ_REMOTE_ALLOW_SYSTEM_ACCESS=1が必要)WebExtension: install_extension, uninstall_extension, list_extensions (リストには
MOZ_REMOTE_ALLOW_SYSTEM_ACCESS=1が必要)Firefox 管理: get_firefox_info, get_firefox_output, restart_firefox, set_firefox_prefs, get_firefox_prefs
ユーティリティ: ダイアログの accept/dismiss、履歴の戻る/進む、ビューポートの設定
Claude Code 用のスクリーンショット最適化
Claude Code CLI でスクリーンショットを使用する場合、base64 画像データがコンテキストを大幅に消費する可能性があります。代わりに saveTo パラメータを使用してスクリーンショットをディスクに保存してください:
screenshot_page({ saveTo: "/tmp/page.png" })
screenshot_by_uid({ uid: "abc123", saveTo: "/tmp/element.png" })保存されたファイルは、コンテキストサイズに影響を与えることなく、Claude Code の Read ツールで表示できます。
ローカル開発
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:devテスト
npm run test:run # all tests once (unit + integration)
npm test # watch mode特定のテストスイートの実行、E2E シナリオの網羅範囲、既知の問題については docs/testing.md を参照してください。
トラブルシューティング
Firefox が見つからない:
--firefox-path "/Applications/Firefox.app/Contents/MacOS/firefox"(macOS) または OS 上の正しいパスを渡してください。初回実行が遅い: Selenium が BiDi セッションをセットアップするためです。2回目以降は高速になります。
ナビゲーション後に UID が古くなる: UID ツールを使用する前に、新しいスナップショット (
take_snapshot) を取得してください。Windows 10: MCP サーバー 'firefox-devtools' の検出中にエラー - MCP error -32000: Connection closed
解決策 1
cmd /cでラップする (詳細):"mcpServers": { "firefox-devtools": { "command": "cmd", "args": ["/c", "npx", "-y", "firefox-devtools-mcp@latest"] } }解決策 2
npxへの絶対パスを使用する(セットアップに合わせて拡張子.cmd,.bat,.exe,.ps1を調整してください):"mcpServers": { "firefox-devtools": { "command": "C:\\nvm4w\\nodejs\\npx.ps1", "args": ["-y", "firefox-devtools-mcp@latest"] } }
バージョニング
1.0 未満の API: バージョンは
0.xから始まります。最新リリースには npx で@latestを使用してください。
CI とリリース
CI、リリース、npm 公開用の GitHub Actions が含まれています。詳細および必要なシークレットについては docs/ci-and-release.md を参照してください。
問題と貢献
問題は Bugzilla の product: Developer Infrastructure, component: AI for Development で追跡されています。
質問や議論については、#firefox-devtools-mcp Matrix ルーム に参加してください。
作者
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