@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 +77 -56
- package/bin/activity.mjs +10 -0
- package/bin/cli.mjs +888 -135
- package/bin/policy.mjs +286 -0
- package/bin/proxy.mjs +173 -45
- package/gateway.mjs +231 -33
- package/package.json +9 -8
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
|
|
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
|
|
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
|
-
|
|
15
|
+
## What's new in v0.4.0
|
|
16
16
|
|
|
17
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
36
|
-
https://private-desktop-device-relay.ljx2043979076.workers.dev/mcp
|
|
37
|
-
```
|
|
46
|
+
## System proxy detection (Windows & macOS)
|
|
38
47
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
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
|
-
|
|
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
|
-
|
|
54
|
+
```powershell
|
|
55
|
+
# Connect (default)
|
|
56
|
+
private-desktop-mcp connect
|
|
51
57
|
|
|
52
|
-
|
|
58
|
+
# Safe read-only mode jailed to a workspace directory
|
|
59
|
+
private-desktop-mcp connect --readonly --allow-dir C:\workspace
|
|
53
60
|
|
|
54
|
-
|
|
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
|
-
|
|
64
|
+
# Aggregate extra local MCP servers alongside Desktop Commander
|
|
65
|
+
private-desktop-mcp connect --servers ./client-configs/servers.example.json
|
|
57
66
|
|
|
58
|
-
|
|
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
|
-
|
|
74
|
+
## Current canonical endpoint
|
|
61
75
|
|
|
62
|
-
|
|
76
|
+
```text
|
|
77
|
+
https://private-desktop-device-relay.ljx2043979076.workers.dev/mcp
|
|
78
|
+
```
|
|
63
79
|
|
|
64
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
108
|
+
```bash
|
|
109
|
+
npm install
|
|
110
|
+
npm test
|
|
111
|
+
node bin/cli.mjs connect
|
|
112
|
+
```
|
|
90
113
|
|
|
91
|
-
|
|
92
|
-
npx.cmd --yes --prefer-online --package=@juexibobi/private-desktop-mcp@latest -- private-desktop-mcp connect --trace
|
|
93
|
-
\`\`\`
|
|
114
|
+
## Security
|
|
94
115
|
|
|
95
|
-
|
|
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
|
+
}
|