mcpField
C
cloudflare-access-app-setup

cloudflare-access-app-setup

github.com/mizchiCloud & DevOps41647 installsUpdated 1w ago
Repository

About cloudflare-access-app-setup

A skill for creating and updating a self-hosted Cloudflare Access application, email allowlist policy, and optional service token. It targets one-off setup, CI testing, and credential rotation without managing Pulumi state.

Key features

  1. 01Idempotent Access app setup
  2. 02Email allowlist policy creation
  3. 03Optional service token creation
  4. 04Configurable through env vars or CLI
  5. 05Returns app AUD and token credentials

Use cases

  1. 01Set up Access for a new Cloudflare Worker
  2. 02Add a service token for CI smoke tests
  3. 03Rotate service token credentials
  4. 04Create temporary Access apps for pull-request tests

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/mizchi/skills --skill cloudflare-access-app-setup

After installing, type/cloudflare-access-app-setupin Claude Code to confirm it loaded.

Bundled filesassets/scripts/setup-access-app.tsREADME.md

Details

From the project README

Cloudflare Access app setup (API-driven)

Creates a self-hosted Cloudflare Access application, an email-allowlist policy, and a service token for headless CLI / CI access. Idempotent: re-running updates the existing app rather than creating duplicates.

Pulumi is the recommended long-term option (declarative + drift detection), but a script is the right answer for:

  • One-shot setup when you don't want Pulumi state for a single app.
  • CI that needs to spin up an ephemeral Access app per PR for testing.
  • Replacing the service token (rotating credentials) without re-importing the rest of the stack.

When to invoke

Use when you're:

  • Setting up Access for a brand-new Cloudflare Worker without an existing Pulumi stack.
  • Adding a service token to an existing Access app for CI smoke runs.
  • Rotating service token credentials without touching the rest of infra.

What's in here

assets/scripts/setup-access-app.ts

Generic script. Reads config via env vars / CLI args, calls the Cloudflare API at https://api.cloudflare.com/client/v4/accounts/<id>/access/apps. Outputs the app's AUD (declare as worker.env.APP_ACCESS_AUD: bindings.text(aud) in cloudflare.config.ts) and, if --create-service-token, the token client_id + client_secret (paste into .env.cloudflare).

Inputs (env or CLI):

VarRequiredDefault
CLOUDFLARE_API_TOKENyes—
CLOUDFLARE_ACCOUNT_IDyes—
--nameyes—
--domainyes—
--allow-emailsone of allow-emails / service-token—
--create-service-tokenoptionalfalse
--session-durationoptional24h
--api-baseoptionalhttps://api.cloudflare.com/client/v4

When NOT to invoke

  • You already use Pulumi for infra. Use the Pulumi ZeroTrustAccessApplication resource — drift detection is worth the extra state file.
  • You need a complex policy graph (multi-tenant, group membership, time-based access). The script is intentionally narrow: one email-allowlist + one optional service token.

Source

The mnemo version (with hard-coded mnemo domain defaults) is at mizchi/mnemo/blob/main/mnemo-server/scripts/setup-access-app.mjs. The version shipped here is the same script with the domain defaults parameterized.

For manual Access operations, discover the cf command with pnpm exec cf cli search "create a self hosted Access application", then inspect its schema. The bundled helper calls the REST API directly and does not require Wrangler. See cf authentication.

Comments

Markdown supported