@juexibobi/private-desktop-mcp 0.4.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/AGENTS.md ADDED
@@ -0,0 +1,137 @@
1
+ # AGENTS.md — Guide for AI Agents Operating and Maintaining Private Desktop MCP
2
+
3
+ This document defines the behavioral contracts for AI coding agents working with **Private Desktop MCP (`@juexibobi/private-desktop-mcp`)** in two roles:
4
+
5
+ 1. **Operator Mode (User Usage & Remote Multi-Device Orchestration)** — when a user asks you to connect their machine, configure an MCP client, inspect paired desktops, run commands across multiple computers, or manage read-only guardrails.
6
+ 2. **Developer Mode (Repository Maintenance & Evolution)** — when a user asks you to modify, test, release, or deploy the connector and Cloudflare Worker relay.
7
+
8
+ ---
9
+
10
+ ## Part 1: Operator Playbook (Using Private Desktop MCP for the User)
11
+
12
+ ### 1. Inspect Current State First (Machine-Readable Preflight)
13
+
14
+ Always run non-destructive JSON preflight checks before changing local configuration or starting a connector:
15
+
16
+ ```bash
17
+ npx --yes @juexibobi/private-desktop-mcp@latest doctor --json
18
+ npx --yes @juexibobi/private-desktop-mcp@latest status --json
19
+ npx --yes @juexibobi/private-desktop-mcp@latest report --json
20
+ ```
21
+
22
+ ### 2. Configuring an AI Client (`setup-client`)
23
+
24
+ Follow the preview-before-confirm contract in [docs/agent-install.md](docs/agent-install.md):
25
+
26
+ 1. Preview the exact configuration change with `--dry-run --json` first:
27
+ ```bash
28
+ npx --yes @juexibobi/private-desktop-mcp@latest setup-client <client> --dry-run --json
29
+ ```
30
+ Supported `<client>` values: `claude-code`, `claude-desktop`, `cursor`, `vscode`, `codex`, `gemini`, `windsurf`, `all`.
31
+ 2. Show the user the target file path and preview, wait for confirmation, then apply without `--dry-run`.
32
+
33
+ ### 3. Starting & Pairing a Device Connector (Cloudflare, Tailscale P2P, or Hybrid)
34
+
35
+ - **Cloudflare Relay (default full mode)**:
36
+ ```bash
37
+ npx --yes --prefer-online --package=@juexibobi/private-desktop-mcp@latest -- private-desktop-mcp connect --json
38
+ ```
39
+ - **Tailscale P2P Node (zero Cloudflare, zero pairing)**:
40
+ ```bash
41
+ npx --yes --prefer-online --package=@juexibobi/private-desktop-mcp@latest -- private-desktop-mcp serve --json
42
+ ```
43
+ - **Hybrid Dual-Transport (BOTH Tailscale P2P AND Cloudflare Relay simultaneously)**:
44
+ ```bash
45
+ npx --yes --prefer-online --package=@juexibobi/private-desktop-mcp@latest -- private-desktop-mcp connect --hybrid --json
46
+ ```
47
+ - **Zero-Server Multi-Device Tailnet Mesh Hub (on AI client machine or homelab)**:
48
+ ```bash
49
+ npx --yes --prefer-online --package=@juexibobi/private-desktop-mcp@latest -- private-desktop-mcp hub --json
50
+ ```
51
+ *(Pass `--expose-tailscale` to serve the hub to the whole tailnet, `--with-local` to also include this machine, or `--peer [name=]url` for static peers.)*
52
+ - **Least-privilege read-only + directory jail mode (recommended for untrusted or exploratory sessions)**:
53
+ ```bash
54
+ npx --yes --prefer-online --package=@juexibobi/private-desktop-mcp@latest -- private-desktop-mcp serve --readonly --allow-dir <workspace_path> --json
55
+ ```
56
+ - **Aggregating additional local stdio MCP servers alongside Desktop Commander**:
57
+ ```bash
58
+ npx --yes --prefer-online --package=@juexibobi/private-desktop-mcp@latest -- private-desktop-mcp connect --servers ./client-configs/servers.example.json
59
+ ```
60
+ - When using Cloudflare mode and a machine is not paired yet, `--json` emits a structured event:
61
+ ```json
62
+ {"event":"pairing_required","deviceName":"...","code":"...","approvalUrl":"https://.../admin/devices","pairId":"...","expiresIn":3600}
63
+ ```
64
+ Present the `code` and `approvalUrl` to the user so they can approve it behind Cloudflare Access.
65
+ - When using Tailscale mode, `--json` emits `{"event":"tailscale_node_ready","mode":"serve|direct","endpointUrl":"..."}` (for `serve` / `connect --hybrid`) or `{"event":"tailnet_hub_ready","endpointUrl":"...","onlineDevices":...}` (for `hub`).
66
+
67
+ ### 4. Multi-Device Orchestration via MCP Tools, Resources & Prompts
68
+
69
+ When connected to the remote `/mcp` Streamable HTTP endpoint:
70
+
71
+ - **Resources (`resources/list`, `resources/read`)** — always available at the Cloudflare edge, even when 0 devices are online:
72
+ - `relay://devices`: Live inventory of paired devices, online state, OS/arch, read-only locks, and current selection.
73
+ - `relay://status`: Worker version, protocol features, and Access verification posture.
74
+ - `relay://audit`: Recent sanitized metadata-only audit log.
75
+ - **Built-in Edge Meta-Tools (`tools/call`)**:
76
+ - `relay_list_devices`: List all paired desktops and their live status.
77
+ - `relay_select_device`: Set the default active target desktop by `device_id` or `device_name`.
78
+ - `relay_ping_device`: Measure WebSocket RTT and verify local `gateway.mjs` health.
79
+ - `relay_set_device_policy`: Lock/unlock a device to read-only mode at the Cloudflare edge (`read_only: true|false`) or rename it (`new_name`).
80
+ - `relay_recent_activity`: Inspect sanitized audit entries (timestamps, actor, device, tool name, HTTP status, duration).
81
+ - **Per-Call Device Targeting (`_device`)**:
82
+ - Every upstream tool schema includes an optional `_device` string property. Pass `_device: "<device_name_or_id>"` on any tool call (e.g., `read_file`, `list_directory`, `start_process`) to route that single call to a specific machine without changing the global selection.
83
+ - **Self-Healing Tool Errors**:
84
+ - If a target device is offline or multiple devices are online without a selection, `tools/call` returns an `isError: true` structured payload containing `onlineDevices`, `selectedDeviceId`, and `nextActions`. Follow `nextActions` (e.g., call `relay_select_device` or pass `_device`) automatically.
85
+
86
+ ---
87
+
88
+ ## Part 2: Developer Playbook (Maintaining the Repository)
89
+
90
+ ### 1. Workspace Map
91
+
92
+ ```text
93
+ core/
94
+ mcp-hub.mjs Runtime-agnostic MCP multi-device protocol core (meta-tools, resources, prompts, _device injection, self-healing errors; shared by Cloudflare Worker and Node Tailnet Mesh Hub)
95
+ worker/
96
+ index.mjs Cloudflare Worker router & SQLite-backed DeviceHub Durable Object (MCP edge lifecycle, WebSocket relay, audit log, admin UI)
97
+ auth.mjs Cryptographic Cloudflare Access RS256 JWT verifier (Web Crypto API, JWKS caching + key-rotation refresh)
98
+ bin/
99
+ cli.mjs Cross-platform CLI (connect, serve, hub, status, doctor, report, setup-client, reset; --transport cloudflare|tailscale|hybrid, --json, heartbeat watchdog, child gateway supervisor)
100
+ local-bridge.mjs Shared local request execution pipeline enforcing policy, tools/list filtering, outbound DLP, and activity logging across both Cloudflare WS and Tailscale HTTP transports
101
+ tailscale.mjs Cross-platform Tailscale CLI discovery, status/peer parser, TTL-cached WhoIs verifier, fail-closed identity authorizer, and managed foreground `tailscale serve` launcher
102
+ tailscale-node.mjs Tailscale P2P MCP node HTTP ingress (`/mcp`, `/pcc/node-info`, `/healthz`) in Serve HTTPS or direct Tailnet IPv4 mode
103
+ tailscale-hub.mjs Zero-server / self-hosted multi-device Tailnet Mesh Hub (Tailscale peer auto-discovery, isolated per-device upstream MCP sessions, static peers, optional local gateway, push-WS relay)
104
+ policy.mjs Local tool governance (--readonly, --allow-dir symlink-aware path jail, allow/deny lists, self-credential guard) & outbound DLP secret redaction
105
+ client-setup.mjs Non-destructive MCP client config generator/merger with --dry-run preview (supports Cloudflare, Tailscale node, local/Tailscale Hub, and Bearer tokens)
106
+ proxy.mjs System proxy autodetection (Windows WinINET, macOS scutil, environment HTTPS_PROXY/NO_PROXY) with automatic direct bypass for Tailscale (`*.ts.net`, `100.64.0.0/10`, `fd7a:115c:a1e0::/48`)
107
+ activity.mjs JSON-RPC/SSE parser, correlation IDs, and TRACE/DEBUG/LIVE terminal activity formatters
108
+ logging.mjs Terminal secret redaction and timestamped logging helpers
109
+ gateway.mjs Local loopback Streamable HTTP MCP gateway fronting @wonderwhy-er/desktop-commander + optional extra stdio MCP servers (Bearer + Host + Origin guard)
110
+ skills/
111
+ private-desktop-mcp/SKILL.md Bundled Agent Skill for coding agents
112
+ docs/
113
+ agent-install.md Canonical agent-driven setup & safety runbook
114
+ tests/
115
+ *.test.mjs Node.js built-in test runner suites covering worker auth, DeviceHub DO, Tailscale auth/node/mesh hub, gateway, policy/DLP, client setup, proxy, activity, and packaging
116
+ ```
117
+
118
+ ### 2. Boundary & Security Invariants
119
+
120
+ 1. **Zero secret leakage**: Never commit `device.json`, `hub-state.json`, Cloudflare API keys/tokens (`cfk_`, `cfut_`, `cfat_`), Tailscale bearer tokens, Access cookies, or `.env` files. Never weaken `bin/policy.mjs` protection of the `PrivateDesktopMCP` credential directory.
121
+ 2. **Fail-closed edge & Tailscale authentication**: `worker/auth.mjs` must verify RS256 signatures, `iss`, `aud`, `exp`, and `nbf` against `CF_ACCESS_TEAM_DOMAIN` + `CF_ACCESS_AUD`. `bin/tailscale.mjs` must fail closed on Tailscale identity (`Tailscale-User-Login` + `WhoIs`, defaulting strictly to the local owner login — never trusting an entire shared tailnet without explicit `--allow-ts-user` / `--allow-ts-tag` / `--token`).
122
+ 3. **Shared local guardrails**: Every transport (`connect` Cloudflare WS, `serve` Tailscale HTTP, `hub --with-local`) must route through `bin/local-bridge.mjs` so `--readonly`, `--allow-dir`, self-credential protection, and outbound DLP cannot be bypassed on any transport.
123
+ 4. **Loopback gateway isolation**: `gateway.mjs` binds only to `127.0.0.1`, validates loopback `Host` headers (anti-DNS-rebinding), rejects browser `Origin` headers (anti-CSRF), and requires a per-launch 32-byte `MCP_LOCAL_TOKEN`.
124
+ 5. **Edge/Hub-always-alive MCP discovery**: `initialize`, `notifications/initialized`, `ping`, `server/discover`, `tools/list`, `resources/list`, `resources/read` (`relay://*`), `prompts/list`, and `prompts/get` must succeed at both the Worker edge and Tailnet Mesh Hub even when zero devices are connected.
125
+ 6. **Direct dependency declaration**: Every package imported by `core/*.mjs`, `bin/*.mjs`, or `gateway.mjs` must be declared directly in `package.json` `dependencies` and listed in `package.json` `files` so `npx --install-strategy=nested` works on a clean machine.
126
+
127
+ ### 3. Verification & Release Workflow
128
+
129
+ Run the full verification gate before opening a PR or tagging a release:
130
+
131
+ ```bash
132
+ npm ci --ignore-scripts --no-audit --no-fund
133
+ npm test
134
+ npm pack --dry-run --json
135
+ ```
136
+
137
+ Releases are published automatically via GitHub Actions OIDC Trusted Publishing (`.github/workflows/release.yml`) when a `v*` tag matching `package.json` and `server.json` `version` is pushed.
package/README.md CHANGED
@@ -1,10 +1,43 @@
1
1
  # Private Desktop MCP
2
2
 
3
- Self-hosted multi-device [Model Context Protocol](https://modelcontextprotocol.io/) bridge for Desktop Commander (and optional additional local MCP servers) using Cloudflare Workers, SQLite-backed Durable Objects, and a one-command cross-platform connector.
3
+ Self-hosted, **Agent-Native** multi-device [Model Context Protocol](https://modelcontextprotocol.io/) bridge for Desktop Commander (and optional additional local MCP servers) supporting **Cloudflare Workers**, **Tailscale P2P / Tailnet Mesh Hub (zero cloud)**, and **Hybrid dual-transport**.
4
4
 
5
- **Transport:** Streamable HTTP (`POST` + `DELETE`, supporting both MCP `2025-*` and stateless `2026-07-28`) to AI clients; outgoing WebSocket with zero-cost hibernation heartbeat from each device to the relay.
5
+ **Transports:**
6
+ - **Tailscale P2P & Mesh Hub (Zero Cloud)**: End-to-end encrypted WireGuard direct connections via `tailscale serve` HTTPS (`*.ts.net:8443`) or direct Tailnet IPv4 (`100.x.y.z:8718` + `whois` verification), with automatic zero-pairing multi-device discovery via `private-desktop-mcp hub`.
7
+ - **Cloudflare Workers + Durable Objects**: Streamable HTTP (`POST` + `DELETE`) to public/cloud AI clients behind Cloudflare Access; outgoing WebSocket with zero-cost hibernation heartbeat from each device.
8
+ - **Hybrid (`connect --hybrid`)**: Runs **both** Tailscale node ingress and Cloudflare outbound WebSocket simultaneously through the same local gateway, policy guardrails, and DLP pipeline.
6
9
 
7
- ## Public npm release
10
+ ## Quick Start: Install with Your Coding Agent
11
+
12
+ Paste the block below into Claude Code, Codex, Cursor, VS Code Copilot, Gemini CLI, OpenClaw, or Antigravity:
13
+
14
+ ```text
15
+ Install and configure Private Desktop MCP for me using the official instructions at:
16
+ https://github.com/KFCheems/private-desktop-mcp/blob/main/docs/agent-install.md
17
+ Before changing anything, identify my OS and AI client, run `npx --yes @juexibobi/private-desktop-mcp@latest doctor --json`, preview client config changes with `setup-client <client> --dry-run --json`, and wait for my confirmation.
18
+ ```
19
+
20
+ Or install directly via native agent plugin / extension marketplaces:
21
+
22
+ ```bash
23
+ # Claude Code
24
+ /plugin marketplace add KFCheems/private-desktop-mcp
25
+ /plugin install private-desktop-mcp@private-desktop-mcp
26
+
27
+ # Codex
28
+ codex plugin marketplace add KFCheems/private-desktop-mcp
29
+
30
+ # Gemini CLI
31
+ gemini extensions install https://github.com/KFCheems/private-desktop-mcp
32
+
33
+ # Antigravity
34
+ agy plugin install https://github.com/KFCheems/private-desktop-mcp
35
+
36
+ # Agent Skill only (npx skills)
37
+ npx --yes skills add KFCheems/private-desktop-mcp
38
+ ```
39
+
40
+ ## Public npm release (Device Connector)
8
41
 
9
42
  ```powershell
10
43
  npx.cmd --yes --prefer-online --package=@juexibobi/private-desktop-mcp@latest -- private-desktop-mcp connect
@@ -12,73 +45,101 @@ npx.cmd --yes --prefer-online --package=@juexibobi/private-desktop-mcp@latest --
12
45
 
13
46
  Each release gets its own immutable npm version. **Do not overwrite a fixed `.tgz` at a stable URL**: npm caching might start an old version.
14
47
 
15
- ## What's new in v0.4.0
48
+ ## What's new in v0.6.0 (Tailscale P2P, Mesh Hub & Hybrid Edition)
16
49
 
17
- ### Security & Governance
18
- - **Cryptographic Cloudflare Access JWT verification (`worker/auth.mjs`)**: Verifies RS256 signatures against `https://<team>.cloudflareaccess.com/cdn-cgi/access/certs` (with automatic `kid` key-rotation refresh), `aud`, `iss`, `exp`, and `nbf`. Fails closed if unconfigured (with an explicit temporary `ALLOW_UNVERIFIED_ACCESS_HEADER=true` migration opt-in).
19
- - **Hardened local gateway (`gateway.mjs`)**: Enforces per-launch ephemeral Bearer authentication (`MCP_LOCAL_TOKEN`), loopback `Host` validation (anti-DNS-rebinding), and browser `Origin` rejection (anti-CSRF).
20
- - **Local policy guardrails (`bin/policy.mjs`)**:
21
- - `--readonly` (or `PCC_READONLY=1`): allows read-only tools only and hides mutating tools from `tools/list`.
22
- - `--allow-dir <dir>` (repeatable, or `PCC_ALLOW_DIRS`): jails file tool paths to allowed directories (resolving symlinks and blocking `..` traversal).
23
- - `--allow-tools <csv>` / `--deny-tools <csv>`: explicit tool allowlist/denylist.
24
- - Always blocks remote access to the connector's own credential directory (`PrivateDesktopMCP/device.json`).
25
- - **Outbound DLP secret redaction (enabled by default, `--no-dlp` to opt out)**: Redacts PEM private keys, AWS/GitHub/OpenAI/Slack/Google tokens, and the active device/gateway bearer tokens from tool responses before sending them back to the cloud LLM.
26
- - **Edge read-only lock & emergency kill-switch**: Toggle per-device read-only lock or revoke all devices at once from `/admin/devices`.
27
- - **Removed hardcoded diagnostic file path**: `/relay/diagnostic` now permits read-only MCP introspection methods only.
50
+ - **Zero-Cloud Tailscale P2P Node (`private-desktop-mcp serve`)**: Expose any Windows, macOS, or Linux desktop over end-to-end encrypted WireGuard using managed foreground `tailscale serve --https=8443` (official Let's Encrypt TLS, cleaned up automatically on Ctrl+C) or direct Tailnet IPv4 (`--ts-direct`), with fail-closed Tailscale user/tag WhoIs verification and no 75s/1MB Worker limits.
51
+ - **Zero-Server Multi-Device Tailnet Mesh Hub (`private-desktop-mcp hub`)**: Shared runtime-agnostic MCP Hub core (`core/mcp-hub.mjs`) with automatic zero-pairing discovery of same-user/tagged Tailscale nodes, isolated per-device upstream MCP sessions, static `--peer` support, optional `--with-local`, `--expose-tailscale`, and compatible push-WebSocket relay (`/relay/ws`).
52
+ - **Hybrid Dual-Transport (`private-desktop-mcp connect --hybrid`)**: Run both Tailscale P2P ingress and Cloudflare outbound WebSocket relay concurrently through the shared local policy/DLP guardrail pipeline (`bin/local-bridge.mjs`).
53
+ - **Automatic Tailscale Proxy Bypass & Agent CLI Integration**: `bin/proxy.mjs` and the Mesh Hub automatically bypass system/Clash HTTP proxies for `*.ts.net`, `100.64.0.0/10`, and `fd7a:115c:a1e0::/48`; `doctor --json`, `status --json`, `report --json`, and `setup-client --hub | --tailscale` all support Tailscale natively.
28
54
 
29
- ### Reliability & Multi-Device Experience
30
- - **Zero-cost WebSocket hibernation heartbeat**: Durable Object `setWebSocketAutoResponse("ping", "pong")` paired with a 25s client heartbeat watchdog detects half-open sockets after OS sleep or Wi-Fi switches without waking hibernated DOs.
31
- - **Fixed reconnect backoff & jitter**: Resets exponential backoff once a session stays healthy and applies random jitter.
32
- - **Local gateway auto-recovery & fast-fail**: Supervises the local `gateway.mjs` child process, immediately fails in-flight calls if it exits unexpectedly, and restarts it automatically with bounded backoff.
33
- - **In-chat multi-device meta-tools**: Built-in `relay_list_devices`, `relay_select_device`, `relay_ping_device`, and `relay_recent_activity` tools let AI clients inspect online machines, switch targets, measure RTT latency, and view sanitized metadata audit logs without leaving chat. Individual tool calls can also target a specific machine via `_device` argument or `X-Target-Device` header.
34
- - **SQLite audit log & upgraded admin dashboard**: Uses Durable Object SQLite (`audit_logs`) to record metadata-only call history (never file contents or command output), plus device platform, CLI version, mode, rename, read-only toggle, and revoke-all controls.
35
- - **Streamable HTTP improvements**: Forwards `DELETE /mcp` session teardown and propagates client `AbortSignal` cancellations (`{ kind: "cancel" }`) all the way to the local gateway.
36
- - **Optional multi-MCP aggregation**: Pass `--servers <config.json>` (or `PCC_MCP_CONFIG`, see [client-configs/servers.example.json](client-configs/servers.example.json)) to aggregate additional local stdio MCP servers under `<server>__<tool>` namespaces alongside Desktop Commander.
37
- - **Upgraded Desktop Commander**: Bumped `@wonderwhy-er/desktop-commander` to `0.3.4` (security patches, Windows process-tree termination, lazy PDF/Office loading, explicit MCP tool annotations).
38
- - **Diagnostics & cross-platform proxy**: Added `doctor` and `report` CLI subcommands, macOS `scutil --proxy` autodetection alongside Windows WinINET, rotating user-private gateway logs (`PrivateDesktopMCP/logs/gateway.log`), and `--relay`/`--port`/`--name` overrides for clean self-hosting.
55
+ ## What's new in v0.5.0 (Agent-Native Edition)
39
56
 
40
- ## Terminal logging
57
+ ### Agent-Native MCP Protocol & Multi-Device Self-Healing
58
+ - **Edge-Always-Alive MCP Lifecycle**: `initialize`, `notifications/initialized`, `ping`, `server/discover`, `tools/list`, `resources/list`, `resources/read` (`relay://*`), `prompts/list`, and `prompts/get` succeed at the Cloudflare Worker edge **even when zero devices are online or multiple devices are online without a selection**, allowing agents to connect, inspect inventory, and guide the user instead of failing with HTTP transport errors.
59
+ - **Dynamic Server Instructions**: `initialize` / `server/discover` automatically injects live paired-device inventory (`online/offline`, OS, read-only status, selected target) and multi-device routing guidance into MCP `instructions`.
60
+ - **Schema-Native `_device` Parameter**: Every upstream tool in `tools/list` (`read_file`, `start_process`, `write_file`, etc.) has an optional `_device` string property injected into its `inputSchema.properties`, enabling schema-strict agents to target any paired computer per call without mutating global selection.
61
+ - **Built-in Edge Meta-Tools, Resources & Prompts**:
62
+ - **Tools**: `relay_list_devices`, `relay_select_device`, `relay_ping_device`, `relay_set_device_policy` (lock/unlock read-only mode or rename a device in chat), and `relay_recent_activity`.
63
+ - **Resources**: `relay://devices`, `relay://status`, and `relay://audit` (`application/json`).
64
+ - **Prompts**: `multi-device-triage` and `safe-remote-maintenance`.
65
+ - **Self-Healing Tool Errors**: When a `tools/call` targets an offline or ambiguous device, the relay returns a structured JSON-RPC `isError: true` result containing `errorCode`, `onlineDevices`, `selectedDeviceId`, and `nextActions` so the agent recovers autonomously.
41
66
 
42
- PCC uses **TRACE logging by default**. The normal `connect` command prints MCP call IDs, sanitized/truncated command and response previews, timings, connection details, and errors.
67
+ ### Agent-Native CLI & Ecosystem Manifests
68
+ - **Universal `--json` Mode**: `doctor --json`, `status --json`, `report --json`, `reset --json`, `setup-client --json`, and `connect --json` (emits `{"event":"pairing_required",...}` and `{"event":"pairing_approved",...}`).
69
+ - **Automated Client Configurator (`setup-client`)**: Non-destructively merges the remote MCP endpoint into `claude-code`, `claude-desktop`, `cursor`, `vscode`, `codex`, `gemini`, `windsurf`, or `all`, with `--dry-run` preview support.
70
+ - **Cross-Platform Agent Manifests & Playbooks**: Ships [AGENTS.md](AGENTS.md), [CLAUDE.md](CLAUDE.md), [docs/agent-install.md](docs/agent-install.md), [skills/private-desktop-mcp/SKILL.md](skills/private-desktop-mcp/SKILL.md), `plugin.json`, `.claude-plugin/`, `gemini-extension.json`, and `.antigravity-plugin/`.
43
71
 
44
- **Privacy:** TRACE can reveal sensitive file contents or command output locally in your terminal. Redaction is best effort; avoid sharing or recording the terminal. Use `--debug` for detailed metadata without content previews, or `--safe` for compact logs. The child gateway log is stored in the user-private `PrivateDesktopMCP/logs/gateway.log` directory and rotates automatically at 5 MB.
45
-
46
- ## System proxy detection (Windows & macOS)
47
-
48
- - **Windows**: Automatically uses the current user's effective WinINET system proxy (static HTTP/Mixed proxies, bypass rules, PAC/WPAD).
49
- - **macOS**: Automatically queries `scutil --proxy` (HTTPS/HTTP proxies and `ExceptionsList`).
50
- - **Environment override**: Explicit `HTTPS_PROXY`, `HTTP_PROXY`, or `ALL_PROXY` settings take precedence on all platforms (`NO_PROXY` respected). Supported proxy transport is HTTP/HTTPS CONNECT.
72
+ ### Security, Governance & Reliability (v0.4.0+)
73
+ - **Cryptographic Cloudflare Access JWT verification (`worker/auth.mjs`)**: Verifies RS256 signatures against `https://<team>.cloudflareaccess.com/cdn-cgi/access/certs` (with automatic `kid` key-rotation refresh), `aud`, `iss`, `exp`, and `nbf`.
74
+ - **Hardened local gateway (`gateway.mjs`)**: Per-launch ephemeral Bearer authentication (`MCP_LOCAL_TOKEN`), loopback `Host` validation (anti-DNS-rebinding), browser `Origin` rejection (anti-CSRF), and authenticated `/healthz`.
75
+ - **Local policy guardrails & Outbound DLP (`bin/policy.mjs`)**: `--readonly`, `--allow-dir <dir>` (symlink-aware path jail), `--allow-tools` / `--deny-tools`, self-credential protection (`PrivateDesktopMCP/device.json`), and automatic outbound secret redaction (PEM keys, AWS/GitHub/OpenAI/Slack/Google tokens, and active relay tokens).
76
+ - **Zero-cost WebSocket hibernation heartbeat & auto-recovery**: RFC 6455 `ws.ping()` + DO `setWebSocketAutoResponse("ping", "pong")`, jittered backoff reset, `DELETE /mcp` + client `AbortSignal` cancel propagation, and automatic local `gateway.mjs` crash recovery.
51
77
 
52
78
  ## CLI commands & flags
53
79
 
54
80
  ```powershell
55
- # Connect (default)
81
+ # Connect via Cloudflare relay (default)
56
82
  private-desktop-mcp connect
57
83
 
84
+ # Serve directly over Tailscale P2P (zero Cloudflare account or pairing required)
85
+ private-desktop-mcp serve
86
+ private-desktop-mcp serve --readonly --allow-dir C:\workspace
87
+
88
+ # Run BOTH Tailscale P2P AND Cloudflare relay simultaneously (Hybrid mode)
89
+ private-desktop-mcp connect --hybrid
90
+
91
+ # Start a zero-server multi-device Tailnet Mesh Hub (auto-discovers Tailscale nodes)
92
+ private-desktop-mcp hub
93
+ private-desktop-mcp hub --with-local --expose-tailscale
94
+
58
95
  # Safe read-only mode jailed to a workspace directory
59
96
  private-desktop-mcp connect --readonly --allow-dir C:\workspace
60
97
 
61
- # Connect to your own self-hosted Cloudflare Worker
62
- private-desktop-mcp connect --relay https://my-relay.example.workers.dev --name WorkPC
98
+ # Configure MCP clients (Cloudflare, local Tailnet Mesh Hub, or Tailscale node)
99
+ private-desktop-mcp setup-client claude-code --dry-run --json
100
+ private-desktop-mcp setup-client claude-code --hub --dry-run --json
101
+ private-desktop-mcp setup-client cursor --tailscale --dry-run --json
63
102
 
64
103
  # Aggregate extra local MCP servers alongside Desktop Commander
65
104
  private-desktop-mcp connect --servers ./client-configs/servers.example.json
66
105
 
67
- # Diagnostics & status
68
- private-desktop-mcp doctor
69
- private-desktop-mcp report
70
- private-desktop-mcp status
71
- private-desktop-mcp reset
106
+ # Machine-readable diagnostics & status (includes Tailscale detection)
107
+ private-desktop-mcp doctor --json
108
+ private-desktop-mcp doctor --tailscale --json
109
+ private-desktop-mcp report --json
110
+ private-desktop-mcp status --json
111
+ private-desktop-mcp reset --json
72
112
  ```
73
113
 
114
+ ## Tailscale P2P & Multi-Device Mesh Hub (Zero Cloud)
115
+
116
+ If your machines are on the same [Tailscale](https://tailscale.com/) tailnet, you can run Private Desktop MCP **without any Cloudflare account, domain, or pairing codes**:
117
+
118
+ 1. **On each desktop you want to control**, run:
119
+ ```bash
120
+ npx --yes --prefer-online --package=@juexibobi/private-desktop-mcp@latest -- private-desktop-mcp serve
121
+ ```
122
+ - Automatically uses foreground `tailscale serve --https=8443` (valid Let's Encrypt cert at `https://<node>.<tailnet>.ts.net:8443/mcp`, torn down cleanly on Ctrl+C) or falls back to direct Tailnet IP (`--ts-direct`, `http://100.x.y.z:8718/mcp`).
123
+ - Enforces fail-closed Tailscale user identity (`Tailscale-User-Login` + `tailscale whois` — defaults strictly to your own Tailscale login so other users on a shared tailnet are rejected), plus the exact same `--readonly`, `--allow-dir`, self-credential guard, and outbound DLP as Cloudflare mode.
124
+ - Automatic proxy bypass in `bin/proxy.mjs` ensures `*.ts.net`, `100.64.0.0/10`, and `fd7a:115c:a1e0::/48` never break under Clash/system HTTP proxies.
125
+
126
+ 2. **On the machine running your AI client (or a homelab/NAS)**, start the **Tailnet Mesh Hub**:
127
+ ```bash
128
+ npx --yes --prefer-online --package=@juexibobi/private-desktop-mcp@latest -- private-desktop-mcp hub
129
+ ```
130
+ - Automatically discovers all online same-user Tailscale peers running `private-desktop-mcp serve` (plus optional `--peer-tag tag:mcp-desktop`, static `--peer`, `--with-local`, and paired WebSocket relays).
131
+ - Exposes ONE unified Streamable HTTP MCP server (`http://127.0.0.1:8720/mcp`, or `https://<hub>.<tailnet>.ts.net:8443/mcp` with `--expose-tailscale`) with full `relay_list_devices`, `relay_select_device`, `relay_ping_device`, `relay_set_device_policy`, `_device` per-call routing (with isolated per-device upstream MCP sessions), `relay://*` resources, and audit logs.
132
+ - Configure your AI client in one command:
133
+ ```bash
134
+ npx --yes @juexibobi/private-desktop-mcp@latest setup-client claude-code --hub --dry-run --json
135
+ ```
136
+
74
137
  ## Current canonical endpoint
75
138
 
76
139
  ```text
77
140
  https://private-desktop-device-relay.ljx2043979076.workers.dev/mcp
78
141
  ```
79
142
 
80
- Client configuration templates are available in `.mcp.json` and `client-configs/` (`vscode-mcp.json`, `mcpServers.json`, `cursor-mcp.json`, `codex.toml.example`).
81
-
82
143
  ## Pairing devices
83
144
 
84
145
  1. On a machine with Node.js 20.18.1+ run `private-desktop-mcp connect`.
@@ -92,25 +153,15 @@ Client configuration templates are available in `.mcp.json` and `client-configs/
92
153
 
93
154
  The Worker source is in `worker/index.mjs` and `worker/auth.mjs`. Infrastructure is described in `wrangler.toml`.
94
155
 
95
- 1. Configure a Cloudflare Access self-hosted application protecting `/mcp` and `/admin/*` with an Owner-only policy. Never protect `/relay/*` with Access (otherwise device WebSocket connections are blocked).
156
+ 1. Configure a Cloudflare Access self-hosted application protecting `/mcp` and `/admin/*` with an Owner-only policy. Never protect `/relay/*` with Access.
96
157
  2. Configure cryptographic Access JWT verification on the Worker before deploying:
97
158
 
98
159
  ```bash
99
160
  wrangler secret put CF_ACCESS_TEAM_DOMAIN # e.g. https://your-team.cloudflareaccess.com
100
161
  wrangler secret put CF_ACCESS_AUD # Access application AUD tag
101
- ```
102
-
103
- 3. For self-hosted custom domains/workers, optionally configure `SHARED_HOSTS`, `ALLOWED_OWNER_HOSTS`, `ALLOWED_RELAY_HOSTS`, and `PUBLIC_BASE_URL` (see comments in `wrangler.toml`).
104
- 4. Deploy with `wrangler deploy`.
105
-
106
- ## Running from source
107
-
108
- ```bash
109
- npm install
110
- npm test
111
- node bin/cli.mjs connect
162
+ wrangler deploy
112
163
  ```
113
164
 
114
165
  ## Security
115
166
 
116
- This tool provides remote filesystem and command-execution capabilities. Restrict Cloudflare Access to your own identity, configure `CF_ACCESS_TEAM_DOMAIN` + `CF_ACCESS_AUD`, approve only devices you control, and consider running `--readonly` or `--allow-dir` for day-to-day workflows. See [SECURITY.md](SECURITY.md).
167
+ This tool provides remote filesystem and command-execution capabilities. Restrict Cloudflare Access to your own identity, configure `CF_ACCESS_TEAM_DOMAIN` + `CF_ACCESS_AUD`, approve only devices you control, and consider running `--readonly` or `--allow-dir` for day-to-day workflows. See [SECURITY.md](SECURITY.md) and [AGENTS.md](AGENTS.md).