@juexibobi/private-desktop-mcp 0.3.5 → 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,84 +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
15
+ ## What's new in v0.4.0
16
16
 
17
- The default `connect` command displays timestamped connection events, local gateway startup, incoming MCP method/tool names, HTTP/RPC success or failure, execution durations and reconnect activity. The terminal stays open for live monitoring.
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
- For more details, use `--debug`:
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
- ```powershell
22
- npx.cmd --yes --prefer-online --package=@juexibobi/private-desktop-mcp@latest -- private-desktop-mcp connect --debug
23
- ```
24
-
25
- ### Windows system proxy detection (v0.3.4)
26
-
27
- 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.
28
-
29
- 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.
40
+ ## Terminal logging
30
41
 
31
- 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.
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.
32
43
 
33
- ## Current independent endpoint
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.
34
45
 
35
- ```text
36
- https://private-desktop-device-relay.ljx2043979076.workers.dev/mcp
37
- ```
46
+ ## System proxy detection (Windows & macOS)
38
47
 
39
- 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.
40
-
41
- ## Pairing devices
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.
42
51
 
43
- 1. On a Windows machine with Node.js 20.18.1+ run `private-desktop-mcp connect` after installation (or the npx command above).
44
- 2. The first run prints an expiring pairing code and an Access-protected approval URL.
45
- 3. Sign into Cloudflare Access and approve the **matching code** in the admin page.
46
- 4. The device saves a locally scoped credential in the user's AppData and connects via WebSocket. Never commit or share that credential.
47
- 5. Leave the terminal open while using tools. Press **Ctrl+C** to disconnect. No startup tasks or Windows services are installed.
48
- 6. Reconnecting the same paired device needs no further approval. Revoke old devices from the admin page.
52
+ ## CLI commands & flags
49
53
 
50
- 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.
54
+ ```powershell
55
+ # Connect (default)
56
+ private-desktop-mcp connect
51
57
 
52
- ## Running without npm publication
58
+ # Safe read-only mode jailed to a workspace directory
59
+ private-desktop-mcp connect --readonly --allow-dir C:\workspace
53
60
 
54
- 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 .`.
61
+ # Connect to your own self-hosted Cloudflare Worker
62
+ private-desktop-mcp connect --relay https://my-relay.example.workers.dev --name WorkPC
55
63
 
56
- ## Cloudflare deployment
64
+ # Aggregate extra local MCP servers alongside Desktop Commander
65
+ private-desktop-mcp connect --servers ./client-configs/servers.example.json
57
66
 
58
- 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.
67
+ # Diagnostics & status
68
+ private-desktop-mcp doctor
69
+ private-desktop-mcp report
70
+ private-desktop-mcp status
71
+ private-desktop-mcp reset
72
+ ```
59
73
 
60
- 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.
74
+ ## Current canonical endpoint
61
75
 
62
- `worker/index.mjs` currently supports the legacy qqking.top host for rollback. The free workers.dev endpoint is the canonical address.
76
+ ```text
77
+ https://private-desktop-device-relay.ljx2043979076.workers.dev/mcp
78
+ ```
63
79
 
64
- ## Releases
80
+ Client configuration templates are available in `.mcp.json` and `client-configs/` (`vscode-mcp.json`, `mcpServers.json`, `cursor-mcp.json`, `codex.toml.example`).
65
81
 
66
- - CI executes syntax tests and package validation.
67
- - Immutable versioned npm packages carry the authoritative `latest` dist-tag.
68
- - Release workflow uses **GitHub Actions OIDC npm trusted publishing** for this repository and release.yml; no long-lived npm publish token is needed.
69
- - GitHub Releases preserves the same immutable `.tgz` as a backup.
70
- - Secrets, local `device.json`, `.env`, `node_modules` and existing Cloudflare Access policies are not stored in Git.
82
+ ## Pairing devices
71
83
 
72
- ## Security
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`.
73
90
 
74
- 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).
91
+ ## Cloudflare deployment & self-hosting
75
92
 
93
+ The Worker source is in `worker/index.mjs` and `worker/auth.mjs`. Infrastructure is described in `wrangler.toml`.
76
94
 
77
- ## Detailed live console (v0.3.5)
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:
78
97
 
79
- PCC now displays an expanded terminal startup banner with computer, device ID, Node version, gateway PID, local MCP URL, Cloudflare relay state and logging mode. Every incoming MCP method/tool call has a short correlation ID, safe parameter summary, MCP/HTTP outcome, duration and structured result summaries (process PID, exit code, line count and output size when available). WebSocket disconnections include close code, connection uptime, total calls and failures. A tool can fail at the MCP layer even when HTTP returns 200; this is reported as an **MCP tool error**.
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
+ ```
80
102
 
81
- Logging has three levels:
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`.
82
105
 
83
- | Command option | Terminal contents | Privacy |
84
- | --- | --- | --- |
85
- | No option | Rich startup, call and response summaries; no raw files/commands | Default |
86
- | \`--debug\` | Adds redacted request metadata, result sizes and aggregate counters | Safe diagnostic metadata |
87
- | \`--trace\` | Also shows sanitized, truncated command and response previews | **Local opt-in; may expose confidential user text** |
106
+ ## Running from source
88
107
 
89
- Example for full local previews (not recommended when screen sharing or saving terminal transcripts):
108
+ ```bash
109
+ npm install
110
+ npm test
111
+ node bin/cli.mjs connect
112
+ ```
90
113
 
91
- \`\`\`powershell
92
- npx.cmd --yes --prefer-online --package=@juexibobi/private-desktop-mcp@latest -- private-desktop-mcp connect --trace
93
- \`\`\`
114
+ ## Security
94
115
 
95
- **Important:** \`--trace\` is best-effort redaction, not a guarantee that arbitrary secrets embedded in file contents or command results will be removed. Use normal logging or \`--debug\` for everyday use. All logs print to the local terminal and are not transmitted to third-party logging services by this feature. The underlying gateway's diagnostics remain in \`%TEMP%\private-desktop-mcp-device.log\`.
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).
package/bin/activity.mjs CHANGED
@@ -110,3 +110,13 @@ export function shortCallId(id){
110
110
  export function formatElapsed(ms){
111
111
  return ms>=1000?(ms/1000).toFixed(2)+"s":ms+"ms";
112
112
  }
113
+
114
+ /** Terminal logging defaults to TRACE unless explicitly reduced. */
115
+ export function loggingOptions(args=[]){
116
+ const flags=new Set(args);
117
+ const safe=flags.has("--safe");
118
+ const debugOnly=flags.has("--debug")&&!flags.has("--trace");
119
+ const trace=!safe&&!debugOnly;
120
+ const debug=!safe&&(debugOnly||trace);
121
+ return {trace,debug,mode:trace?"TRACE":debug?"DEBUG":"LIVE"};
122
+ }