Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,59 @@ All notable changes to Zen MCP are documented here. The format follows
[Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project
uses [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.3.3] - 2026-11-02

### Added

- `zen-mcp onboard` lists common MCP clients, preselects the ones found on
this machine, and merges a `zen-mcp` stdio server into each selected
client's configuration. Existing servers, JSONC comments, trailing commas,
and TOML tables are left alone, and rerunning updates the entry instead of
duplicating it. An **Other MCP client** option prints a paste-ready prompt
for clients the picker does not know.

### Fixed

- Glance validates the selected tab's current URL as `http(s)`, enforces the
domain allowlist before the preview loads, and uses a content principal for
the URL instead of the system principal. It also checks the URL the preview
actually committed and closes the preview when a redirect leaves the
allowlist.
- Malformed safety settings in the config file or safety environment variables
stop startup with a clear error instead of falling back to a weaker policy.
That includes `autoLaunch` and `autoAttachWindows`, which no longer fall back
to `true` when the value is malformed.
- Read-only mode also blocks `zen_progress`, `zen_ask`, and `zen_notify`, so an
agent cannot draw or change cards while the server is read-only.
- `zen_tabs_close`, `zen_folder_create`, and `zen_folder_add_tabs` cap their
tab id lists at 100 per call.
- Launch ownership is read through the chrome sandbox globals with a component
service fallback, so Zen 1.24b can start and an unavailable chrome scope
produces a clear error instead of bare `moz-nullprincipal` frames. (#15)
- POSIX process detection covers the real Zen process names and reports
platform status correctly. (#15)
- Foreground tab selection activates the requested tab and reports the
observed focus state instead of a false success. (#16)
- Show source repaints the evidence overlay and scrolls the quoted passage
back into view after the first highlight expires. (#17)
- Adding and removing an essential restores the tab's original space and
pinned state. (#18)
- Closing a split view verifies the split is gone and closes only clearly
synthetic leftovers. (#19)
- Evidence scoring checks surrounding context before the occurrence cap, so a
repeated word can still be disambiguated. (#20)
- Quotes that are definitely absent return `QUOTE_NOT_FOUND` instead of
`LOW_MATCH_CONFIDENCE`. (#21)
- Batch evidence records the real citation outcomes in the audit log instead
of reporting a partial failure as clean. (#22)
- A Stop press from the progress card produces a stop event, changes the
button to "Stopping...", and is re-sent after a bridge reconnect. (#23)
- Concurrent evidence work on one tab is serialized, so verification and
clearing cannot leave an overlay host behind.
- Consent decline guidance now says to restart the server, and batch evidence
uses the documented 20-second highlight default.
- Sandbox script errors report the error name and message before the stack.

## [0.3.2] - 2026-11-01

### Fixed
Expand Down Expand Up @@ -77,6 +130,7 @@ uses [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
Changes for 0.1.0 and 0.2.0 are not recorded here. See the release notes on
GitHub.

[0.3.3]: https://github.com/spaxe-dev/zen-mcp/releases/tag/v0.3.3
[0.3.2]: https://github.com/spaxe-dev/zen-mcp/releases/tag/v0.3.2
[0.3.1]: https://github.com/spaxe-dev/zen-mcp/releases/tag/v0.3.1
[0.3.0]: https://github.com/spaxe-dev/zen-mcp/releases/tag/v0.3.0
23 changes: 20 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ npx @spaxe-dev/zen-mcp setup
Each GitHub release also attaches a package tarball and `SHA256SUMS`:

```sh
npm install -g ./zen-mcp-0.3.2.tgz
npm install -g ./zen-mcp-0.3.3.tgz
zen-mcp setup
```

Expand All @@ -116,6 +116,7 @@ The installed command is `zen-mcp`. Nothing is installed into Zen itself; the br

```sh
zen-mcp setup # detects Zen, writes a config, prints an MCP snippet
zen-mcp onboard # pick MCP clients and add Zen MCP to their config
zen-mcp doctor # config, executable, Marionette, bridge, profile, policy
zen-mcp status # config, profile mode, and port state
```
Expand All @@ -124,7 +125,23 @@ zen-mcp status # config, profile mode, and port state

### Connect an MCP client

Claude Code:
Run the picker:

```sh
zen-mcp onboard
```

It lists Claude Code, Claude Desktop, Cursor, VS Code, Codex CLI, Gemini CLI, Windsurf, Cline, and Zed. Clients found on this machine are preselected. Use the arrow keys to move, space to toggle, and enter to confirm. Zen MCP merges a `zen-mcp` entry into each selected client's own configuration file and leaves other servers alone. Choose **Other MCP client** to print a step-by-step runbook for any agent: known config paths, the right entry shape for JSON, VS Code, Zed and TOML clients, merge rules, a validation checklist, and a completion report.

For scripts or a shell without a TTY, name the clients:

```sh
zen-mcp onboard --clients claude-code,cursor
zen-mcp onboard --clients all --command /path/to/zen-mcp
zen-mcp onboard --clients other
```

Claude Code by hand:

```sh
claude mcp add zen-mcp -- zen-mcp serve
Expand Down Expand Up @@ -188,7 +205,7 @@ Do not point `profilePath` at your normal profile unless that is the tradeoff yo
| Browser ownership | Always on | Launches its own Zen, proves identity with a nonce and `moz:processID`, then closes the Marionette listener to every other client | A local process can race for the port before lockdown; the race is detected, not eliminated |
| Consent | On | Shows one approval card per server process before the first read or change; decline closes the owned browser | After a decline, restart the server to ask again; a timeout leaves the card open |
| Pause | Available in the banner | Blocks browser tools with `paused`, hides the progress card, defers questions, and skips watch polls until Resume | A command already running in Zen may finish; its result is discarded. Pause is not persisted, and existing evidence overlays are not removed |
| Read-only mode | Off | Blocks all 27 tools in the mutating set, including `zen_launch` and a read-only server's auto-launch | Reads, lists, questions, events, and the audit log still work; session and template listings still show stored URLs |
| Read-only mode | Off | Blocks all 30 tools in the mutating set, including `zen_launch`, a read-only server's auto-launch, and on-screen progress, question, and notification cards | Reads, lists, events, collected answers, and the audit log still work; session and template listings still show stored URLs |
| Domain allowlist | Empty | Matches an exact host or a subdomain on a label boundary before opening, previewing, verifying, watching, restoring a session, or applying a template | It is rechecked immediately after opening, but slow, script, or meta redirects can land elsewhere afterwards; reads recheck the tab URL |
| Private windows | Excluded | The bridge is not injected into private windows and an existing bridge is destroyed | This path is not covered by the automated live suite; treat it as a best-effort boundary |
| Audit log | On | Appends one JSON line per tool call, including blocked calls, with URLs reduced to scheme, host, and path | Argument summaries are bounded; sensitive values are digested, but a preview of the summarized arguments can remain |
Expand Down
26 changes: 22 additions & 4 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ zen-mcp launch Launch Zen once, verify ownership, then quit it
zen-mcp status Print config, profile mode, and port state
zen-mcp doctor Check config, executable, bridge, profile, port, policy
zen-mcp setup Detect Zen, write config, print an MCP snippet
zen-mcp onboard Pick MCP clients and add Zen MCP to their config
zen-mcp setup --use-default-profile
zen-mcp setup --dedicated-profile
zen-mcp config show Print the config path and values
Expand All @@ -33,6 +34,19 @@ zen-mcp config set <key> <value>

`setup` does not install anything into Zen. The bridge is injected at runtime.

## MCP clients

`onboard` merges Zen MCP into MCP client configurations:

```text
zen-mcp onboard
zen-mcp onboard --clients claude-code,cursor
zen-mcp onboard --clients all
zen-mcp onboard --clients other
```

The picker knows Claude Code, Claude Desktop, Cursor, VS Code, Codex CLI, Gemini CLI, Windsurf, Cline, and Zed. It preselects clients found on this machine. Only the `zen-mcp` entry is created or replaced; other servers stay, and JSONC files keep their comments and trailing commas. `other` prints a step-by-step runbook with config paths, entry shapes, merge rules, a validation checklist and a completion report. `--command` changes the command clients should run.

## File locations

Config file:
Expand Down Expand Up @@ -81,6 +95,8 @@ Session and template files are written atomically with owner-only permissions. T

Numeric file values outside their range are clamped when loaded. `config set` rejects them instead, so use it when you want a validation error.

Policy keys are validated by type. `readOnly`, `requireConsent`, `useDefaultProfile`, `auditLog`, `autoLaunch`, and `autoAttachWindows` must be JSON booleans, and `allowedDomains` must be an array of strings. A malformed value stops the server with a config error instead of falling back to a weaker default.

### Marionette port

Current Zen builds listen on 2828. The launcher passes `-marionette` without a port, so Zen does not follow `marionettePort`; the setting only changes the port the server tries to reach. Leave it at `2828` unless you know your Zen build supports another port. If another process owns 2828, quit that process; changing the setting usually makes the launch fail.
Expand All @@ -95,18 +111,20 @@ Environment variables override the file for that process. They are never written
| `ZEN_MCP_DATA_DIR` | Sessions, templates, audit log, and the default agent profile directory |
| `ZEN_MCP_ZEN_PATH` | Zen executable |
| `ZEN_MCP_PROFILE` | Custom agent profile directory |
| `ZEN_MCP_USE_DEFAULT_PROFILE` | `1` uses Zen's normal profile instead of the dedicated one |
| `ZEN_MCP_REQUIRE_CONSENT` | `0` skips the one-time approval card |
| `ZEN_MCP_USE_DEFAULT_PROFILE` | `1`, `true`, `yes`, or `on` uses Zen's normal profile instead of the dedicated one |
| `ZEN_MCP_REQUIRE_CONSENT` | `0`, `false`, `no`, or `off` skips the one-time approval card |
| `ZEN_MCP_CONSENT_TIMEOUT_SECONDS` | How long a tool waits for approval |
| `ZEN_MCP_LAUNCH_ARGS` | Extra Zen arguments, split on whitespace |
| `ZEN_MCP_MARIONETTE_PORT` | Port the server connects to (see [Marionette port](#marionette-port)) |
| `ZEN_MCP_READ_ONLY` | `1`, `true`, or `yes` enables read-only mode |
| `ZEN_MCP_READ_ONLY` | `1`, `true`, `yes`, or `on` enables read-only mode |
| `ZEN_MCP_ALLOWED_DOMAINS` | Comma-separated domain allowlist |
| `ZEN_MCP_AUDIT_LOG` | `1`, `true`, or `yes` enables the audit log |
| `ZEN_MCP_AUDIT_LOG` | `1`, `true`, `yes`, or `on` enables the audit log |
| `ZEN_MCP_WATCH_MIN_INTERVAL_SECONDS` | Lower bound for watch polling |
| `ZEN_MCP_LOG` | `debug`, `info`, `warn`, or `error` |
| `ZEN_MCP_BRIDGE_SCRIPT` | Override the bundled `bridge.js` path; `doctor` warns when set |

Boolean variables accept `1`/`0`, `true`/`false`, `yes`/`no`, or `on`/`off`, ignoring case and surrounding spaces. Any other value stops the server with an error instead of falling back to the file or default.

Logs always go to **stderr**; stdout belongs to the MCP transport.

## `config set`
Expand Down
4 changes: 2 additions & 2 deletions docs/security.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,15 @@ The banner in Zen has a Pause button. Pausing rejects pending bridge requests, h

A command that is already executing in Zen when Pause is pressed may still finish in the browser. The server drops its result and rejects later requests. Pause is held in memory, is not persisted, and does not remove evidence overlays that are already visible.

`readOnly` blocks the complete mutating tool set: `zen_launch` and 26 other tools covering spaces, tabs, folders, pins, essentials, split view, Glance, clipboard writes, watches, sessions, templates, tab grouping, and evidence operations. Reads, lists, status, questions, events, and the audit log keep working. A read-only server also refuses to auto-launch Zen, so it never starts a process or creates a profile.
`readOnly` blocks the complete mutating tool set: `zen_launch` and 29 other tools covering spaces, tabs, folders, pins, essentials, split view, Glance, clipboard writes, watches, sessions, templates, tab grouping, evidence operations, and the on-screen progress, question, and notification cards. Reads, lists, status, events, collected answers, and the audit log keep working. A read-only server also refuses to auto-launch Zen, so it never starts a process or creates a profile.

Read-only mode is not a confidentiality boundary. Session and template listings still return stored URLs, and page reads still return page text. Use Pause when the user wants to stop browser access entirely.

### URL policy

One normalizer is shared by the MCP guard, the runtime, and the bridge. Inputs without a scheme are treated as `https`. `zen_tabs_open` accepts `http(s)` and `about:` URLs; Glance previews and both Evidence tools accept only `http(s)`. With an empty allowlist these are all permitted. With a non-empty allowlist, every URL is matched by host, so an `about:` URL is rejected along with any other non-`http(s)` scheme.

The domain allowlist matches a host exactly or as a subdomain on a label boundary, and is checked before tabs open, Glance, evidence, watches, session restores, and template applies. The tab URL is checked again immediately after `zen_tabs_open` returns, and a tab that landed outside the list is closed. A slow script or meta redirect after that check can still move the tab; reads recheck the URL before returning content. An empty list allows every domain; a list whose entries all normalize away denies everything. Sessions and templates are sanitized and capped before use.
The domain allowlist matches a host exactly or as a subdomain on a label boundary, and is checked before tabs open, Glance, evidence, watches, session restores, and template applies. Glance resolves the selected tab's current URL, requires `http(s)`, and checks the allowlist before the preview loads, so a privileged or off-list tab is refused before any load starts. The preview uses a content principal for that URL rather than the system principal. After it opens, the bridge reads the URL the preview actually committed; a redirect that lands outside the allowlist closes the preview and fails the call. A later location change on the glance is watched too, and a preview that leaves the allowlist is closed. The tab URL is checked again immediately after `zen_tabs_open` returns, and a tab that landed outside the list is closed. A slow script or meta redirect after that check can still move the tab; reads recheck the URL before returning content. An empty list allows every domain; a list whose entries all normalize away denies everything. Sessions and templates are sanitized and capped before use.

### Reads

Expand Down
4 changes: 2 additions & 2 deletions docs/tools.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ For read formats and Evidence Mode behavior, see [reading-and-evidence.md](readi

The MCP guard applies policy before a tool runs:

- **Read-only mode** blocks the 27 tools that change browser, server, or persisted state: `zen_launch`, space create/switch/delete, tab open/close/select, folder create/add, pin, essentials, Glance, split view/close, clipboard write, watch add/remove, session save/restore/delete, template save/apply/delete, tab grouping, and the three evidence tools. A read-only server also refuses to auto-launch Zen.
- **Read-only mode only blocks the mutating set.** `zen_read_page`, `zen_read_pages`, `zen_find_text`, `zen_search_tabs`, history, bookmarks, status, lists, `zen_ask`, `zen_events`, `zen_answers`, `zen_notify`, `zen_progress`, `zen_config`, and `zen_audit_tail` keep working. Session and template listings can still show stored URLs.
- **Read-only mode** blocks the 30 tools that change browser, server, persisted, or on-screen state: `zen_launch`, space create/switch/delete, tab open/close/select, folder create/add, pin, essentials, Glance, split view/close, clipboard write, watch add/remove, session save/restore/delete, template save/apply/delete, tab grouping, the three evidence tools, and `zen_progress`, `zen_ask`, and `zen_notify`. A read-only server also refuses to auto-launch Zen.
- **Read-only mode only blocks the mutating set.** `zen_read_page`, `zen_read_pages`, `zen_find_text`, `zen_search_tabs`, history, bookmarks, status, lists, `zen_events`, `zen_answers`, `zen_config`, and `zen_audit_tail` keep working. Session and template listings can still show stored URLs.
- **The domain allowlist** checks URLs for tools that open, preview, verify, watch, restore, or apply a template. An empty list allows everything. Entries are normalized to a host and match exactly or as a subdomain on a label boundary. URL checks happen before the action and again after `zen_tabs_open` returns; a redirect that happens later, such as a slow script or meta refresh, can still leave the tab on another host. Reads recheck the tab URL before returning content.
- **The audit log** records tool calls, including calls blocked by read-only mode or the allowlist, and resource reads under `resource:<uri>`. `executed` reports whether the handler returned a result; `ok` reports whether that result succeeded. Evidence batch entries add `citationsVerified`, `citationsFailed`, and `outcome` (`success`, `partial`, or `failed`), so a batch with a failed citation is not logged as full success.

Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@spaxe-dev/zen-mcp",
"version": "0.3.2",
"version": "0.3.3",
"description": "An agent harness for Zen Browser. Native spaces, background research tabs, and in-browser questions.",
"license": "MIT",
"repository": {
Expand Down
15 changes: 11 additions & 4 deletions src/bridge/host.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1143,10 +1143,17 @@ export class BridgeHub {
params: BridgeMethodMap["glance.open"]["params"],
windowId?: string
) {
const result = await this.request("glance.open", params, {
windowId,
timeoutMs: 30_000,
});
if (params?.url) {
this.#assertUrlAllowed(String(params.url), "Refusing to preview");
}
const result = await this.request(
"glance.open",
{ ...params, allowedDomains: this.#allowedDomains },
{
windowId,
timeoutMs: 30_000,
}
);
if (result.url) {
this.#assertUrlAllowed(result.url, "Refusing to preview");
}
Expand Down
Loading
Loading