Skip to main content
Glama

Agent Bridge

Browser access to the desktop AI coding-agent sessions running on your Mac.

Agent Bridge installs a small daemon and a menu bar app on the Mac. The daemon enumerates the sessions of the agents you already use — Claude Desktop's Code panel, Claude Code CLI, ChatGPT Desktop's Codex panel, Codex CLI, Antigravity, DeepSeek Harness — and lets you read and reply to them from a phone or any other browser. It can also host its own Claude Code processes so the browser can create sessions that do not depend on a desktop app.

The Mac dials out to a Cloudflare relay. Nothing listens on an inbound port, no tunnel is installed, and no firewall rule is needed. Every byte between the browser and the Mac is end-to-end encrypted with Noise; the relay only sees opaque ciphertext and routing metadata.

Contents

Related MCP server: claude-desktop-to-code

How it works

   Phone / laptop browser                Cloudflare                    Your Mac
 ┌──────────────────────┐          ┌──────────────────┐          ┌──────────────────────┐
 │  web client (PWA)    │   WSS    │  relay Worker    │   WSS    │  bridge daemon       │
 │  Noise initiator     │◀────────▶│  Room DO / room  │◀────────▶│  Noise responder     │
 │  E2E: ciphertext     │          │  ciphertext only │          │  adapters + SQLite   │
 └──────────────────────┘          └──────────────────┘          └──────────┬───────────┘
                                                                            │ local files,
                                                                            │ sockets, CLI
                                                                  ┌─────────▼──────────┐
                                                                  │ Claude Desktop,    │
                                                                  │ claude, codex,     │
                                                                  │ agy, dsh, hosted   │
                                                                  └────────────────────┘
  1. bridge init creates a room on the relay and stores the room id, a bridge token and a Noise static identity in a local state directory.

  2. bridge serve (or the menu bar app) opens one outbound WebSocket to the relay and keeps it open, reconnecting with 1 s → 30 s backoff.

  3. bridge invite mints a one-time invite token locally. Only its SHA-256 hash is uploaded to the relay. The invite link carries the token in the URL fragment, which browsers never send to a server.

  4. The browser performs a Noise xxpsk3 handshake with the Mac, with the PSK derived by HKDF-SHA256 from the invite token and the room id. Both sides display a 6-digit confirmation code derived from the two public keys; the user compares them and confirms.

  5. The device's Noise public key is stored on the Mac. Future connections use the ik pattern — the Mac authenticates the device cryptographically, so no token is needed and a stolen relay cannot impersonate either side.

  6. Requests and responses are Noise transport messages inside binary relay frames; the relay forwards 16-byte channel ids and never parses a payload.

The web client polls for new messages (5 s in a chat or list view, 10 s for the background session watcher) rather than receiving server-pushed deltas. Push notifications use Web Push/VAPID so the phone still gets an alert when the tab is closed.

Supported agents

Each adapter is a separate module in apps/bridge/src/adapters/. Capability differs by agent because each one stores and accepts messages differently.

Adapter key

Display name

List

Read

Send

Create

Notes

hosted

Claude Code · Bridge 托管

full

full

✅

✅

Bridge owns the CLI process; approvals work end to end

claude-code

Claude Desktop · Code

partial

partial

✅

❌

Wakes the desktop app and injects a peer message

claude-code-cli

Claude Code · CLI

partial

partial

✅

❌

Running CLI via local socket, otherwise claude --resume -p

codex

ChatGPT Desktop · Codex

partial

partial

✅

❌

Only threads that are open in the app; native compact

codex-cli

Codex · CLI

partial

partial

✅

❌

codex queue when running, otherwise codex exec resume

antigravity

Antigravity CLI

partial

partial

✅

❌

Cannot send while the session is running

antigravity-desktop

Antigravity 桌面版

full

full

❌

❌

Read-only

dsh

DeepSeek Harness

partial

partial

✅

❌

Headless profile

"Partial" reflects the adapter's own capabilities declaration (Completeness = complete | partial | unknown | unavailable), not a bug: none of these agents publish a stable session API, so list and read may miss tool output, attachments or historical turns. See docs/GUIDE.md for the data source and send mechanism of each adapter.

Install

macOS 13 or newer, Apple Silicon and Intel in one universal build.

  1. Open AgentBridge.dmg.

  2. Drag AgentBridge.app into /Applications.

  3. Launch it. The app lives in the menu bar and has no Dock icon.

The bundle contains the bridge CLI, its compiled output and a Node runtime, so nothing else needs to be installed.

Release builds are signed and notarised only when the Apple secrets are configured. Otherwise macOS blocks the first launch. On macOS 15 or newer the right-click → Open shortcut is gone: dismiss the dialog, open System Settings → Privacy & Security and click "Open Anyway" at the bottom. On macOS 14 and earlier, right-click the app → Open. Either way this also works:

xattr -dr com.apple.quarantine /Applications/AgentBridge.app

From source

git clone https://github.com/gowinder/agent-bridge.git
cd agent-bridge
npm ci
npm run build:wasm -w @craftstead/crypto   # Rust Noise module → packages/crypto/wasm/noise.wasm
npm run build           # tsc -b across all workspaces
npm run check           # type check, including the web client
npm test                # build + node:test suite

build:wasm needs a Rust toolchain with the wasm32-unknown-unknown target:

rustup target add wasm32-unknown-unknown

Then either run the daemon directly (npm run bridge -- <command>) or build the menu bar app with npm run menubar (add AGENT_BRIDGE_ARCHS="arm64 x86_64" for a universal binary).

First run

The menu bar app does all of this for you; the CLI equivalents are shown for headless machines.

# 1. Create a room on the relay and write local state
npm run bridge -- init --relay https://agent-bridge.craftstead.app \
                        --web   https://agent-bridge.craftstead.app \
                        --name  "My Mac"

# 2. Run the daemon (the menu bar app does this itself)
npm run bridge -- serve

# 3. Mint a one-time invite, valid for 10 minutes
npm run bridge -- invite --ttl 600

init refuses a non-HTTPS relay unless it is a loopback address, and it health checks /v1/health before writing anything.

invite prints a link of the form:

https://agent-bridge.craftstead.app/#/pair?relay=…&room=…&invite=…

Open it on the phone. The pairing screen shows a 6-digit code; the same code is printed in the terminal (and shown in the menu bar app). Confirm it on both sides and name the device. The invite is single-use, and the room can hold any number of devices.

If a room was already claimed by a different Mac, the relay refuses the new bridge: the first bridge to claim a room id owns it (trust on first use), and replacing it requires clearing the room on the relay side.

Everyday use

The web client has three levels:

  • Clients (#/clients) — one card per installed agent, with live session counts.

  • Projects (#/clients/:appId/projects/:projectId) — sessions grouped by working directory.

  • Session (…/sessions/:sessionId) — the conversation, a context gauge, a message composer, attachments, and an optional task rail.

In a session you can read the transcript, send a message, answer an approval prompt, rename the session, request a native compact (or copy /compact when the agent has no native compact), and — if the Mac owner enabled remote devtools — browse project files and run a single shell command.

The rail shows the environment, the context window usage, MCP servers and background tasks where the adapter exposes them.

Hosted sessions

Hosted sessions are the only kind the browser can create. The bridge spawns claude itself:

claude -p --input-format stream-json --output-format stream-json --verbose \
       --permission-mode <mode> --permission-prompts host \
       --permission-prompt-tool stdio [--session-id|--resume] [--model]

Because the bridge owns the process's stdin, tool-permission questions arrive as real prompts in the chat with Allow / Deny buttons, and the answer goes back as a control_response. Transcripts are written to $AGENT_BRIDGE_HOME/hosted/.

Create the allowlist first (~/Library/Application Support/AgentBridge/hosted.json, or $AGENT_BRIDGE_HOME/hosted.json):

{
  "dirs": ["/Users/you/code/scratch"],
  "idleTimeoutMs": 1800000,
  "allowBypassPermissions": false
}
  • dirs — absolute paths, expanded and realpathed before comparison. Only these directories can be used as a hosted project. Restart the bridge after editing.

  • idleTimeoutMs — stop an idle process after this many milliseconds (default 30 minutes, minimum 60 s). Sending another message resumes the same CLI session.

  • allowBypassPermissions — default false. When true, hosted sessions may be started with bypassPermissions; when false that mode is rejected.

  • cliPath — optional; defaults to claude on PATH, then a search of ~/.local/bin, ~/.claude/local, /opt/homebrew/bin, /usr/local/bin.

Remote devtools

File browsing and shell execution are separate opt-in switches, both off by default, both with a TTL:

npm run bridge -- devtools                 # show status
npm run bridge -- devtools files on --ttl 3600
npm run bridge -- devtools terminal on --ttl 600
npm run bridge -- devtools files off
npm run bridge -- devtools terminal off

The file browser is read-only and confined to the session's project directory. The terminal runs one command at a time (max 8 concurrent), in its own process group, and the owning browser tab can cancel it.

CLI reference

agent-bridge init --relay <url> [--web <url>] [--name <name>]
agent-bridge invite [--ttl 30..600]
agent-bridge serve
agent-bridge devices [ttl manual|1h|24h|7d|30d]
agent-bridge revoke <deviceId>
agent-bridge devtools [files|terminal] [on|off|status] [--ttl 60..86400]
agent-bridge port [<port>]
agent-bridge status
agent-bridge info
agent-bridge --version

Command

Purpose

init

Create a room, generate the bridge token and Noise identity, write state.

invite

Mint a single-use pairing token (TTL 30–600 s, default 300) and print the link.

serve

Run the daemon: connect to the relay, dispatch sessions, serve the admin API.

devices

List paired devices, optionally change their expiry policy.

revoke

Revoke one device and close its live sockets.

devtools

Toggle the remote file browser and terminal, with a TTL.

port

Read or write the local admin port, then restart the daemon.

status / info

Human-readable state: relay, room, devices, uptime.

Per-device management is also available from the web client, but only for the device you are using; other devices are managed on the Mac.

Configuration

Setting

Default

Meaning

AGENT_BRIDGE_HOME

~/Library/Application Support/AgentBridge

State directory (database, identity, hosted transcripts, port file).

AGENT_BRIDGE_ADMIN_PORT

port file, else 47825 / 47826

Override the loopback admin port for one run.

AGENT_BRIDGE_ENV

inferred from relay host

preview or production; picks the default admin port.

AGENT_BRIDGE_CLAUDE_PATH

claude

Path to the Claude Code CLI used by hosted sessions.

State directory contents:

bridge.db          SQLite: devices, invites, push subscriptions, titles, events,
                   and the Noise static identity (identity_private / identity_public)
hosted.json        hosted-session allowlist and policy
hosted/            hosted transcripts (*.jsonl) and sessions.json
admin-port         loopback admin port for this state directory
admin-token        bearer token for the admin API (mode 0600)

The database is opened in WAL mode with a 3 s busy timeout, and the directory is created with mode 0700. Back up the state directory to keep devices paired; deleting it unpairs everything.

Security model

  • End-to-end encryption. Noise xxpsk3 for pairing, ik for reconnects. The relay forwards ciphertext and never holds a key.

  • Outbound only. The Mac opens the WebSocket; there is no listener, tunnel or port forward.

  • One-time invites. Only the SHA-256 hash of the token is stored on the relay; a used invite cannot be replayed. Invites expire in 30–600 s.

  • Human confirmation. A 6-digit code derived from both public keys must match on the Mac and in the browser before the device is registered.

  • Device identity. Each paired device is a Noise static key. Revocation is local and immediate — the relay closes the matching sockets.

  • Browser vault. Device metadata lives in localStorage in plain text, but the secret keys are AES-GCM encrypted with a PBKDF2-SHA256 key (600,000 iterations) derived from a user password, and stay unlocked for 30 minutes. The password never leaves the browser.

  • Loopback admin API. 127.0.0.1 only, Host must be a loopback name, no Origin header accepted, bearer token compared in constant time, token file mode 0600.

  • Rate limits. 40 WebSocket upgrades and 120 API requests per minute per IP on the relay.

  • Strict CSP on the web client: script-src 'self' 'wasm-unsafe-eval', connect-src https: wss:, frame-ancestors 'none'.

Limitations

These are properties of the current design, not bugs to be worked around:

  • Remote approval of a desktop session is unreliable by nature. Messages injected into a Claude Desktop or Claude Code session arrive as peer / cross-session input, so the agent may refuse to treat your "approve" as the user's own decision. Use a Bridge-hosted session when the workflow needs real approvals from the phone, or do the final step on the Mac. See REMOTE_APPROVAL.zh-CN.md.

  • Browsers can only create hosted sessions. Every other adapter attaches to sessions that already exist on the Mac.

  • Antigravity Desktop is read-only.

  • session.subscribe, session.unsubscribe, sync.resume, operation.get, turn.cancel and approval.respond are declared in the protocol but not dispatched by the bridge yet. The UI polls instead of subscribing to server-pushed events; only shell.output is emitted as a real event, and approval buttons are sent as ordinary messages.

  • The web client UI is Chinese only (zh-CN). There is no i18n layer.

  • The relay is a single Cloudflare Worker + Durable Object per room. Room data lives in that object; idle rooms are cleaned after 30 days, keeping only the claim anchors.

  • The relay is trusted for availability, not confidentiality. It can drop, delay or refuse traffic, and it learns room ids, timing and frame sizes.

  • Hosted sessions support Claude Code and pi. The hosted adapter speaks claude's stream-json control protocol and pi's RPC mode; other agents are mirrored from their desktop or CLI sessions.

  • Transcripts are not encrypted at rest. hosted/*.jsonl and bridge.db rely on macOS file permissions (0700/0600), not on disk encryption.

  • One bridge per room. A second Mac cannot take over a claimed room id.

Full detail, protocol reference and troubleshooting: docs/GUIDE.md.

MCP server

apps/mcp is a stdio MCP server that lets an agent running on another machine drive the pi / Claude Code sessions the bridge hosts on your Mac: open a session in an allowlisted directory, send work, read the reply, wait for the turn to finish, archive it. It is not a remote shell — it only touches the sessions it opened (or that the user adopts by name), maps none of the shell / filesystem / device protocol methods, and the relay still sees only ciphertext. Pairing is a one-time invite plus the same six-digit code comparison as the web client.

Install steps, the MCP host configuration snippet, the pairing walkthrough, a first-task example, the optional listener and troubleshooting are in apps/mcp/README.md.

The server ships on npm as @craftstead/agent-bridge-mcp (scoped to the same publisher as @craftstead/protocol and @craftstead/crypto); the packaged bin is still agent-bridge-mcp, and the MCP serverInfo name stays agent-bridge-mcp.

npx -y @craftstead/agent-bridge-mcp        # or: npm i -g @craftstead/agent-bridge-mcp

Running it from a clone (npm run mcp) works the same way.

Development

apps/bridge      Node daemon: relay client, session adapters, admin API, push
apps/relay       Cloudflare Worker + Durable Object `Room`
apps/web         Vite SPA / PWA (TypeScript, no framework)
apps/menubar     Swift AppKit menu bar app (LSUIElement)
apps/mcp         stdio MCP server that drives hosted sessions (Node, no build step)
packages/protocol  Wire types, method names, limits
packages/crypto    Noise handshakes, PSK derivation, chunked secure channel

Everyday commands:

npm run build        # tsc -b
npm run check        # tsc -b + web type check
npm test             # build + node:test
npm run web          # vite dev server for the web client
npm run relay:dev    # wrangler dev for the relay
npm run bridge -- serve
npm run mcp          # stdio MCP server (apps/mcp), for an MCP host to spawn
npm run test:mcp     # apps/mcp offline selftests

Branching and release rules are in AGENTS.md: develop deploys the preview relay, main deploys production, feature branches come from develop, and production deploys are gated on a version bump in the root package.json.

Deployment

.github/workflows/deploy.yml builds the wasm module, type checks, builds the web client and deploys with wrangler:

  • push to develop with a changed root version → wrangler deploy --env preview

  • push to main with a changed root version, or a vX.Y.Z tag on main matching the package version → production

  • prerelease tags are excluded from production

.github/workflows/release.yml builds the universal menu bar app, the DMG and its SHA-256, and publishes a GitHub Release on v*. Signing and notarisation run only when the Apple secrets are present. A prerelease tag (with a hyphen) may point at a commit on develop or main; a stable tag must be on main.

License

MIT

Available Tools

9 tools
bridge_statusA

只读:连接/设备/bridge 信息。返回本连接器设备身份(public 部分)、relay、配对时记录的 bridge 信息、device.list 自查结果与登记册概览。

Inputs: no named parameters.

session_adoptB

写:用户点名接管一个既有托管会话。先校验会话存在且在 bridge 侧是托管会话,再打 MCP 标签、写入登记册(参数 sessionId + purpose)。

Inputs: purpose (required), sessionId (required).

session_archiveB

写:归档登记册会话(hosted.archive),并在登记册里标记 archived。

Inputs: sessionId (required), archived.

session_listA

只读:只列登记册内会话,并附带各自在 bridge 侧的实时状态(busy/hosted/归档等)。未登记的会话不会出现在这里。

Inputs: includeArchived.

session_openA

get-or-create:按 (engine, cwd, purpose) 查登记册;命中且会话还在就复用,否则用 hosted.create 新建(非空启动偏好显式传;空值不传,交给 CLI 默认),自动打 MCP 标签、标题 MCP · ,并写入登记册。cwd 必须在 bridge 托管白名单内(远程设备不能 addDir)。

Inputs: cwd (required), purpose (required), model, title, +4 more.

session_readA

只读:读登记册会话最近 N 条消息 + busy 状态,返回消息全文(不摘要/不截断,超长按条数分页)。回合结束后若 pi 在提问,标出 needsUser 与原文。

Inputs: sessionId (required), limit, before.

session_sendA

写:给登记册会话发一条消息。带 operationId 幂等键(可传入复用:同一 operationId 已投递成功时不再重发);profile.promptSuffix 非空时在末尾追加该后缀(useSubagent=false 不加);写发送审计(只存哈希)。会话 busy 时直接报错,不排队不叠发。

Inputs: text (required), sessionId (required), operationId, useSubagent.

session_stopC

写:停掉登记册会话的托管进程(hosted.stop)。

Inputs: sessionId (required).

session_waitA

轮询到 busy 变 false 或超时(默认 120s,上限 600s),返回这期间的新消息(全文)与是否在等用户回答。用户从前端 stop/插话时如实返回,不自动续发。

Inputs: sessionId (required), limit, timeoutMs.

Tool Schema Changelog

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

Loading tool schema changelog…

    TDQS

    A3.6/5.0

    Scored across 9 tools

    Disambiguation4/5

    Most tools have clearly distinct purposes: read vs. send vs. wait vs. stop vs. archive are well-separated by action. The closest pair is session_open (get-or-create a new hosted session) and session_adopt (take over an existing hosted session), which share the 'register into registry' side effect but are distinguished by parameter shape and preconditions. session_read and session_wait also overlap slightly on returning messages, though wait's polling semantics are explicit.

    Naming Consistency4/5

    Eight of nine tools follow a strict noun_verb/session_<action> pattern (session_list, session_stop, session_open, session_read, session_wait, session_send, session_archive, session_adopt). bridge_status is the one deviation, using a different prefix and noun-first form, but it is still readable and clearly a singleton status tool.

    Tool Count5/5

    Nine tools is well-scoped for a session-bridge connector: one status tool plus a full session lifecycle. Each tool maps to a distinct operation with no filler or duplicate entry points.

    Completeness4/5

    The surface covers the full session lifecycle: discover (bridge_status, session_list), create/attach (session_open, session_adopt), interact (session_read, session_send, session_wait), and terminate (session_stop, session_archive). Minor gaps exist: no way to remove/unregister a session from the registry, and no update/rename of purpose or metadata after registration, which agents may need to work around.

    Maintenance

    ActivityMaintained
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      B
      maintenance
      A remote Streamable HTTP MCP server that lets web clients like Claude.ai and ChatGPT manage cloud machines with OAuth login — creating, starting, pausing and deleting machines, running commands, reading and writing files, managing snapshots and public ports, and driving an optional Linux desktop via screenshots and input actions. Long-running work can be backgrounded and operations polled, so browser-based clients stay within their timeouts.
      1
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      Exposes a single authenticated MCP endpoint that federates to agents running on your own machines, letting you delegate coding jobs to be worked in fresh git worktrees and pushed to a branch, or proxy the stdio MCP servers installed there as tools. Agents dial out through a Cloudflare Tunnel and enforce your local policy, so no inbound ports are opened.
      Apache 2.0