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:
Set it explicitly when you want to override inference or be explicit in your config.
oauth, bearer, api_key, custom, none.If you omit this variable, the server infers it automatically based on which other variables are present:| Condition | Inferred strategy |
|---|---|
AUTH_ENABLED=true | oauth |
API_KEY is set | api_key |
BEARER_TOKEN is set | bearer |
| None of the above | none |
OAuth-specific variables
These variables are required whenAUTH_STRATEGY=oauth.
OAuth client ID registered with your authorization server.
OAuth client secret. Store this as a Wrangler secret, never in plain text.
Space-separated list of OAuth scopes to request (e.g.,
openid profile email).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).Token endpoint URL of your OAuth provider (e.g.,
https://oauth2.googleapis.com/token).Token revocation endpoint URL. Used when clients call
/revoke.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.Client secret for the upstream provider.
Base URL for the upstream provider’s API.
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
Static API key value. Required when
AUTH_STRATEGY=api_key.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).Minimum log level to emit. Accepted values:
debug, info, warning, error.Host address for the Node.js server to bind to.
Port for the Node.js server to listen on.
Maximum requests per second allowed per client before rate limiting kicks in.
Maximum number of concurrent in-flight requests per client.
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.
The KV namespace binding is only needed for Cloudflare Workers deployments. The Node.js adapter uses in-memory storage by default.