Skip to main content
Glama

ff-mcp

ff-mcp connects a local MCP client to Firefox. It gives the client only the browser access that you approve.

The project has two parts:

  • A Firefox Manifest V3 extension controls browser access.

  • A Python Native Messaging host serves MCP on 127.0.0.1.

The Firefox extension makes the final access decision. The local MCP server cannot bypass this decision. A client can list tab metadata without page access. The client needs separate grants to read a page, interact with a page, run a script, or take a screenshot.

Features

  • List tab metadata, including the container of each tab.

  • Request READ, INTERACT, SCRIPT, or SCREENSHOT access for one tab.

  • Look up the result of an access request by its request ID.

  • Grant access once, for one document, for one tab session, or for a host until you remove the rule.

  • Read bounded snapshots with stable document-scoped element references and CSS query results.

  • Batch up to 20 known actions and return a snapshot in one tool call.

  • Optionally act or navigate, wait for a UI condition, and snapshot one element in one tool call.

  • Click, type, scroll, and navigate with structured operations.

  • Replace the text of a contenteditable editor without SCRIPT access.

  • Run JavaScript only after a separate SCRIPT grant.

  • Build persistent rules with a visual editor.

  • Audit access decisions and sensitive operations in Firefox.

  • Listen automatically while enabled on a loopback-only MCP server.

Related MCP server: fire-fodex

Requirements

  • Firefox 150 or newer.

  • Python 3.14.

  • uv.

One-time SCRIPT execution needs Firefox 153 or newer. Firefox 153 added userScripts.execute(). Other features support Firefox 150 or newer.

Install

Read the user setup guide for complete instructions.

You can also give this repository to a local coding agent. The agent will read AGENTS.md and guide you through setup. You must still select a Firefox profile and approve the add-on in Firefox.

On Windows, follow Windows installation and repair. It uses explicit uv directories outside AppData and registration from ordinary PowerShell outside Codex. This avoids an installation visible to a packaged agent but unavailable to Firefox.

The main commands on other platforms are:

uv tool install --force .
ff-mcp profiles --json
ff-mcp setup --profile "/path/to/your/profile" --install-addon

Confirm the installation in Firefox. The enabled extension starts listening automatically.

For extension development, open about:debugging. Select This Firefox. Select Load Temporary Add-on. Then select extension/manifest.json.

Connect an MCP client

Run ff-mcp connection for the local URL. No setup token or connection approval is needed. Remove bearer-token settings from older client entries. The same loopback endpoint supports stateful MCP clients and clients using the sessionless protocol since 2026-07-28. Browser-origin HTTP requests are rejected.

See the user setup guide for Codex, Claude Code, and generic MCP client examples.

Permission flow

  1. Call browser_tabs and select a tab ID.

  2. Call browser_request_access with capabilities, agent name, model, harness, and a brief task reason.

  3. If the result includes access_context, keep it private and pass it to the tools that use this access. Approve or reject the request in Firefox. browser_access_status reports the result.

  4. Use the approved browser tool.

  5. Revoke the grant in Firefox or with browser_revoke.

Stateful clients keep their MCP session header. Sessionless clients get access_context from their first browser_request_access call. Reuse it for status checks, further requests, page access, grant listing, audit and revocation. It expires after eight hours or when the native host restarts. If it expires, call browser_request_access without access_context to start a new context. You can revoke any remaining grants from the expired context in Firefox. The context identifies the grant owner and Firefox still decides which capabilities are allowed. Persistent rules also work on sessionless requests without a context.

READ access is enabled by default for these local addresses:

  • localhost

  • Subdomains of .localhost

  • 127.0.0.0/8

  • ::1

This default does not grant INTERACT, SCRIPT, or SCREENSHOT access.

Check an access request

A pending browser_request_access result contains a requestId. Call browser_access_status with that ID instead of repeating the request. The status is one of these values:

  • pending: the user did not decide yet.

  • approved: the result contains the selected lifetime and a grantId, or a ruleId for a persistent approval. The grant can since be used up or revoked; browser_grants lists active grants.

  • denied: the user rejected the request.

  • stale: the tab closed or its document changed before a decision. Send a new request.

  • unknown: the request belongs to a different owner or Firefox no longer records it.

Only the session or access context that made a request can read its status. Firefox keeps the newest 200 results in memory until the server stops.

Tab containers

browser_tabs returns cookieStoreId and incognito for each tab. cookieStoreId is firefox-default, firefox-private, or firefox-container-N for a container tab. The add-on does not request the permission that reads container names, so only this identifier is available.

Efficient browser use

Request the needed capabilities together with lifetime: "tab_session" to keep approval through navigation. The popup still lets the user choose a shorter lifetime. Request only what the task needs. Use browser_snapshot to get visible controls with @ref selectors; pass these directly to click, type, or batch actions. References become invalid when the document changes. CSS selectors also work. The default text limit is 12,000 characters; increase max_chars when needed.

Snapshots are compact by default, including those returned by waits and action batches. Visible controls appear once in elements, with stable references, short names (ARIA labels, associated labels, or visible text), link targets, and relevant state. Compact snapshots omit the duplicate forms and links lists and empty attributes. They retain page text and visible headings for context. truncation reports text clipping and omitted controls or headings; individual shortened names and link targets carry truncation flags. Controls are limited to 200. Use browser_query for controls beyond that limit. Use browser_snapshot(compact=false) for full attributes, form structure, and the separate links list; include_links controls that list only in full mode. Input values are not included in either mode.

Set scope to a CSS selector or a current-document @ref to limit a snapshot to one element, for example a dialog, a menu, or a panel. browser_snapshot, browser_wait, browser_actions, and browser_navigate accept it. A scoped snapshot contains the text, headings, and controls of that element, and a scope entry with its reference. Accessible names can use labels outside the scope. It also lists ARIA widgets that page-wide snapshots omit: menu items, options, tabs, checkboxes, radios, switches, comboboxes, text boxes, and tree items. Page-wide snapshots do not change. A scoped wait is ready only when the scope element exists. A scoped snapshot without a wait fails when no element matches.

Use browser_actions for a known sequence such as filling several fields. It requires READ and INTERACT, executes at most 20 click/type/scroll actions in order, and returns a snapshot. It stops on failure and reports completed; inspect that result before retrying. A page navigation or transport failure can interrupt the response after actions have run. Async UI updates can need another snapshot.

Act, wait, and snapshot in one call

browser_actions and browser_navigate accept the optional wait_for and scope parameters. With one of them, the tool does these steps in one call:

  1. It checks the parameters and the access before it changes the page.

  2. It runs the actions or the navigation one time.

  3. It waits up to timeout_ms for the wait_for condition.

  4. It returns one snapshot, limited to scope when given.

For example, open a menu and read only that menu:

{
  "tab_id": 22,
  "actions": [{"kind": "click", "selector": "button[aria-label='Panel menu']"}],
  "wait_for": {"selector": "[role=menu]"},
  "scope": "[role=menu]"
}

The result contains wait.status and, when the status is ready, snapshot:

  • ready: the condition matched.

  • timeout: the condition did not match in time.

  • error: the wait could not continue. wait.message gives the cause, for example that READ access ended when the document changed.

  • skipped: an action failed, so the tool did not wait (browser_actions only).

Completed actions and the navigation stay done in every case. The tool never repeats them. Inspect the tab before you send them again.

browser_actions needs READ and INTERACT for the current document before it acts. For browser_navigate, READ must continue after navigation: use a tab-session grant or a persistent rule. The tool fails before it navigates when neither exists. A condition can match on the old document when an action starts a navigation later; use a condition that only the expected result satisfies. Use CSS selectors, not @ref values, for a condition or scope on a new document.

Without wait_for and scope, both tools behave as before.

Replace text in an editor

browser_replace_text replaces all text of one contenteditable editor, such as a CodeMirror query editor. It needs INTERACT only and runs no script. selector is the editable element (for CodeMirror 6, .cm-content) or a wrapper that contains exactly one editable element.

The tool focuses the editor, selects only its content, and inserts the text through Firefox's own text insertion. The editor receives the same input events as for typing. Focus stays in the editor. The tool stops before it changes text when the element is not an editor, is only a part of an editor, or does not take focus.

The result contains no page text. status tells what the editor shows afterwards:

  • verified: the editor's visible text matches the requested text, and its DOM contains no additional text.

  • unchanged: the editor's DOM text stayed the same. Inspect the editor before retrying or saving.

  • inconclusive: the editor shows other text. Some editors render only the visible lines, reformat text, or add completions. Inspect the editor with a scoped snapshot or a screenshot before a retry.

Limits: the editor must be in the top document and outside a shadow root. Editors that keep their text in a hidden textarea are not contenteditable; use browser_type for a reachable input or textarea. An editor that applies a change only when it loses focus can need another page action. The check uses the editor's DOM text. An editor can report inconclusive after applying an edit, for example when it renders blank lines differently or shows only part of its document. This operation was probed with CodeMirror 6 in headless Firefox. It was not tested on a Grafana instance.

Wait for page readiness

browser_navigate sends navigation once, then waits for the destination content script by default. Its wait result reports ready, timeout, or error; a timeout does not undo the navigation. Set wait_until: "none" for the previous immediate-return behavior.

Use browser_wait or browser_snapshot(wait_for=...) for asynchronous UI updates. Conditions are combined with AND. An empty condition waits for an accessible document. Supported fields are:

  • selector: CSS selector or a current-document @ref.

  • state: attached, detached, visible (default), hidden, or enabled; requires a selector.

  • text: case-sensitive substring in the element's rendered text, or the page text without a selector.

  • url: exact absolute HTTP(S) URL, including query and fragment.

For example, after opening a review dialog:

{
  "tab_id": 22,
  "wait_for": {"selector": "[role=dialog] button[type=submit]", "state": "enabled"},
  "timeout_ms": 10000
}

browser_wait returns {status: "ready", snapshot: ...} or {status: "timeout", timeoutMs: ...}. A waiting browser_snapshot returns its normal snapshot on success or the same timeout object. Both require READ access, recheck consent during waiting, and consume a one-use grant only on success. Use a tab-session grant and CSS selectors for waits that span navigation.

Timeouts default to 10 seconds and accept 1–20,000 milliseconds. Polling is bounded even when a content script does not answer. Waits do not retry actions, wait for network-idle, or guarantee that all asynchronous work is finished. Use a condition that represents the next action's prerequisite. Batches remain synchronous; split a batch at an async boundary, wait for the condition, then continue.

One-use grants

A persistent rule authorizes an operation first, then a reusable grant. A one-use grant is used up only when nothing else gives the capability. browser_actions selects its READ and INTERACT sources together before it acts. One one-use grant with both capabilities covers the batch and its snapshot. With wait_for or scope, the tool holds a one-use grant during the wait; other requests cannot use it. The batch uses up a one-use INTERACT grant. Only a returned snapshot uses up a one-use READ grant.

Host and add-on versions

The native host and the signed add-on update separately. scope, wait_for on browser_actions and browser_navigate, browser_replace_text, and browser_access_status need an add-on that supports them. An older add-on rejects these calls before it reads or changes a page, and the tool tells you to update the add-on. Calls without these options work with older add-ons. browser_tabs omits the container fields with an older add-on.

Policy rules

Open the extension options page to use the visual policy editor. Each new rule has one main AND group. The main group contains an OR allow group and a NAND exclusion group.

Add host, URL pattern, regular expression, or scheme conditions. You can nest AND, OR, NAND, and NOR groups. Then select the capabilities that the rule grants.

An empty positive group matches nothing. An empty negated group matches everything. Therefore, a new rule stays inactive until you add a condition to its allow group.

The default localhost rule starts with READ access. You can edit or disable it, but you cannot delete it. A persistent approval is automatically added to the main allow group of a new rule.

Regular expressions have a length limit. They cannot use backreferences, lookarounds, or clear nested quantifiers. This is a safety subset. It is not a complete RE2 implementation.

Development

UV_CACHE_DIR=/tmp/ff-mcp-uv-cache uv sync --locked --group dev
UV_CACHE_DIR=/tmp/ff-mcp-uv-cache uv run ruff check .
UV_CACHE_DIR=/tmp/ff-mcp-uv-cache uv run ruff format --check .
UV_CACHE_DIR=/tmp/ff-mcp-uv-cache uv run pytest -q
node --test tests/background.test.js tests/content.test.js tests/policy.test.js tests/rule-model.test.js tests/popup.test.js tests/waits.test.js

Run the Firefox integration test only when you want to start Firefox with a temporary profile:

FF_MCP_RUN_FIREFOX_TESTS=1 \
  UV_CACHE_DIR=/tmp/ff-mcp-uv-cache \
  uv run pytest -q tests/test_firefox_integration.py

Set FIREFOX_BINARY if Selenium cannot find Firefox. The test can find the standard Linux Snap installation without this variable.

The Firefox extension has no runtime third-party dependencies. It also has no build step.

Releases

Check the four synchronized version sources, or bump all of them with one command:

python3 scripts/version.py check
python3 scripts/version.py bump patch  # also accepts minor, major, or an exact X.Y.Z

A tag in the form vX.Y.Z starts the release workflow. CI checks that pyproject.toml, the Python package, the Firefox manifest, and uv.lock all have the same version. The release additionally requires the tag to match that version.

The workflow sends the extension to Mozilla Add-ons for unlisted signing. It verifies the returned XPI. It then attaches the signed XPI and its SHA-256 file to a GitHub release. These generated files stay untracked. It also publishes updates.json at a stable latest-release URL. Signed versions that contain this update URL use the file for automatic self-distributed updates.

Set these secrets in the GitHub release environment:

  • AMO_JWT_ISSUER

  • AMO_JWT_SECRET

Create the credentials on the AMO API keys page. Unlisted signing does not add the extension to AMO search results.

Security limits

  • The extension requests broad site access because it must support user-approved access to many sites. Its internal capability checks are critical.

  • Approved page data and browser activity go to the local native host and MCP client.

  • Firefox blocks content scripts on restricted pages such as about: pages and the add-ons store.

  • A tab-session grant stays active after navigation in that tab. A document grant does not.

  • Temporary grants are bound to one MCP session or sessionless access context. A new session or access context needs its own grants.

  • Persistent rules (including default localhost READ) apply to every session and local client.

  • Agent/model/harness labels are supplied by the client, not verified identities.

  • Local clients can list tab metadata without approval. Approvals gate page operations.

  • A click or input operation can cause page actions. Grant INTERACT access with care. browser_replace_text replaces the complete text of an editor with INTERACT access alone.

  • SCRIPT gives full page control. A main-world script can read and change page-owned JavaScript state. Grant it only to clients and sites that you trust.

See firefox_mcp_extension_findings.html for the design research.

License

MIT. See LICENSE and THIRD_PARTY.md.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      C
      maintenance
      Drive 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.
      41
      83 npm
      2
      MIT
    • A
      license
      B
      quality
      D
      maintenance
      A local Firefox bridge for MCP agents that enables tab control, DOM interaction, mouse/keyboard actions, and screenshots.
      24
      MIT
    • A
      license
      Not graded
      quality
      C
      maintenance
      A local MCP server for Firefox that gives AI agents full control over the browser via a Unix socket, enabling automation of tabs, pages, cookies, and more without exposing any network ports.
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables MCP-capable CLIs to operate real, already-logged-in Firefox tabs via a WebExtension and native messaging, without simulated input. Supports navigation, clicking, typing, reading, screenshots, and console/network capture with policy gating and frame awareness.
      3
      MIT