All configuration for the R2 MCP Worker is driven by environment variables. Non-sensitive values are set under theDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/xxyoudeadpunkxx/cloudflare-r2-remote-mcp-worker/llms.txt
Use this file to discover all available pages before exploring further.
vars block in wrangler.jsonc and are visible in plain text. Sensitive values — credentials, tokens, and signing keys — must be stored as encrypted Wrangler secrets. This page is the complete reference for every variable the Worker reads.
Auth
Controls which authentication strategy the Worker enforces on the
/mcp route.Accepted values: "github" or "none"."github"— requires GitHub OAuth login. Callers must complete the OAuth flow before the Worker will serve MCP requests. RequiresGITHUB_CLIENT_ID,GITHUB_CLIENT_SECRET,COOKIE_ENCRYPTION_KEY, andOAUTH_KV."none"— disables authentication entirely. Suitable for local development or internal deployments protected by another mechanism. Do not use"none"for public deployments.
"github".Comma-separated list of GitHub usernames that are permitted to access the
/mcp route when AUTH_MODE=github. Comparison is case-insensitive.Example: "alice,bob,carol"Setting this to an empty string means no GitHub user will be granted access. You must include at least your own GitHub username for the Worker to be usable.R2 Binding and Object Scope
The name of the R2 bucket that the Worker operates on. This value must match the
bucket_name set in the r2_buckets binding in wrangler.jsonc.Required by the admin account tools (ENABLE_ACCOUNT_TOOLS=true) and the presigned URL tools (ENABLE_PRESIGN_TOOLS=true). The core object tools use the R2_BUCKET binding directly, but some operations cross-reference this name for API calls.An optional key prefix that scopes all object operations to a sub-path of the bucket. When set, every key provided by a tool caller is interpreted as relative to this prefix, and all keys returned in responses have the prefix stripped.Example: setting
R2_ROOT_PREFIX=team/data means a tool call for key report.csv operates on the object stored at team/data/report.csv.Leave empty (or omit) to operate on the full bucket.Payload Limits
Maximum number of UTF-8 bytes that the
r2_object_get tool will return inline in the MCP response. Objects larger than this limit are rejected with an error directing the caller to use a presigned URL or a streaming approach instead.Default: 262144 (256 KB). Must be a positive integer.Maximum number of bytes allowed for base64 transfer tools and Worker-mediated copy operations. This limit protects against Worker CPU and memory exhaustion when the Worker itself reads and re-encodes object data.Default:
1048576 (1 MB). Must be a positive integer.Maximum number of objects returned per
r2_object_list call. Tool callers may request a smaller page size, but they cannot exceed this ceiling.Default: 100. Must be a positive integer.Feature Flags
Set to
"true" to activate the read-only Cloudflare account admin tools (e.g. bucket metadata, usage statistics). These tools make authenticated requests to the Cloudflare REST API using CLOUDFLARE_ACCOUNT_ID and CLOUDFLARE_API_TOKEN.Both CLOUDFLARE_ACCOUNT_ID and CLOUDFLARE_API_TOKEN must be set before enabling this flag.Set to
"true" to activate the presigned URL generation tools. These tools use the AWS S3-compatible R2 API to produce time-limited, pre-authenticated URLs that grant direct access to objects without routing traffic through the Worker.R2_ACCESS_KEY_ID and R2_SECRET_ACCESS_KEY must be set before enabling this flag.Secrets — GitHub OAuth
The client ID of your GitHub OAuth App. Obtained from the GitHub Developer Settings page after creating an OAuth App.Required when
AUTH_MODE=github.The client secret of your GitHub OAuth App. Generated alongside the client ID in GitHub Developer Settings.Required when
AUTH_MODE=github.A high-entropy random string used as the key for HMAC-signing the OAuth session cookie. This prevents cookie tampering between the browser and the Worker.Required when
AUTH_MODE=github.Cloudflare API
Your Cloudflare account ID. Found in the Cloudflare dashboard URL or under Account Home → Overview. This is not a secret — set it under
vars in wrangler.jsonc.Required when ENABLE_ACCOUNT_TOOLS=true. Also used to derive the R2 S3-compatible endpoint when R2_S3_ENDPOINT is not explicitly set:
https://<account-id>.r2.cloudflarestorage.comA Cloudflare API token with read-only R2 scope. Create one at My Profile → API Tokens → Create Token using the R2:Read permission template. Store as a Wrangler secret — never place it under
vars.Required when ENABLE_ACCOUNT_TOOLS=true.R2 S3 / Presign
R2 access key ID for the S3-compatible API. Generated in the Cloudflare dashboard under R2 → Manage R2 API Tokens. Store as a Wrangler secret — never place it under
vars.Required when ENABLE_PRESIGN_TOOLS=true.R2 secret access key corresponding to
R2_ACCESS_KEY_ID. Shown only once at creation time — store it immediately as a Wrangler secret.Required when ENABLE_PRESIGN_TOOLS=true.The S3-compatible endpoint URL for your R2 bucket. Not a secret — set it under Set this explicitly if you need to override the derived value or use a custom domain endpoint.
vars in wrangler.jsonc. If omitted, the Worker derives it automatically from CLOUDFLARE_ACCOUNT_ID:The region string passed to the S3 client. R2 uses
"auto" as its canonical region identifier. Not a secret — set it under vars in wrangler.jsonc.Only change this if your S3-client tooling requires a different value for compatibility reasons.R2 Bucket Binding
The bound R2 bucket. Declared in the
r2_buckets array in wrangler.jsonc with "binding": "R2_BUCKET". The Worker accesses all R2 objects through this binding — it is the primary interface for every object read, write, delete, and list operation.This is a Cloudflare binding, not an environment variable string. It cannot be set in vars or as a Wrangler secret. It is wired up by the r2_buckets binding configuration and is always required for the Worker to function.KV Namespace Binding
A Cloudflare KV namespace binding used to store short-lived OAuth state tokens during the GitHub OAuth callback flow. The binding name must be
OAUTH_KV and the namespace ID must be set in the kv_namespaces array in wrangler.jsonc.Required when AUTH_MODE=github. The Worker will throw a startup error if this binding is missing and GitHub auth is active.Summary Table
| Variable | Type | Required | Default |
|---|---|---|---|
R2_BUCKET | R2Bucket binding | Always | — |
AUTH_MODE | string | Optional | "github" |
ALLOWED_GITHUB_LOGINS | string | When AUTH_MODE=github | — |
R2_BUCKET_NAME | string | For admin + presign tools | — |
R2_ROOT_PREFIX | string | Optional | "" |
MAX_INLINE_TEXT_BYTES | integer | Optional | 262144 |
MAX_TRANSFER_BYTES | integer | Optional | 1048576 |
MAX_LIST_LIMIT | integer | Optional | 100 |
ENABLE_ACCOUNT_TOOLS | string | Optional | "false" |
ENABLE_PRESIGN_TOOLS | string | Optional | "false" |
GITHUB_CLIENT_ID | string (secret) | When AUTH_MODE=github | — |
GITHUB_CLIENT_SECRET | string (secret) | When AUTH_MODE=github | — |
COOKIE_ENCRYPTION_KEY | string (secret) | When AUTH_MODE=github | — |
CLOUDFLARE_ACCOUNT_ID | string | When account tools enabled | — |
CLOUDFLARE_API_TOKEN | string (secret) | When account tools enabled | — |
R2_ACCESS_KEY_ID | string (secret) | When presign tools enabled | — |
R2_SECRET_ACCESS_KEY | string (secret) | When presign tools enabled | — |
R2_S3_ENDPOINT | string | Optional | Derived from account ID |
R2_S3_REGION | string | Optional | "auto" |
OAUTH_KV | KVNamespace binding | When AUTH_MODE=github | — |