@juexibobi/private-desktop-mcp 0.3.6 → 0.4.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/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # Private Desktop MCP
2
2
 
3
- Self-hosted multi-device [Model Context Protocol](https://modelcontextprotocol.io/) bridge for Desktop Commander using Cloudflare Workers, Durable Objects and a one-command Windows connector.
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.
4
4
 
5
- **Transport:** Streamable HTTP to ChatGPT; outgoing WebSocket from the device to the relay.
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.
6
6
 
7
7
  ## Public npm release
8
8
 
@@ -12,59 +12,105 @@ npx.cmd --yes --prefer-online --package=@juexibobi/private-desktop-mcp@latest --
12
12
 
13
13
  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
14
 
15
- ### Terminal logging (v0.3.6)
15
+ ## What's new in v0.4.0
16
16
 
17
- PCC now uses **TRACE logging by default**. The normal `connect` command prints MCP call IDs, sanitized/truncated command and response previews, timings, connection details, and errors. There is no need for `--trace`.
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.
18
28
 
19
- **Privacy:** TRACE can reveal sensitive file contents or command output. Redaction is best effort; avoid sharing or recording the terminal. Use `--debug` for detailed metadata without content previews, or `--safe` for compact logs. The former `--trace` flag remains supported for compatibility.
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.
20
39
 
21
- ### Windows system proxy detection (v0.3.4)
40
+ ## Terminal logging
22
41
 
23
- PCC automatically uses the current Windows user's **effective system proxy** (WinINET), including static HTTP/Mixed proxies, Windows proxy bypass rules, and supported PAC/WPAD configurations. It uses the same detected proxy for the HTTPS device-pairing API and for the secure WebSocket relay. No manual `HTTPS_PROXY` configuration is required for normal Windows system proxy settings.
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.
24
43
 
25
- Explicit `HTTPS_PROXY`, `HTTP_PROXY` or `ALL_PROXY` settings take precedence over Windows settings; `NO_PROXY` exclusions are respected for an explicitly configured environment proxy. Supported proxy transport is HTTP/HTTPS CONNECT. SOCKS-only proxy endpoints must be exposed through an HTTP/Mixed port. The detected proxy is re-checked periodically when retrying a lost connection. If system lookup fails or times out, PCC reports a warning and tries a direct connection.
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.
26
45
 
27
- Debug mode prints **redacted parameter metadata and response size/type**, not command contents, file contents or raw tool results. Sensitive fields and inline tokens are masked, but local paths and other non-sensitive metadata may still appear, so avoid sharing debug logs publicly. The child gateway's detailed stderr/stdout is still stored at `%TEMP%\private-desktop-mcp-device.log`. Neither logging mode changes device pairing, OAuth or startup behavior.
46
+ ## System proxy detection (Windows & macOS)
28
47
 
29
- ## Current independent endpoint
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.
51
+
52
+ ## CLI commands & flags
53
+
54
+ ```powershell
55
+ # Connect (default)
56
+ private-desktop-mcp connect
57
+
58
+ # Safe read-only mode jailed to a workspace directory
59
+ private-desktop-mcp connect --readonly --allow-dir C:\workspace
60
+
61
+ # Connect to your own self-hosted Cloudflare Worker
62
+ private-desktop-mcp connect --relay https://my-relay.example.workers.dev --name WorkPC
63
+
64
+ # Aggregate extra local MCP servers alongside Desktop Commander
65
+ private-desktop-mcp connect --servers ./client-configs/servers.example.json
66
+
67
+ # Diagnostics & status
68
+ private-desktop-mcp doctor
69
+ private-desktop-mcp report
70
+ private-desktop-mcp status
71
+ private-desktop-mcp reset
72
+ ```
73
+
74
+ ## Current canonical endpoint
30
75
 
31
76
  ```text
32
77
  https://private-desktop-device-relay.ljx2043979076.workers.dev/mcp
33
78
  ```
34
79
 
35
- Set up a remote Streamable HTTP MCP connection with Cloudflare Access OAuth. The gateway and device pairing admin page share this free workers.dev host. The old qqking.top route is a temporary fallback, not a dependency of this connector.
80
+ Client configuration templates are available in `.mcp.json` and `client-configs/` (`vscode-mcp.json`, `mcpServers.json`, `cursor-mcp.json`, `codex.toml.example`).
36
81
 
37
82
  ## Pairing devices
38
83
 
39
- 1. On a Windows machine with Node.js 20.18.1+ run `private-desktop-mcp connect` after installation (or the npx command above).
40
- 2. The first run prints an expiring pairing code and an Access-protected approval URL.
41
- 3. Sign into Cloudflare Access and approve the **matching code** in the admin page.
42
- 4. The device saves a locally scoped credential in the user's AppData and connects via WebSocket. Never commit or share that credential.
43
- 5. Leave the terminal open while using tools. Press **Ctrl+C** to disconnect. No startup tasks or Windows services are installed.
44
- 6. Reconnecting the same paired device needs no further approval. Revoke old devices from the admin page.
45
-
46
- If multiple devices are online, select the intended one at the admin page. The relay must never route to an arbitrary device when the target is ambiguous.
84
+ 1. On a machine with Node.js 20.18.1+ run `private-desktop-mcp connect`.
85
+ 2. The first run prints an expiring pairing code and opens (or prints) the Access-protected approval URL.
86
+ 3. Sign into Cloudflare Access and approve the **matching code** in `/admin/devices`.
87
+ 4. The device saves its scoped credential in `PrivateDesktopMCP/device.json` and connects via WebSocket. Never commit or share that credential.
88
+ 5. Leave the terminal open while using tools. Press **Ctrl+C** to disconnect. No startup tasks or system services are installed.
89
+ 6. With multiple devices online, switch devices directly in chat via `relay_list_devices` / `relay_select_device`, pass `_device: "<name>"` on a tool call, or select one at `/admin/devices`.
47
90
 
48
- ## Running without npm publication
91
+ ## Cloudflare deployment & self-hosting
49
92
 
50
- Install from your own checked-out repository with `npm install` then `node bin/cli.mjs connect`. To install globally from the project: `npm install -g .`.
93
+ The Worker source is in `worker/index.mjs` and `worker/auth.mjs`. Infrastructure is described in `wrangler.toml`.
51
94
 
52
- ## Cloudflare deployment
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).
96
+ 2. Configure cryptographic Access JWT verification on the Worker before deploying:
53
97
 
54
- The Worker source is in `worker/index.mjs`. The infrastructure is described by `wrangler.toml`. Production has a **separate Cloudflare Access self-hosted application** protecting exactly `/mcp` and `/admin/*`, with Owner-only policy. Device pairing paths `/relay/*` remain reachable but device WebSocket access is protected by a bearer token issued only after pairing approval.
55
-
56
- Never protect the **entire Worker** with Worker-level Access: this would prevent WebSocket connections. Never deploy the Worker without first configuring path-based Access for the MCP and admin endpoints. Use Wrangler or Cloudflare API credentials provided directly in your own secure environment.
98
+ ```bash
99
+ wrangler secret put CF_ACCESS_TEAM_DOMAIN # e.g. https://your-team.cloudflareaccess.com
100
+ wrangler secret put CF_ACCESS_AUD # Access application AUD tag
101
+ ```
57
102
 
58
- `worker/index.mjs` currently supports the legacy qqking.top host for rollback. The free workers.dev endpoint is the canonical address.
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`.
59
105
 
60
- ## Releases
106
+ ## Running from source
61
107
 
62
- - CI executes syntax tests and package validation.
63
- - Immutable versioned npm packages carry the authoritative `latest` dist-tag.
64
- - Release workflow uses **GitHub Actions OIDC npm trusted publishing** for this repository and release.yml; no long-lived npm publish token is needed.
65
- - GitHub Releases preserves the same immutable `.tgz` as a backup.
66
- - Secrets, local `device.json`, `.env`, `node_modules` and existing Cloudflare Access policies are not stored in Git.
108
+ ```bash
109
+ npm install
110
+ npm test
111
+ node bin/cli.mjs connect
112
+ ```
67
113
 
68
114
  ## Security
69
115
 
70
- This tool has Windows filesystem and command-execution capabilities. Restrict Cloudflare Access to your own identity, approve only devices you control and never expose a naked HTTP MCP endpoint. See [SECURITY.md](SECURITY.md).
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).