Core variables
Cloudflare KV namespace binding used for token and session storage. This is a Wrangler binding, not a plain string.See Binding the KV namespace below for setup instructions.
Base64url-encoded 32-byte key used to encrypt tokens at rest with AES-256-GCM. Generate one before deploying.
Auth variable
The authentication strategy to use. Accepted values:
oauth, bearer, api_key, custom, none.If you omit this variable, the server infers it automatically based on which other variables are present:Set it explicitly when you want to override inference or be explicit in your config.
OAuth-specific variables
These variables are required whenAUTH_STRATEGY=oauth.
Redirect URI registered with your OAuth provider. Must use HTTPS in production.
Authorization endpoint URL of your OAuth provider (e.g.,
https://accounts.google.com/o/oauth2/v2/auth).Comma-separated list of allowed redirect URIs for dynamic client registration. Restricts which redirect URIs clients may register.
When
true, any redirect URI is accepted. Never enable this in production — it introduces an open redirect vulnerability.Extra query parameters to append to the authorization URL, in
key=value&key2=value2 format. Useful for provider-specific requirements (e.g., access_type=offline&prompt=consent for Google).Client ID for the upstream provider (the service your MCP server proxies, e.g., a Google API client ID). Separate from
OAUTH_CLIENT_ID, which is your MCP server’s own OAuth identity.Accounts or user-info endpoint for the upstream provider (e.g.,
https://www.googleapis.com/oauth2/v1/userinfo).Bearer token variables
Static bearer token value. Required when
AUTH_STRATEGY=bearer. The server injects this as Authorization: Bearer <value> on every tool call.API key variables
Name of the request header used to pass the API key (e.g.,
x-api-key, X-Custom-Key).Custom headers variable
Arbitrary request headers to inject, in
Header-Name:value,Header-Name2:value2 format. Required when AUTH_STRATEGY=custom.Other variables
Override for the server’s public base URL. Set this when your server runs behind a reverse proxy that terminates TLS, so OAuth redirects and discovery documents use the correct external URL (e.g.,
https://my-mcp.example.com).Setting variables by runtime
- Cloudflare Workers
- Node.js
Use Wrangler secrets for sensitive values and Local development —
.dev.vars for local development.Production — add secrets:.dev.vars:.dev.vars
.dev.vars is the Wrangler equivalent of .env. Add it to .gitignore — it holds secrets.Binding the KV namespace
TOKENS is a Cloudflare KV namespace, not a plain environment variable. You bind it in your Wrangler config.
1
Create the namespace
2
Add the binding to wrangler.toml
wrangler.toml
wrangler.jsonc:wrangler.jsonc
The KV namespace binding is only needed for Cloudflare Workers deployments. The Node.js adapter uses in-memory storage by default.