Skip to content

mcpx: public front-door Worker with OAuth and selector enforcement - #13697

Merged
dezren39 merged 1 commit into
mainfrom
lane-mcpx-door-20261123
Nov 23, 2026
Merged

dezren39 merged 1 commit into
mainfrom
lane-mcpx-door-20261123

Conversation

@dezren39

@dezren39 dezren39 commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

What this is

The public MCP front door for the self-hosted mcpx endpoint: a Cloudflare Worker at mcpx.security.cab, ported from the proven desktop-commander Worker (#13404) and adapted to mcpx.

  • /mcp (and bare /) is guarded by the Worker's own OAuth 2.1 authorization server: a Bearer access token issued through /authorize (Google-SSO approval page, single-use PKCE code), or the owner's machine bearer. Hosted clients (Claude, ChatGPT) cannot pass a Cloudflare Access login, so only /authorize stays behind Access.
  • The Worker presents its Access service token to the Access-gated bridge door (mcpx-link.security.cab/mcp) and proxies streamable HTTP — method, body and response (including Mcp-Session-Id and SSE streams) pass through. /v1/* is never proxied.
  • OAuth codes and tokens are stored in KV under their SHA-256, never in the clear; refresh tokens rotate.

Adaptations from the desktop-commander Worker

  • Identity: Worker mcpx, package mcpx-worker, route mcpx.security.cab, ISSUER https://mcpx.security.cab, RESOURCE https://mcpx.security.cab/mcp, SCOPE mcpx, ACCESS_AUD and OAUTH_KV per the mcpx: public endpoint at mcpx.security.cab with OAuth/Google-SSO front door and machine bearer #13657 brief; BRIDGE_BASE is https://mcpx-link.security.cab.
  • Workflows renamed to mcpx-worker-{publish,promote,tests}.yml: environment mcpx-production, concurrency mcpx-worker-lifecycle, artifact mcpx-worker-upload-<run_id>-<run_attempt>, version tag prefix mcpx-.
  • No desktop-commander references remain outside the README's historical mentions.

Bare-path equivalence

Requests to / are handled exactly as /mcp — same auth gate, same selector handling, same proxying (the upstream path is always /mcp). Covered by tests.

Filtering enforcement (src/filter.ts)

The mcpx upstream exposes no per-client hooks (X-Mcpx-Settings is ignored on /mcp; no per-session state), so the Worker polices every request and response itself. Enforcement is a pure function of (URL selector, message); nothing keys on Mcp-Session-Id.

Selector ns (consumed by the door, never forwarded; caller codemode dropped — only the code-mode surface is offered in v1):

ns Profile Set
absent conservative empty
a,b selected {a,b}
* full pass-through
  • tools/list responses expose the 4 discovery tools (mcpx_namespaces, mcpx_catalog, mcpx_types, mcpx_search); selected adds mcpx_call + mcpx_batch. mcpx_exec, mcpx_tool_invoke and any other mcpx_* extra are never listed. Paginated pages filtered with the upstream cursor passed through.
  • tools/call checked before upstream: disallowed → HTTP 200 with JSON-RPC -32602 “not exposed by this door's selector”. mcpx_namespaces allowed with its response filtered to the set; mcpx_catalog/mcpx_search allowed (metadata, unfiltered in v1); mcpx_types only when every requested namespace is in set; mcpx_call (selected only) with mcpx's dotted-name resolution; mcpx_batch/batch_call (selected only) only when every item is in set and none targets a gateway tool — one violation rejects the whole batch.
  • Batched JSON-RPC arrays are checked element by element; rejected elements get their own error while allowed elements proceed.
  • prompts/list/resources/list drop out-of-set mcpx://<ns>/ entries; prompts/get/resources/read for such a URI are rejected.
  • Responses handled in both JSON and SSE (data: lines) framings and re-emitted in kind.

v1 limitations (documented in the README): catalog/search metadata responses stay unfiltered; the flat code-mode surface is not offered. The profiles are the door-side stand-in for per-client capability ceilings — when daemon-side auth lands (#13659, aligned with #8299) the selector maps onto a ceiling instead of Worker-side filtering.

Verification

In pkgs/mcpx/worker:

  • npm ci --no-audit --no-fund — clean
  • npm test — 4 files, 44 tests passed
  • npm run typecheck — no errors

Base: origin/main @ 0a6ca03ccca7125a495ea0366e4f0a67738cd5d2.

Part of #13657

{
  "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-23T20:48:39Z",
    "session_id": "ses_e5df611f53bffeUdDmNMJWuqnm",
    "lane": null,
    "host": "amd",
    "worktree": "/home/user/git/code-mcpx-door-20261123",
    "model": null,
    "lane_start_issues": [],
    "workspace_ref": {
      "kind": "worktree",
      "id": "/home/user/git/code-mcpx-door-20261123",
      "repo": "developing-today/code",
      "branch": "lane-mcpx-door-20261123",
      "sha": "020967e21313b1e392a82dd65af928ef1c348a7c"
    },
    "auth_subject": "oc-code-03",
    "stamped_by": "fleet 0.1.0 (native)"
  }
}

Run Proof on this PR
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

Port the proven desktop-commander Worker into pkgs/mcpx/worker as the
public MCP front door for the self-hosted mcpx endpoint: OAuth 2.1
authorization server with Google-SSO approval at /authorize, machine
bearer for owner tooling, and a transparent streamable-HTTP proxy to
the Access-gated bridge door (mcpx-link.security.cab).

Bare path / is handled exactly as /mcp. The ns query parameter selects
a filtering profile (conservative by default, selected with ns=a,b,
full with ns=*) and is stripped before proxying; mcpx_* enforcement of
tools/list, tools/call, batches and mcpx:// resources happens in the
Worker itself, for both JSON and SSE framings.

Part of #13657
@coderabbitai

coderabbitai Bot commented Nov 23, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 52 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: a1f519d3-4865-4ada-9e64-85ad63563deb
Commits

Reviewing files that changed from the base of the PR and between 6d57532 and 020967e.

Files ignored due to path filters: 1

  • pkgs/mcpx/worker/package-lock.json is excluded by !**/package-lock.json
Files selected for processing: 22

  • .github/workflows/mcpx-worker-promote.yml
  • .github/workflows/mcpx-worker-publish.yml
  • .github/workflows/mcpx-worker-tests.yml
  • pkgs/mcpx/worker/README.md
  • pkgs/mcpx/worker/cloudflare.config.ts
  • pkgs/mcpx/worker/config.json
  • pkgs/mcpx/worker/package.json
  • pkgs/mcpx/worker/promote.d.mts
  • pkgs/mcpx/worker/promote.mjs
  • pkgs/mcpx/worker/src/filter.ts
  • pkgs/mcpx/worker/src/index.ts
  • pkgs/mcpx/worker/src/oauth.ts
  • pkgs/mcpx/worker/test/filter.test.ts
  • pkgs/mcpx/worker/test/memory-kv.ts
  • pkgs/mcpx/worker/test/oauth.test.ts
  • pkgs/mcpx/worker/test/promote.test.ts
  • pkgs/mcpx/worker/test/proxy.test.ts
  • pkgs/mcpx/worker/tsconfig.json
  • pkgs/mcpx/worker/upload-version.mjs
  • pkgs/mcpx/worker/verify-upload-run.mjs
  • pkgs/mcpx/worker/vitest.config.ts
  • pkgs/mcpx/worker/wrangler.toml
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant