You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: client mode with Claude Desktop support via mitmproxy
Add a "client mode" so users can connect Claude Code (and optionally
Claude Desktop) to a remote CC-Router instance without hosting accounts
locally. The setup wizard now asks up-front whether to host or connect.
Claude Desktop does not honor ANTHROPIC_BASE_URL, so its traffic is
redirected via mitmproxy in local mode — a process-scoped interceptor
that rewrites api.anthropic.com requests to the proxy. The server auth
middleware now accepts x-api-key as an alternative to Bearer, matching
what the Anthropic SDK (embedded in Claude Desktop) sends.
- New `cc-router client {connect,disconnect,status,start-desktop,stop-desktop}` commands
- New interceptor module: mitmproxy manager + redirect addon
- Config schema: ProxyConfig.client with remoteUrl/remoteSecret/desktopEnabled
- Setup wizard: "Host vs Connect" first step, Desktop opt-in at the end
- README: Client mode + Claude Desktop support sections
- server.ts: auth middleware accepts x-api-key (backward-compatible)
Copy file name to clipboardExpand all lines: README.md
+138-5Lines changed: 138 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,11 +17,12 @@ Distribute Claude Code requests across N subscriptions to multiply your throughp
17
17
## How it works
18
18
19
19
```
20
-
Claude Code (terminal)
21
-
│
22
-
│ ANTHROPIC_BASE_URL=http://localhost:3456
23
-
│ ANTHROPIC_AUTH_TOKEN=proxy-managed
24
-
▼
20
+
Claude Code (terminal) ─┐
21
+
│ ANTHROPIC_BASE_URL=http://localhost:3456
22
+
│
23
+
Claude Desktop ─[mitmproxy]─┐ (optional — intercepts api.anthropic.com)
24
+
│
25
+
▼
25
26
┌─────────────────────────────────────┐
26
27
│ CC-Router :3456 │
27
28
│ │
@@ -41,6 +42,8 @@ Claude Code (terminal)
41
42
42
43
All standard Claude Code features work transparently: streaming, extended thinking, tool use, prompt caching.
43
44
45
+
**Claude Desktop support** is opt-in and requires a small interceptor (mitmproxy) because Claude Desktop doesn't expose a custom API endpoint setting. See [Claude Desktop support](#claude-desktop-support).
cc-router docker up Start full Docker stack (cc-router + LiteLLM)
284
294
cc-router docker up --build Rebuild cc-router image before starting
285
295
cc-router docker down Stop Docker containers
@@ -321,6 +331,129 @@ See [docs/litellm-setup.md](docs/litellm-setup.md) for details.
321
331
322
332
---
323
333
334
+
## Client mode — connecting to an existing CC-Router
335
+
336
+
If someone on your team already hosts a CC-Router instance (on a VPS, home server, or another machine on the LAN), you don't need to install accounts locally. You just point your Claude Code at the remote proxy.
337
+
338
+
The setup wizard asks about this at the very first step:
339
+
340
+
```bash
341
+
cc-router setup
342
+
# → What do you want to do?
343
+
# • Host CC-Router on this machine
344
+
# • Connect to an existing CC-Router server ← pick this
345
+
```
346
+
347
+
Or use the dedicated command directly:
348
+
349
+
```bash
350
+
# Quick connect — just point Claude Code at the remote proxy
Client mode writes `ANTHROPIC_BASE_URL` and `ANTHROPIC_AUTH_TOKEN` into `~/.claude/settings.json`, so Claude Code talks directly to the remote proxy. Nothing runs locally — no accounts, no proxy process, no resources.
361
+
362
+
### CLI reference
363
+
364
+
```text
365
+
cc-router client connect <url> Connect Claude Code to a CC-Router server
366
+
cc-router client connect --desktop Also configure Claude Desktop interception
367
+
cc-router client connect -s <secret> Pass the proxy secret inline (or use --secret)
368
+
cc-router client disconnect Revert all client configuration
369
+
cc-router client status Show current connection + remote server health
370
+
cc-router client start-desktop Start the Claude Desktop mitmproxy interceptor
371
+
cc-router client stop-desktop Stop the Claude Desktop interceptor
372
+
```
373
+
374
+
---
375
+
376
+
## Claude Desktop support
377
+
378
+
Claude Desktop (chat + Cowork) **can be routed through CC-Router**, but unlike Claude Code it does not respect `ANTHROPIC_BASE_URL`. It talks directly to `api.anthropic.com` via an embedded Anthropic SDK. To redirect its traffic, CC-Router uses [mitmproxy](https://mitmproxy.org/) in *local redirect mode* — a process-scoped interceptor that only captures Claude Desktop's network traffic and forwards it to the proxy.
379
+
380
+
This is **opt-in** — the setup wizard will ask if you want it.
- Admin access to install the mitmproxy CA certificate
386
+
- On macOS: manual approval of mitmproxy's Network Extension (one time, via System Settings)
387
+
388
+
### Installing mitmproxy
389
+
390
+
```bash
391
+
# macOS
392
+
brew install mitmproxy
393
+
394
+
# Windows
395
+
# Download the installer from https://mitmproxy.org/downloads/
396
+
# (or: pip install mitmproxy)
397
+
398
+
# Linux
399
+
pip install mitmproxy # kernel 6.8+ required for local mode
400
+
```
401
+
402
+
### Enabling Desktop interception
403
+
404
+
During `cc-router setup` or `cc-router client connect`, answer **Yes** when asked about Claude Desktop. The wizard will:
405
+
406
+
1. Check that mitmproxy is installed
407
+
2. Generate the mitmproxy CA certificate (if not already present)
408
+
3. Install the CA into the OS trust store (requires sudo/admin)
409
+
4. Write the redirect addon to `~/.cc-router/interceptor/addon.py`
410
+
5. On macOS, prompt you to approve the Network Extension
411
+
412
+
Then start the interceptor:
413
+
414
+
```bash
415
+
cc-router client start-desktop
416
+
```
417
+
418
+
Open Claude Desktop and send a message. The request will be intercepted, redirected to CC-Router, and round-robinned across your accounts just like Claude Code traffic.
419
+
420
+
### Stopping / removing Desktop interception
421
+
422
+
```bash
423
+
cc-router client stop-desktop # Stop the interceptor (keep configuration)
424
+
cc-router client disconnect # Stop + remove all client config
mitmproxy's local mode is *process-scoped* — it only intercepts traffic from the Claude process, not your browser, curl, or any other app. The OS-level interception uses:
-**macOS: "provider rejected new flow"** — re-enable Mitmproxy Redirector in System Settings → General → Login Items & Extensions → Network Extensions, then restart mitmproxy.
451
+
-**Windows: UAC prompt every start** — expected; mitmproxy's redirector needs admin at runtime.
452
+
-**Linux: "eBPF program failed to load"** — check your kernel version with `uname -r`. You need ≥ 6.8.
453
+
-**Chat shows "failed to connect"** — make sure CC-Router is reachable from the mitmproxy process. Run `curl http://localhost:3456/cc-router/health` to verify the proxy is up.
454
+
455
+
---
456
+
324
457
## Reverting to normal Claude Code
325
458
326
459
To stop using cc-router and go back to normal Claude Code authentication:
0 commit comments