Create the Cloudflare API token, run clodex setup, and add the connector to claude.ai.

Before you start

  • A domain whose DNS is on Cloudflare.
  • Cloudflare Zero Trust turned on for the account (free plan). Open Cloudflare One once so the account gets a team domain such as myteam.cloudflareaccess.com.
  • cloudflared installed and on your PATH.

1. Create a Cloudflare API token

In the Cloudflare dashboard go to My Profile > API Tokens > Create Token > Custom token and add:

Scope Permission
Account Cloudflare Tunnel: Edit
Account Access: Apps and Policies: Edit
Account Access: Organizations, Identity Providers, and Groups: Edit
Zone (your domain) DNS: Edit
Zone (your domain) Zone: Read

clodex uses the token only while clodex setup runs. It is never saved, logged or put on a command line, so a short expiry is fine.

2. Run setup

clodex setup --hostname clodex-mcp.example.com --email you@example.com

Setup asks for the token with hidden input; CLOUDFLARE_API_TOKEN or --api-token-stdin also work. It is idempotent and only creates or changes what is missing:

  • Access application for the hostname: self-hosted, 30-day session, an allow policy for your email, and Managed OAuth on, so Cloudflare Access is the OAuth server claude.ai signs in against. Dynamic client registration accepts only https://claude.ai/api/mcp/auth_callback. If the account has no login method at all, setup adds the email one-time PIN.
  • Named Tunnel (clodex by default, remotely managed) with ingress hostname -> http://127.0.0.1:8787 and a 404 catch-all. Other hostnames on that tunnel are kept.
  • DNS: a proxied CNAME from the hostname to the tunnel. Setup refuses to repoint a record that belongs to something else.
  • The connector token in ~/.config/clodex/tunnel.token (owner-only) and non-secret settings in ~/.config/clodex/config.toml.

On macOS, setup also opens the menu bar app and adds it to your login items (clodex itself stays off). Pass --no-menu-bar to skip that.

Use a one-level subdomain such as clodex-mcp.example.com: Cloudflare’s free certificate covers *.example.com but not deeper names.

3. Add the connector in claude.ai

  1. Settings > Connectors > Add custom connector.
  2. Name clodex, URL https://<hostname>/mcp, OAuth fields empty.
  3. Connect and sign in through Cloudflare Access.

claude.ai cannot edit a connector. To change its URL, remove it and add it again.

Changing the hostname or email

Run setup again with the new values. For a new hostname, remove the old connector in claude.ai and add the new URL; then delete the old DNS record, tunnel route and Access app in Cloudflare if nothing else uses them.

Ports

clodex listens on 127.0.0.1:8787 (MCP, the tunnel’s target) and 127.0.0.1:47787 (Liveboard). Change them with --mcp-port and --liveboard-port; setup updates the tunnel route to match.