Skip to main content
Glama
README.md
# codex-desktop-mcp

An MCP server that lets other agents work with the Codex chats in the **ChatGPT desktop app on your Mac**: list and read conversations, start new chats in your projects, send follow-ups, pick the model, reasoning effort, and speed, steer or interrupt running work, and answer approvals. It runs locally and can be exposed to the internet behind bearer tokens, so a remote agent can monitor and drive your Codex work.

New chats and follow-ups run inside the desktop app by default, with the model, effort, and speed you asked for, so you can watch them and type in them without the “This is open in another app” lock.

It also works with **OpenCodex**, an optional local proxy that lets Codex use several subscriptions (for example Anthropic Claude and OpenAI accounts) and rotates between them. When OpenCodex is installed, the tools show which provider and account serve each chat, every account's quota, how OpenCodex rotates them, and the usage valued at API prices, and an agent can pick the active account. Without OpenCodex everything else works the same. See [OpenCodex](#opencodex-optional).

> **Unofficial.** Not affiliated with OpenAI. It combines the Codex app-server protocol with the desktop app's `codex://` links (and, on app versions before 26.1120, its internal IPC channel). These can change when the app updates. Run `codex-desktop-mcp doctor` after updating the app.

## How it works

```mermaid
flowchart LR
  Agent["Remote agent or MCP client"] -->|"HTTPS + bearer token"| Tunnel["Tunnel or reverse proxy"]
  Tunnel --> MCP["codex-desktop-mcp\n127.0.0.1:8723/mcp"]
  MCP -->|"codex://threads/wake/…"| App["ChatGPT desktop app\nruns queued messages"]
  MCP -->|"stdio JSON-RPC"| Engine["codex app-server\nbundled with ChatGPT.app"]
  App --> Store[("~/.codex\nchats, projects, config")]
  Engine --> Store
```

The bridge routes each request to the right place:

- **New chats and follow-ups** run through the desktop app by default. For a new chat, the bridge creates it, saves the model, reasoning effort, and speed in it, and releases its writer lock. It then adds the message to the chat's queue (`thread/queue/add`) and opens `codex://threads/wake/<id>`, which makes the app send the queued message itself. If the chat is busy, the message waits in the queue and the app sends it when the current turn ends. The bridge never resends a queued message.
- **Listing, history, and the model catalog** use a private `codex app-server` with the same `~/.codex` storage. It does not run the default chat turns.
- **Explicit headless runs** use `execution: "background"` on `create_chat` or `send_message`. This mode remains useful when no desktop session is available, and it is the only one where the bridge can steer, interrupt, or answer approvals.

Codex lets only one process write to a chat at a time. Default app execution keeps that owner inside the desktop app. Explicit background execution still locks its chats until the runner's last active turn finishes and the runner exits. If a new chat's prompt cannot be queued, the empty chat is archived and the call fails; the bridge never silently falls back to a headless turn.

**A Mac you use from another Mac over SSH or Remote:** the Codex app on your other Mac talks to this Mac's `codex app-server` daemon, while app delivery hands chats to the ChatGPT app running on this Mac. That app then owns them, and your other Mac shows "This is open in another app". Start the server with `--daemon` (`codex-desktop-mcp service install --daemon` saves it): new chats and follow-ups then run in the daemon, through its control socket `~/.codex/app-server-control/app-server-control.sock`, so the Codex app connected over SSH or Remote shows them live and you can type in them. Chats already loaded by the ChatGPT app on this Mac stay locked until that app releases them, for example when it quits.

In daemon mode the server reads every chat's live state from the daemon, including chats started from a Codex app: `list_chats` marks running chats, and `get_chat_status`, `wait_for_chat`, steering, and `interrupt_chat` work on any of them. `send_message` on a busy chat queues the message by default (`action: "queued"` with its `position`); `whenBusy: "steer"` adds it to the running turn and `"interrupt"` stops the turn first. Queued messages go into the daemon's own queue: the Codex apps show them, the daemon sends them as turns end, and they survive restarts of this server and of the daemon. The server also watches the chats it queued for (listed in `daemon-queue.json` in its config folder) and starts a message that is still waiting once the chat is idle.

**Upgrading from chatgpt-desktop-mcp (0.8 and earlier):** the project is now called codex-desktop-mcp: the command, the npm package, the GitHub repository (the old address redirects), the MCP server name, the LaunchAgents (`com.codex-desktop-mcp.*`), the logs folder, and the environment variables (`CODEX_DESKTOP_MCP_*`). Existing setups keep working: the old `CHATGPT_DESKTOP_MCP_*` variables are still read, and an existing `~/.config/chatgpt-desktop-mcp` folder, with its tokens and machines, is used until `~/.config/codex-desktop-mcp` exists. Tokens and URLs do not change. To switch over, install the new package, move the config folder if you like (`mv ~/.config/chatgpt-desktop-mcp ~/.config/codex-desktop-mcp`), run `codex-desktop-mcp service install`, which replaces the old LaunchAgents with the new ones, then `npm uninstall -g chatgpt-desktop-mcp`.

**Upgrading from 0.4:** ChatGPT 26.1120 removed the IPC router that 0.4 used to hand chats to the app. 0.4 then created empty chats that showed the app's default model. 0.5 delivers through the chat queue instead. `send_message` accepts `whenBusy: "queue"` and can return `action: "queued"`. Steer and interrupt only work for background runs; changing the model of a chat loaded in the app is refused.

**Upgrading from 0.3:** `app` is now the default execution mode. It uses the permissions selected in the desktop app. Explicit `sandbox` / `approvalPolicy` arguments or operator-enforced overrides require `execution: "background"` when creating a chat. `create_chat` returns `deliveredVia` and `turnStarted`; an app-started turn may have `turnId: null`, and `wait: true` still waits for it.

## Requirements

- macOS with the ChatGPT desktop app and Codex. App execution needs a logged-in desktop session and an app-server supporting `thread/queue/*` and `thread/settings/update` (ChatGPT 26.1120 or later).
- Node.js 22 or newer.
- Optional: [`cloudflared`](https://developers.cloudflare.com/cloudflare-one/connections/connect-networks/downloads/) for a public URL (`brew install cloudflared`). A fixed URL also needs a domain on Cloudflare.

## Install

```sh
npm install -g https://github.com/kevinrss01/codex-desktop-mcp/tarball/main
codex-desktop-mcp doctor
```

The compiled CLI is committed in `dist/`, so installing from GitHub needs no build step. To pin a release, replace `main` with a tag such as `v0.3.0`. From a clone: `npm install && npm link`.

## Quick start

```sh
# 1. Create a token. It is printed once; only its SHA-256 digest is stored.
codex-desktop-mcp token create --name my-agent --scope control

# 2. Serve MCP on http://127.0.0.1:8723/mcp
codex-desktop-mcp serve

# Or also publish it on a temporary public HTTPS URL
codex-desktop-mcp serve --tunnel
```

Every request needs `Authorization: Bearer <token>`. Tokens have one of two scopes:

| Scope | Tools |
| --- | --- |
| `read` | `list_machines`, `list_models`, `list_projects`, `list_chats`, `read_chat`, `get_chat_status`, `wait_for_chat`, `wait_for_chats`, `overview`, `get_usage`, `list_pending_requests` |
| `control` | Everything in `read`, plus `create_chat`, `send_message`, `interrupt_chat`, `rename_chat`, `archive_chat`, `respond_to_request`, `switch_account` |

Manage tokens with `codex-desktop-mcp token list` and `codex-desktop-mcp token revoke <id-or-name>`.

## Connect an agent

**Claude Code**

```sh
claude mcp add --transport http codex-desktop https://YOUR-HOST/mcp --header "Authorization: Bearer $CDM_TOKEN"
```

**Codex CLI** (`~/.codex/config.toml`)

```toml
[mcp_servers.codex_desktop]
url = "https://YOUR-HOST/mcp"
bearer_token_env_var = "CDM_TOKEN"
```

**OpenAI Responses API**

```js
const response = await openai.responses.create({
  model: 'gpt-6.1-sol',
  input: 'Check my Codex chats and summarize what is still running.',
  tools: [
    {
      type: 'mcp',
      server_label: 'codex_desktop',
      server_url: 'https://YOUR-HOST/mcp',
      headers: { Authorization: `Bearer ${process.env.CDM_TOKEN}` },
      require_approval: 'never',
    },
  ],
});
```

**Local stdio clients** (no token; the client launches the server):

```json
{ "mcpServers": { "codex-desktop": { "command": "codex-desktop-mcp", "args": ["stdio"] } } }
```

Add `"--read-only"` to the args for a monitoring-only setup. ChatGPT custom connectors require OAuth, which this server does not implement yet.

To try tools from a terminal: `CDM_URL=http://127.0.0.1:8723/mcp CDM_TOKEN=... node scripts/call-tool.mjs list_chats '{"limit":5}'`.

## Tools

| Tool | What it does |
| --- | --- |
| `list_machines` | The Macs this endpoint can reach, whether each is available, its access level, and its OpenCodex state. See [Several Macs](#several-macs-behind-one-endpoint). |
| `list_models` | Models Codex can use, with their reasoning efforts and speed tiers. Each model names its `provider` (`openai`, `anthropic`, …) and `via`: `opencodex` when OpenCodex serves it, `codex` for the Codex sign-in. With OpenCodex, `providers` shows each provider's accounts, how many can take work, and the active one. |
| `list_projects` | Projects saved in the app, plus folders used by recent chats. |
| `list_chats` | Chats sorted by last activity; filter by project, search text, or archived state. |
| `read_chat` | The latest turns of a chat in order: messages, plus one-line summaries of commands, edits, and tool calls. Page back with `olderCursor`. |
| `get_chat_status` | Whether the chat is running, since when, and where (`app`, `bridge`, `daemon`, or `stored`), its model, effort, and speed, pending approvals, queued messages, how full its context window is (`context.usedPercent`), and the latest assistant message. With OpenCodex, `openCodex` names the account and model that served its latest request, with failed requests, fallbacks, and estimated cost. |
| `wait_for_chat` | Waits until the chat stops running (up to 300 s), then returns its status. |
| `wait_for_chats` | Waits until one (`mode: "any"`) or every (`"all"`) of up to 20 chats is done, to follow several agents at once. |
| `overview` | One call to see every agent: chats that are working, waiting for an approval or answer, queued, failed, or active in the last hours, with their model, running time, last message, context use, and, with OpenCodex, the provider and account serving them. Covers every Mac unless `machine` is given. |
| `get_usage` | Capacity left. `summary` gives the gist in a few lines; `codexAccount` has the Codex sign-in's limits, reset times, and credits. With OpenCodex, `openCodex` tells whether it routes Codex, how it rotates accounts, and the usage over `period` (`today`, `7d`, `30d`) valued at API prices, and `openCodexAccounts` lists every account with its quota windows, including per-model weekly limits. With `chatId`, also that chat's context use, estimated cost, and serving account. |
| `create_chat` | Starts a chat in a project (or a new folder under `~/Documents/Codex/<date>/`, as the app does) with an optional first prompt, model, effort, speed, sandbox, and approval policy. |
| `send_message` | Sends a follow-up. If the chat is busy, `whenBusy` chooses to reject, queue it after the current turn, steer, or interrupt. In daemon mode it queues by default, and steer and interrupt work for every chat; otherwise they only work for background runs. |
| `interrupt_chat` | Stops the running turn. |
| `rename_chat`, `archive_chat` | Retitle, archive, or restore a chat. |
| `list_pending_requests`, `respond_to_request` | See and answer command, file, question, and MCP approval requests from chats the bridge runs. |
| `switch_account` | With OpenCodex: makes one account the active one for a provider, by label or id. OpenCodex already moves on by itself near the limit, so this is for deliberate choices, such as keeping an account free. Running chats move on their next request. |

**Model, effort, and speed.** `list_models` returns valid values. `speed` accepts `standard`, a tier id such as `priority` or `ultrafast`, or a tier name such as `Fast`. They are saved in the chat before the app opens it. A chat that the app currently has loaded keeps its settings; change them in the app.

A typical monitoring loop: `list_chats` to see what changed, `get_chat_status` for live state, `wait_for_chat` until a run ends, then `read_chat` for the transcript.

## OpenCodex (optional)

OpenCodex is a local proxy in front of Codex. It injects its address in `~/.codex/config.toml`, so Codex sends every model request through it. OpenCodex then serves models from several providers and spreads requests over several accounts of each provider, moving to another account when one nears its limit. The bridge does not need it, and it never changes how chats are created, queued, or run. When OpenCodex is installed, the bridge reads it through its CLI, `ocx`, and the tools show what it does:

```mermaid
flowchart LR
  Agent["Agent"] --> MCP["codex-desktop-mcp"]
  MCP -->|"chats"| Engine["Codex engine"]
  Engine -->|"model requests"| OCX["OpenCodex proxy"]
  OCX --> A1["Anthropic account 1"]
  OCX --> A2["Anthropic account 2"]
  OCX --> O1["OpenAI account"]
  MCP -.->|"ocx: accounts, quotas, request log, spend, switch"| OCX
```

| Question an agent asks | Where the answer is |
| --- | --- |
| Does OpenCodex serve this Mac's chats? | `get_usage` → `openCodex.routesCodex` and `problem`; `list_machines` → `openCodex` for every Mac |
| Which provider serves a model? | `list_models` → `provider` and `via` for each model |
| Which account serves this chat, did it fail over, what did it cost? | `get_chat_status` → `openCodex`; `overview` → `provider` and `account` for every agent |
| How much quota is left on each account, and which ones can take work? | `get_usage` → `summary` and `openCodexAccounts` (`usable`, quota windows, per-model weekly limits) |
| How does OpenCodex pick and switch accounts? | `get_usage` → `openCodex.rotation` (strategy and switch threshold) |
| How much was used? | `get_usage` → `openCodex.spend`: requests and tokens valued at API prices, by provider and top models, for `today`, `7d`, or `30d`. Subscriptions are flat-rate, so this is a value, not a bill. |
| Use another account now | `switch_account` (control tokens) |

How it works and what to expect:

- **Detection.** The bridge looks for `ocx` in `/Applications/OpenCodex.app/Contents/MacOS/`, `~/.opencodex-desktop/bin/`, `/opt/homebrew/bin/`, `/usr/local/bin/`, and `~/.local/bin/`. Set `CODEX_DESKTOP_MCP_OPENCODEX=off` to ignore OpenCodex, or to the path of `ocx` if it lives elsewhere. Set it before `service install` so the background server uses it. When OpenCodex is missing, `get_usage` says so in its summary, `list_models` reports `via: "codex"`, and `switch_account` explains that there is nothing to switch.
- **Matching chats to accounts.** OpenCodex logs each request with a hash of the Codex chat id and a tag of the account that served it. The bridge matches both, so it names the account without reading any email address. Accounts appear under the labels OpenCodex shows: an alias you set, or a masked email. `get_chat_status` also counts the chat's recent failed requests and fallbacks, and `recent.accounts` shows when OpenCodex moved it to another account. OpenCodex keeps only its most recent requests, so a chat that has been quiet for a long time may show no account.
- **Freshness.** Quotas, rotation, and usage are cached for 30 seconds to 5 minutes, and request logs for 15 seconds, so dashboards stay cheap. Pass `refresh: true` to `get_usage` to ask the providers for fresh quotas.
- **Several Macs.** Each Mac reports its own OpenCodex. Pass `machine` to `get_usage` or `switch_account` to read or change another Mac's accounts.
- **Compatibility.** The bridge reads the JSON output of `ocx` (tested with OpenCodex 2.100). If a future version changes it, the OpenCodex fields go missing and every other tool keeps working.

## Exposing it safely

A control token lets the holder make Codex run commands on your Mac with the permissions in your Codex configuration. Treat it like SSH access.

- The server listens on `127.0.0.1` by default. Publish it through a TLS tunnel or reverse proxy; do not bind it to a public interface.
- `serve --tunnel` starts a Cloudflare quick tunnel. Its URL is random and changes on every start, which suits testing. For a fixed address on your own domain, use `service install` below.
- Give monitoring agents `read` tokens. Revoke tokens you no longer use.
- Requests carrying a browser `Origin` header are rejected unless allowed with `--allow-origin`, which also enables CORS for that origin. Repeated failed authentication from one client returns 429.
- To restrict chats the bridge starts or resumes, run with `--sandbox workspace-write --approval-policy on-request` and answer approvals with `respond_to_request`. Callers cannot loosen these settings through tool arguments. Chats open in the app keep the app's own settings.

## Keep it running on your own URL

`service install` keeps the server running in the background with macOS LaunchAgents. It starts at login, restarts after a crash, and a watchdog checks it every two minutes. Choose how other agents reach it:

| Setup | Command | What you need |
| --- | --- | --- |
| Your own domain through Cloudflare (recommended) | `service install --hostname mcp.yourdomain.com` | A domain on Cloudflare (the free plan works) and `cloudflared` |
| Your own tunnel or proxy | `service install --public-url https://your-url` | Tailscale Funnel, ngrok, Caddy, nginx, or anything that forwards HTTPS to `http://127.0.0.1:8723` |
| This Mac only | `service install` | Nothing else; local clients use `http://127.0.0.1:8723/mcp` |

Then create a token for each agent with `codex-desktop-mcp token create --name <agent>` and check everything with `codex-desktop-mcp service status`.

### Your own domain through Cloudflare

```sh
brew install cloudflared
cloudflared tunnel login        # pick the domain that will hold the hostname
codex-desktop-mcp service install --hostname mcp.yourdomain.com
codex-desktop-mcp token create --name my-agent
```

Agents connect to `https://mcp.yourdomain.com/mcp`. Install creates a named tunnel in your Cloudflare account (`codex-desktop-mcp` unless you pass `--tunnel-name`), adds a DNS record for the hostname, and forwards only that hostname to the local server. It stops before touching DNS if the domain does not use Cloudflare nameservers, and it never replaces an existing record unless you pass `--overwrite-dns`.

The certificate from `cloudflared tunnel login` covers one domain. If you have several, log in again for the domain you want or set `TUNNEL_ORIGIN_CERT=/path/to/cert.pem` before running install.

### Your own tunnel or proxy

Run your tunnel so it forwards to `http://127.0.0.1:8723`, then tell the service its URL. With Tailscale Funnel, for example:

```sh
tailscale funnel --bg 8723
codex-desktop-mcp service install --public-url https://my-mac.your-tailnet.ts.net
```

The service keeps the MCP server running and checks the public URL, so `service status` shows when it is down. Keeping the tunnel or proxy itself running is up to that tool.

### Options

Install saves its settings in `~/.config/codex-desktop-mcp/service.json`. Running `service install` again, for example after upgrading Node or this package, reuses them; any option you pass replaces the saved value.

| Option | Default | Effect |
| --- | --- | --- |
| `--hostname <host>` | none | Publish on your domain through a named Cloudflare tunnel. |
| `--tunnel-name <name>` | `codex-desktop-mcp` | Cloudflare tunnel to create or reuse. |
| `--tunnel-credentials <file>` | none | Run a tunnel created on another Mac; see [A second Mac](#a-second-mac-without-a-cloudflare-login). |
| `--overwrite-dns` | off | Replace an existing DNS record for the hostname. |
| `--skip-zone-check` | off | Skip the check that the domain uses Cloudflare DNS. |
| `--public-url <url>` | none | Use a tunnel or proxy you run yourself. The service monitors it. |
| `--local-only` | | Remove the saved hostname or public URL. |
| `--port <number>` | `8723` | Local port. |
| `--keep-awake <mode>` | `ac` | `ac` blocks idle sleep on AC power, `always` also on battery, `off` leaves sleep to macOS. |
| `--open-app`, `--no-open-app` | open | Open the ChatGPT app in the background at login. |
| `--sandbox`, `--approval-policy`, `--workspace-root`, `--codex-bin`, `--allow-origin` | your Codex settings | Passed to the background server, as with `serve`. |
| `--reset` | | Ignore the saved settings and start from the defaults. |

If you set `CODEX_DESKTOP_MCP_CONFIG_DIR`, `CODEX_HOME`, `CODEX_DESKTOP_MCP_CODEX_BIN`, `CODEX_DESKTOP_MCP_NEW_CHAT_MACHINE`, or `CODEX_DESKTOP_MCP_OPENCODEX` when running install, the background agents use the same values. Each macOS user can run one service.

### What runs in the background

LaunchAgents live in `~/Library/LaunchAgents` and write logs to `~/Library/Logs/codex-desktop-mcp`:

| Agent | What it does |
| --- | --- |
| `server` | Runs `serve` on 127.0.0.1 and restarts it if it exits. |
| `tunnel` | With `--hostname`, runs the named tunnel. `cloudflared` reconnects by itself after network drops. |
| `watchdog` | Every 2 minutes, restarts the server if `/healthz` stops answering, and restarts the tunnel if the public URL fails twice in a row while the Mac is online. |
| `keepawake` | Runs `caffeinate` according to `--keep-awake`. |
| `openapp` | Opens the ChatGPT app in the background at login so open chats can be controlled live. |

`service uninstall` removes the agents and keeps the Cloudflare tunnel and DNS record; delete those with `cloudflared tunnel delete <name>` and the Cloudflare dashboard.

### macOS folder permissions

macOS asks before a background process reads Documents, Desktop, Downloads, iCloud Drive, or external drives. New chats go in `~/Documents/Codex` by default, and your projects may live in those folders, so the background server checks access when it starts and macOS shows a prompt for `node`. Click **Allow**. To cover every folder at once, add the node binary shown by `service status` to System Settings › Privacy & Security › Full Disk Access. Upgrading Node can reset this permission.

`service status` reports whether the server can read the chat folder. Install the package itself outside those folders, as a global npm install does; a copy inside Documents cannot start in the background until `node` is allowed there.

### What it survives

- **Network drops and Wi‑Fi changes:** the tunnel reconnects and the URL does not change.
- **Crashes and hangs:** launchd restarts the server and tunnel within about 10 seconds, and the watchdog restarts a process that stops answering.
- **Restart or shutdown:** everything starts again once you log in. With FileVault on, macOS waits for your password at boot, so the URL is down until then. To power back on after a power cut, run `sudo pmset -a autorestart 1`.
- **Sleep:** a sleeping Mac cannot answer. `--keep-awake` prevents idle sleep; on battery only with `always`.
- **Closing the lid:** the Mac sleeps unless it is in clamshell mode (power plus an external display). `sudo pmset -a disablesleep 1` keeps it awake with the lid closed; undo with `sudo pmset -a disablesleep 0`. A closed, awake laptop runs warm, so do not put it in a bag.
- **The ChatGPT app:** listing and reading work without it. App execution launches it if needed; a message the app has not picked up stays queued and returns `action: "queued"`.

For an address that stays up while your laptop is off, run the bridge on an always-on Mac, such as a Mac mini, and point your agents there.

## Several Macs behind one endpoint

Run the bridge on each Mac, then register the other Macs on the one your agents connect to. Every tool gains a `machine` argument, and `list_machines` shows which Macs are reachable, so an agent can pick where to start a chat or follow one on any machine.

```sh
# On the Mac mini: run the service and create a token for the endpoint that will reach it
codex-desktop-mcp service install --hostname mini-mcp.example.com
codex-desktop-mcp token create --name laptop-endpoint

# On the Mac your agents connect to
codex-desktop-mcp machine name laptop
codex-desktop-mcp machine add mini --url https://mini-mcp.example.com/mcp   # paste the token at the prompt
codex-desktop-mcp machine list
```

```text
laptop           available   this Mac, control access, ChatGPT app open, v0.8.0, OpenCodex not installed
mini             available   https://mini-mcp.example.com/mcp, control access, ChatGPT app closed, v0.8.0, OpenCodex v2.100.12, proxy running, routes Codex, 180 ms
```

Agents then pass `machine` to any tool:

| Value | Runs on |
| --- | --- |
| omitted, `local` | The Mac serving the endpoint |
| a name such as `mini` | That Mac |
| `auto` | The first available Mac in the order shown by `machine list`; change it with `machine prefer <name>` |
| `all` | Every Mac, for `list_chats` and `list_pending_requests`; results are merged and each item names its machine |

Results from a routed call include `machine`, so the agent knows where a chat lives. `list_machines` reports, for each Mac, whether it answers, whether the endpoint can control it or only read it, its version, whether its ChatGPT app is open for live control, and whether OpenCodex routes its Codex.

Tools that take a `chatId` find the chat by themselves when `machine` is omitted: they go to the Mac where the chat was created or last seen, and otherwise try each reachable Mac in turn. Set `CODEX_DESKTOP_MCP_NEW_CHAT_MACHINE` (for example `auto`) when installing the service to choose where `create_chat`, `list_projects`, and `list_models` go when `machine` is omitted. Both `effort` and `reasoningEffort` are accepted.

Machines are managed only from the command line, never through MCP. Tokens for other Macs are stored in `~/.config/codex-desktop-mcp/machines.json` with owner-only permissions. A few ways to limit what the endpoint can do:

- Give it a `read` token from the other Mac, or add the Mac with `--read-only`. Only read tools are forwarded to it.
- Agents holding a `read` token on the endpoint can only read, on every Mac.
- To make both Macs entry points, register each on the other. Forwarded calls always run on the receiving Mac, so they never loop.

### A second Mac without a Cloudflare login

A tunnel can run on a Mac that is not logged in to Cloudflare. Create it on a Mac that is, then copy its credentials file:

```sh
# On the Mac logged in to Cloudflare
cloudflared tunnel create mini-mcp
cloudflared tunnel route dns mini-mcp mini-mcp.example.com
# copy ~/.cloudflared/<tunnel-id>.json to the other Mac, then on that Mac:
codex-desktop-mcp service install --hostname mini-mcp.example.com --tunnel-credentials ./<tunnel-id>.json
```

Install copies the file into the config folder, so you can delete the copy you transferred.

## Limitations

- macOS only. App delivery relies on the app's `codex://threads/wake` link and may need an update after a ChatGPT release. Use explicit background execution if desktop delivery is unavailable.
- The bridge waits up to 30 seconds for the app to pick up a queued message. Without live control, a turn the app runs is detected from stored history (a turn with no completion time), so a crashed turn can look like it is still running.
- Explicit background turns still prevent desktop input until the runner releases them. Existing background turns are not moved or interrupted by an app handoff for another chat.
- Renaming or archiving a chat that the app currently has loaded is refused; do it in the app.
- Approvals for runs inside the app are answered in the app; `get_chat_status` shows that one is waiting.
- Messages are text only. Regular ChatGPT conversations outside Codex are stored in your ChatGPT account, not in `~/.codex`, and are not covered.

## Development

```sh
npm install
npm test          # unit and protocol tests (no app needed)
npm run build     # rebuild dist/ and commit it with your change
node dist/cli.js serve --verbose
```

The tests cover machine routing between two in-process servers, the IPC framing and a fake desktop router, the shared Codex engine and its message queue, the OpenCodex integration against a fake `ocx` (and the same tools without it), token storage, model option resolution, history formatting, live-state parsing, and HTTP authentication and scopes through a real MCP client.

## License

[MIT](LICENSE)