Skip to content

Self-hosted Desktop Commander MCP endpoint: Worker front door, Access gate, laptop bridge #13404

Open

Description

@dezren39

Self-hosted Desktop Commander MCP endpoint (Worker front door, Access-gated, laptop bridge)

Build a self-hosted replacement for the vendor's metered Remote Desktop Commander relay, following the fleet's existing Worker patterns (atlas-search Worker, id-mail publish/promote).

Shape

  • Worker desktop-commander in pkgs/desktop-commander/worker/ (atlas-search worker layout: wrangler.toml + cloudflare.config.ts + src/): a transparent streamable-HTTP MCP proxy. workers_dev off — the only door is the Access-gated custom hostname.
  • Deploys: Cloudflare version deployments with the cf binary (cf workers versions create), driven by GitHub Actions publish + promote workflows modeled on id-mail-worker-publish.yml / id-mail-worker-promote.yml (upload version with provenance artifact; promote the verified upload to 100%).
  • Public door: commander.security.cab — Cloudflare Access app (self-hosted, 24h session) with (1) an Allow policy for the owner's Google identity via the existing Google IdP (client saved under Google sign-in for pm.security.cab: create the OAuth client (hands: interactive login) #12417, wiring under fix(pm-stack): the console is the gate for the whole public hostname #12412) and (2) a service-token policy for machine MCP clients that can send Access headers.
  • Bridge door: commander-link.security.cab — Access app, service-token-only (the atlas-search pattern), token held by the Worker as version secrets. Ingress added to the existing sandbox-link tunnel -> http://localhost:8931 on amd.
  • Laptop bridge: the packaged Desktop Commander (pkgs/desktop-commander, stdio) wrapped by supergateway in streamable-HTTP mode on 127.0.0.1:8931, run as a systemd user service; the service definition is added to the Nix home config in the same change so it survives rebuilds.
  • Secrets: by name only, in fleet secrets / GitHub environment secrets; values never in the repo or logs. New names: cloudflare.access.desktop-commander-client-id / -client-secret (bridge door), a public-door client token pair, and a dedicated deploy token cloudflare.api-token-desktop-commander-worker.

Acceptance

  • POST https://commander.security.cab/mcp with the public-door service token completes an MCP initialize + tools/list against the real Desktop Commander on amd.
  • The same URL without credentials is stopped by Access (login wall / 401).
  • A publish run uploads a new Worker version without promoting it; a promote run moves exactly that version to 100%.
  • mcpx on the laptop consumes the endpoint as a remote server (first verified client).
  • The vendor device agent (desktop-commander-remote.service) is left running until this endpoint is verified, then stood down as a separate recorded step.

Non-goals

  • No use of the vendor's hosted relay or its pairing.
  • No changes to the local stdio Desktop Commander wiring in mcpx (that path stays as-is).
{
  "direct_parent": null,
  "links": [],
  "lineage": {
    "design": null,
    "roadmap_item": null,
    "priority": null
  },
  "pm_meta": 1,
  "provenance": {
    "queue_id": null,
    "scheduled_start": null,
    "picked_up_at": null,
    "work_started_at": null,
    "created_at": "2026-11-23T15:31:25Z",
    "session_id": null,
    "lane": null,
    "host": "htch-runtime",
    "worktree": null,
    "model": null,
    "lane_start_issues": [],
    "workspace_ref": null,
    "auth_subject": "archer",
    "stamped_by": "fleet 0.1.0 (native)"
  }
}

Activity

  1. developing-today commented on Nov 23, 2026

    @developing-today
    Contributor
  2. added 5 commits that reference this issue on Nov 23, 2026
  3. dezren39 commented on Nov 23, 2026

    @dezren39
    MemberAuthor

    Build complete — endpoint live, pipeline proven end to end

    The self-hosted Desktop Commander endpoint is live at https://commander.security.cab/mcp and the full delivery pipeline has now run green end to end:

    • Publish run 45218020597 — tests, dry-run, upload with provenance artifact: success.
    • Promote run 45220046876 — verified the upload run, promoted its version to 100%: success. Active deployment a2bbae9b serves version 37e2f6a3.
    • Public door re-verified after the promote: health check answers with the client service token; no credentials gets the Access login wall (302).

    Chain: client → Access (owner Google identity, or the public service token) → Worker desktop-commander (refuses anything without an Access assertion; swaps caller material for its egress token) → Access service-token-only bridge door → sandbox-link tunnel → supergateway bridge on the laptop → packaged Desktop Commander 0.2.52. Real tool calls (initialize, tools/list, list_directory) verified through the whole chain before the pipeline proof.

    Fixes landed on the way: PR #13427 (the build), #13443 (wrangler dev-server declaration the cf versions flow requires), #13447 (first-publish baseline: a missing Worker reads as no baseline, not an error), #13453 (uploaded version resolved by its unique tag — versions-create stdout is a human panel in this cf build; plus the recorded operator promotion of run 45216887574's genuine orphaned version), #13473 (versions get needs --worker-id).

    Secrets live only in Bitwarden, by name: cloudflare.access.desktop-commander-link-client-id / -client-secret (Worker egress), cloudflare.access.desktop-commander-client-id / -client-secret (public door clients), cloudflare.api-token-desktop-commander-worker (scoped deploy token: Workers Scripts Write + Tail Read). The sandbox build copies were shredded after the build.

    Remaining, deliberately separate steps (this issue stays open for them):

    1. mcpx consumer entry — a remote-server entry pointing at the endpoint; it needs two Access headers rather than a bearer token, so the header-auth shape lands with the next laptop switch.
    2. Vendor device agent stand-down — desktop-commander-remote.service still runs as the fallback until the self-hosted door has soaked; standing it down is its own recorded step.
    3. workers.dev subdomain still enabled for the Worker — the account token cannot disable it (405/10405 on that API); the Worker's own assertion check is the guard there meanwhile (401 on /mcp without Access).
  4. added a commit that references this issue on Nov 23, 2026
  5. dezren39 commented on Nov 23, 2026

    @dezren39
    MemberAuthor

    OAuth front door — built, deployed, verified

    Hosted MCP clients (Claude, ChatGPT) connect server-side and could not pass the Cloudflare Access login at the public door: every path on commander.security.cab answered them with a 302 to the Access login, and there was no OAuth discovery to find. The Worker now runs an OAuth 2.1 authorization server, and the Access app moved to guard only the approval page.

    Code — PR #13488, merged 4421467c3776. New src/oauth.ts:

    • Discovery (public): /.well-known/oauth-protected-resource (both shapes) and /.well-known/oauth-authorization-server.
    • POST /register — dynamic client registration (RFC 7591), public clients (token_endpoint_auth_method: "none"), https / loopback-http redirect URIs; clients stored in the new KV namespace desktop-commander-oauth (ea675d3c…) under client:<id>.
    • GET/POST /authorize — the approval page. The Worker verifies the Access JWT itself (RS256 against the team JWKS, the app audience, owner email) before rendering; approval is a CSRF-nonce form POST to the same path issuing a single-use, PKCE-bound code (10 min).
    • POST /token — authorization-code exchange (PKCE S256; the code is consumed on any exchange attempt) issuing an opaque access token (1 h) plus a rotating refresh token (30 d). Codes and tokens are stored in KV under their SHA-256 (code: / at: / rt:).
    • /mcp accepts a live OAuth Bearer or the machine bearer (constant-time compare); anything else gets 401 with the resource_metadata pointer. Bridge door and proxy core unchanged. /healthz public as before; everything else 404.

    Access restructure (applied via API, in place) — the public app c84b6ade… was re-scoped from the whole hostname to commander.security.cab/authorize; its service-token policy was removed (the public service token 8430d758… still exists but is no longer accepted at this door — the machine bearer replaces it for the owner's tooling); the owner-email policy is the only one left; the app audience is unchanged (c6ddf0a5…), which is what the Worker verifies as ACCESS_AUD. The bridge-door app (commander-link) was not touched.

    Secrets — machine bearer generated on the laptop, stored in Bitwarden Secrets Manager as desktop-commander.machine-bearer, set as the GitHub environment secret MACHINE_BEARER on desktop-commander-production, and staged into the version secrets file by the publish workflow (PR #13488). Values never printed or committed.

    Deploy — publish run 45224460919 (success, head 4421467c), promote run 45224874110 (success). Active deployment 3cd1134d, version ffcc823a.

    External verification (from the sandbox, no credentials):

    • GET /mcp → 401 with WWW-Authenticate: Bearer resource_metadata="https://commander.security.cab/.well-known/oauth-protected-resource" (not a 302).
    • Both discovery documents → 200 with the specified contents.
    • GET /authorize (no creds) → 302 to the Access login — the approval page is still behind the owner's sign-in.
    • Simulated client flow: /register → 201; an authorization code seeded in KV in exactly the record shape /authorize writes → /token exchange 200; code reuse → 400; MCP initialize with the access token → desktop-commander 0.2.52; tools/list → the real tool names (get_config, read_file, write_file, list_directory, …); refresh rotation → 200 with a new pair, old refresh token reuse → 400; machine bearer → initialize 200. All test clients/tokens were deleted from KV afterwards (namespace verified empty).

    The one piece only the owner completes: the browser approval click. On the first real connection from Claude or ChatGPT, the client registers itself and redirects the owner to commander.security.cab/authorize, where the Access Google sign-in plus the approval page (naming the client) issue the first real code. That leg cannot be simulated from here — everything before and after it is verified live.

    Still open on this issue: the mcpx consumer entry (now simpler — a static Authorization: Bearer header with the machine bearer, no Access header pair needed), the vendor device-agent stand-down, and the workers.dev subdomain disable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions