---
title: "cdp-mux and mcp-mux: one browser and one login for many agents"
date: 2026-12-03
url: "http://travisjeffery.com/cdp-mux-and-mcp-mux-one-browser-and-one-login-for-many-agents/"
tags: ["ai", "tools", "rust"]
agent:
  instructions: "Use this search API to find relevant content across this site with keywords or natural-language queries, instead of crawling individual pages. Results are returned in Markdown."
  endpoint: "https://travisjeffery.com/.well-known/search?q={query}"
  method: "GET"
  documentation: "https://developers.cloudflare.com/ai-search/how-to/search-for-agents/"
---

# cdp-mux and mcp-mux: one browser and one login for many agents

I run a lot of agents at once under [Quartermaster](http://travisjeffery.com/coordinating-many-agents-with-quartermaster/): a coordinator, a chat session I talk to, and many parallel workers, spread across Claude Code, Codex and pi. They all want the same two things. My signed-in browser, and the same remote MCP servers.

One agent sharing those is fine. A dozen is not. Every new DevTools connection asks me to approve remote debugging again. Every agent CLI runs its own OAuth flow for every MCP server, so I log in over and over. And when a server rotates refresh tokens, the clients race each other: one spends the refresh token, the next presents the now-dead one, gets `invalid_grant`, and asks me to log in again.

So I wrote two small Rust tools, one for each layer: [cdp-mux](https://github.com/travisjeffery/cdp-mux) for the browser and [mcp-mux](https://github.com/travisjeffery/mcp-mux) for remote MCP servers. They're separate tools for separate protocols. Neither is a superset of the other, and you can use either one alone.

## cdp-mux: one browser, many DevTools clients

`cdp-mux` holds one WebSocket to Brave, Chrome, Chromium or Edge and listens on `127.0.0.1:9333`. Any number of CDP clients (`chrome-devtools-mcp`, Playwright, Puppeteer, scripts) connect through it, so I approve remote debugging once.

- **No collisions.** It remaps JSON-RPC request IDs per client and routes each `sessionId` only to the client that attached it. When a client disconnects, it detaches that client's sessions and disposes the browser contexts it created.
- **No closing my browser.** `Browser.close` is answered locally with `{}`, so an exiting script can't quit it.
- **No focus stealing.** With `--no-focus`, new tabs open in the background and `Target.activateTarget` and `Page.bringToFront` become no-ops.
- **Tabs agents can't see.** Repeatable `--exclude-url` and `--include-url` regexes hide targets from listing, events and attaching, so my email stays out of reach.

## mcp-mux: one login per server, many MCP clients

`mcp-mux` holds one OAuth grant per remote Streamable HTTP MCP server and exposes each one at `http://127.0.0.1:9444/<name>/mcp`. Clients send a static local token; `mcp-mux` injects the upstream access token and streams responses straight through.

- **One login per server.** `mcp-mux login <name>` does discovery, dynamic client registration and PKCE once. Every client shares the result.
- **No refresh races.** Refreshes run one at a time per server, under an in-process mutex and a cross-process file lock, so a rotating refresh token is spent exactly once. A request that gets a `401` is retried once with the new token, often without touching the token endpoint because another request already rotated it.
- **Proactive refresh.** Tokens refresh 5 to 10 minutes before they expire, with backoff on network errors and `5xx` responses.
- **Clear failures.** A rejected grant marks that server `needs_login` in `/mcp-mux/status` and stops refreshing it. The other servers keep working.

## How I run them

Both run as `systemd --user` services. `mcp-mux` fronts about ten remote MCP servers, and Claude Code, Codex and pi all point at its local URLs with the same token. `cdp-mux` runs with `--no-focus` in front of my everyday browser, and `chrome-devtools-mcp` connects to it instead of to the browser.

Now a new worker starts and has the browser and every tool immediately. No approval dialog, no login, no tab jumping to the front while I'm typing, and no worker invalidating another's token.

Both proxies share the same localhost posture: they bind `127.0.0.1` only, reject non-loopback `Host` headers with `421` and any `Origin` header with `403`, require a local bearer token by default, and can write a metadata-only JSONL audit log with `--log`.

## When to use them

Use `cdp-mux` when several agents or scripts need your real, signed-in browser. Skip it for clean, repeatable automation like end-to-end tests or scraping; headless Playwright with its own profile is simpler and safer.

Use `mcp-mux` when more than one MCP client talks to the same OAuth-protected remote server, especially one that rotates refresh tokens. With one client and one server, the client's own OAuth is fine.

Both are MIT licensed and build with `cargo install --path .` on Rust 1.85+: [travisjeffery/cdp-mux](https://github.com/travisjeffery/cdp-mux) and [travisjeffery/mcp-mux](https://github.com/travisjeffery/mcp-mux).
