Skip to main content
Glama

zen-mcp

zen-mcp is a local stdio MCP server for Zen Browser. It reads and mutates tabs, Spaces, and ordinary tab groups in normal Zen windows, including tabs in inactive and unsynchronized windows. It discovers Zen folders separately and never treats them as ordinary tab groups.

The supported installation path is the included Nix flake. The project also builds with Node 22 and npm.

Requirements

  • Zen Browser >=1.24b <1.25

  • Nix with flakes enabled

  • A closed Zen profile during bridge installation and removal

The bridge uses Zen's privileged experiment APIs. It is intended for a profile that you control and should not be copied into an untrusted profile.

Related MCP server: Firefox Tab Management Agent MCP

Install

From this checkout:

nix profile install .#
zen-mcp-setup --profile default

--profile is required. It accepts a Zen profile name, default, or an absolute profile directory. Close every Zen process that uses the selected profile first. Setup refuses to modify a locked profile.

The setup command:

  • backs up the existing user.js and any previous zen-mcp-bridge@local.xpi

  • adds only the three preferences required by the experiment bridge

  • installs the profile-local bridge XPI

  • records enough state to restore the prior configuration on uninstall

Restart Zen completely after setup. Then register the stdio server with Codex:

codex mcp add zen-mcp -- zen-mcp

The equivalent Codex ~/.codex/config.toml entry is:

[mcp_servers.zen-mcp]
command = "zen-mcp"
args = []

See the Codex MCP documentation for client configuration details.

Run the diagnostics after Zen has started:

zen-mcp-doctor --profile default

The doctor checks the Zen version, selected profile, managed preferences, extension files, common MCP configuration files, live bridge authentication, Spaces availability, and unsupported versions. Use --json for machine readable output or --no-live to skip authentication.

Run without a profile install

nix run .#setup -- --profile default
nix run .#doctor -- --profile default
nix run .#

nix run .# starts the stdio MCP server. It is normally launched by the MCP client rather than interacted with directly. If the local bridge listener cannot start, MCP initialization still completes and zen_status reports a structured startupError; bridge-dependent tools return BRIDGE_UNAVAILABLE.

Home Manager

The flake exports a Home Manager module for package installation:

{
  inputs.zen-mcp.url = "path:/path/to/zen-mcp";

  imports = [ inputs.zen-mcp.homeManagerModules.default ];

  programs.zen-mcp.enable = true;
}

The module installs zen-mcp, zen-mcp-setup, and zen-mcp-doctor through the Home Manager profile. It does not register an MCP client automatically and does not modify a Zen profile. Client registration remains separate so the same server can be used by any compatible stdio MCP client.

If Zen's user.js is also managed by Home Manager, declare the bridge preferences in that profile so setup can leave the generated file untouched:

programs.zen-browser.profiles.default.settings = {
  "extensions.experiments.enabled" = true;
  "xpinstall.signatures.required" = false;
  "extensions.autoDisableScopes" = 0;
};

Complete the one-time bridge setup while Zen is closed:

zen-mcp-setup --profile default

Uninstall

Close Zen, then run:

zen-mcp-setup --profile default --uninstall

For a source checkout, use:

nix run .#setup -- --profile default --uninstall

Uninstall removes the managed preference block and restores the original user.js, including a symlinked user.js when its contents are unchanged. A previous bridge XPI is restored when one existed; otherwise only the managed XPI is removed. Unrelated profile configuration is preserved.

Remove the Codex registration separately if it is no longer wanted:

codex mcp remove zen-mcp

Collections and IDs

Zen windows that mirror the same synced workspace form one logical collection. Mirrored DOM tabs are deduplicated into one result with all mirror window IDs. Each unsynchronized normal window is a separate collection. Private windows are excluded and reported as unsupported.

collection_id, space_id, tab_id, and group_id are guarded, session-scoped identifiers. They include the bridge session nonce and become invalid after Zen restarts or the bridge reconnects. Run discovery tools again after a reconnect instead of retaining IDs.

Tools

Tool

Purpose

zen_status

Report bridge and version state, profile, collections, Spaces availability, and unsupported windows.

list_spaces

List Spaces with IDs, names, icons, ordering, and active state.

create_space

Create a Space without switching to it, optionally after an existing Space.

list_tabs

List deduplicated logical tabs with collection, Space, URL, title, pin, group, discard, essential, and placeholder filters. Returns a flat tabs compatibility array, a hierarchy in outline, and a readable text tree.

list_tab_groups

List ordinary tab groups and Zen folders as distinct kinds with title, color, collapsed state, members, and separate counts.

create_tab_group

Create a plain, expanded <tab-group> from explicitly selected unpinned tabs in one collection and Space. Zen-folder members and pinned tabs are rejected.

update_tab_group

Rename, recolor, collapse, or add unpinned tabs to and remove members from an ordinary tab group. Zen folders and pinned additions are rejected.

ungroup_tabs

Remove explicitly selected tabs from ordinary tab groups without closing them. Tabs in Zen folders are rejected.

unpin_tabs

Remove explicitly selected pinned tabs from pinned sections without changing their Space or ordinary-group membership. Essential tabs, Zen-folder members, and split views are rejected.

move_tabs

Preview and confirm moving tabs to another Space in the same collection.

close_tabs

Preview and confirm closing explicitly selected tabs.

Read-only tools, additive mutations, reorganizing mutations, and destructive mutations advertise MCP annotation hints so clients can apply their own approval policy.

Tab groups and Zen folders

Zen folders and ordinary tab groups are different node types even though Zen's tab-group APIs recognize both. list_tab_groups reports kind: "group" for an ordinary <tab-group> and kind: "folder" for a ZenFolder, plus separate groupCount and folderCount values. Collection status uses the same separate counts.

create_tab_group calls Zen's ordinary addTabGroup operation, returns kind: "group", and forces collapsed: false. It does not create a ZenFolder, does not move selected tabs into one, and fails with GROUP_MEMBERSHIP before mutation when a selection already contains a Zen-folder member or a pinned tab.

update_tab_group and ungroup_tabs are deliberately restricted to ordinary tab groups. A Zen-folder target fails with GROUP_MEMBERSHIP and a message stating that Zen folders are not ordinary tab groups. Adding a pinned tab to an ordinary group is also rejected before mutation.

Zen treats an ordinary group containing any pinned tab as pinned and hides the whole group while the Space's pinned section is collapsed. The bridge therefore rejects pinned members during group creation or addition. unpin_tabs removes an existing pinned tab from pinned sections while preserving its current ordinary-group membership, which makes an otherwise hidden group visible. It does not expand the pinned section automatically. An already-affected group can also be renamed, have its pinned member removed, or be ungrouped through the normal recovery operations.

list_tabs preserves the flat tabs array for clients that consume the existing response, and adds an outline that groups the same filtered tabs by collection, Space, Zen folder, ordinary tab group, and ungrouped status. Folder containment is inferred from the snapshot's member tabs, so an ordinary group nested inside a folder is shown beneath that folder without duplicating its tabs. The MCP text content renders this outline as a readable tree; the full response remains available in structuredContent.

Preview and confirmation

The first move_tabs or close_tabs call does not mutate the browser. It returns:

  • the exact affected tabs, including split-view members and pinned tabs

  • warnings and an expiry timestamp

  • a one-use confirmationToken

Repeat the same call with that token to execute it. Tokens expire after 120 seconds, are bound to the original arguments, and become stale if relevant collection state changes. Replaying a token fails.

Essential tabs are never moved, grouped, or closed. Pinned tabs can be moved or closed only when explicitly selected, and every affected pin appears in the preview. A selected split-view tab expands to its complete split-view unit. Tab groups and Zen folders cannot span Spaces or collections; move tabs first when consolidating across Spaces.

If a runtime mutation fails partway through, the bridge stops initiating changes, reads browser state again, and returns verified succeeded, failed, and unattempted targets. This is not an atomic rollback. Structured failures include codes such as BRIDGE_UNAVAILABLE, UNSUPPORTED_ZEN_VERSION, UNKNOWN_ID, STALE_PREVIEW, PROTECTED_TAB, GROUP_MEMBERSHIP, and PARTIAL_APPLY.

Security model

  • The MCP endpoint listens only on 127.0.0.1 and uses an ephemeral port.

  • A random token is written to ${XDG_STATE_HOME:-~/.local/state}/zen-mcp/connection.json with mode 0600.

  • The bridge reconnects and authenticates with the token in its first frame.

  • A per-user lock prevents multiple zen-mcp server processes from racing over the bridge connection.

  • The token changes each time the server starts.

  • Only normal Zen windows are exposed. Private windows are excluded.

v1 limitations

Space deletion, Space metadata updates, remote MCP transport, private-window access, and direct zen-sessions.jsonlz4 editing are not included. Opening or navigating tabs, history, bookmarks, Space activation, and Space editing are also outside v1. Zen-folder renaming, mutation, and ungrouping are not exposed.

Development

nix develop
npm install
npm run check
nix flake check
nix build

npm run check runs type checking, ESLint, Vitest, and the production build. The build creates dist/ and a deterministic bridge/zen-mcp-bridge.xpi. The Nix package keeps dist/ and the XPI together so the installed setup command finds its packaged bridge.

For a live end-to-end test, use a dedicated Zen profile and state directory:

npm run build
npm run smoke:live -- \
  --profile /absolute/path/to/isolated-profile \
  --state-root /absolute/path/to/isolated-state

The profile must be running with the bridge installed and have at least two non-essential loose tabs in one Space and window. The smoke test creates an ordinary tab group, verifies it is expanded and distinct from Zen folders, renames, recolors, collapses, expands, and ungroups it. It requires explicit paths and refuses the default state root so it cannot silently target the default Zen profile.

License

MIT

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