Skip to main content

Documentation 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.

All configuration for the R2 MCP Worker is driven by environment variables. Non-sensitive values are set under the 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

AUTH_MODE
string
default:"github"
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. Requires GITHUB_CLIENT_ID, GITHUB_CLIENT_SECRET, COOKIE_ENCRYPTION_KEY, and OAUTH_KV.
  • "none" — disables authentication entirely. Suitable for local development or internal deployments protected by another mechanism. Do not use "none" for public deployments.
If omitted or set to an empty string, the Worker defaults to "github".
ALLOWED_GITHUB_LOGINS
string
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

R2_BUCKET_NAME
string
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.
R2_ROOT_PREFIX
string
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

MAX_INLINE_TEXT_BYTES
integer
default:"262144"
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.
MAX_TRANSFER_BYTES
integer
default:"1048576"
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.
MAX_LIST_LIMIT
integer
default:"100"
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

ENABLE_ACCOUNT_TOOLS
string
default:"false"
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.
ENABLE_PRESIGN_TOOLS
string
default:"false"
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 variables in this section are sensitive credentials. They must never be placed in wrangler.jsonc. Always set them with npx wrangler secret put <NAME> so they are encrypted at rest and excluded from source control.
GITHUB_CLIENT_ID
string
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.
GITHUB_CLIENT_SECRET
string
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.
Generate a secure value with:
openssl rand -base64 32
The output is a 44-character base64 string with ~256 bits of entropy — sufficient for cookie signing.

Cloudflare API

CLOUDFLARE_ACCOUNT_ID
string
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.com
CLOUDFLARE_API_TOKEN
string
A 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
string
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
string
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.
R2_S3_ENDPOINT
string
The S3-compatible endpoint URL for your R2 bucket. Not a secret — set it under vars in wrangler.jsonc. If omitted, the Worker derives it automatically from CLOUDFLARE_ACCOUNT_ID:
https://<account-id>.r2.cloudflarestorage.com
Set this explicitly if you need to override the derived value or use a custom domain endpoint.
R2_S3_REGION
string
default:"auto"
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

R2_BUCKET
R2Bucket
required
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

OAUTH_KV
KVNamespace
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

VariableTypeRequiredDefault
R2_BUCKETR2Bucket bindingAlways
AUTH_MODEstringOptional"github"
ALLOWED_GITHUB_LOGINSstringWhen AUTH_MODE=github
R2_BUCKET_NAMEstringFor admin + presign tools
R2_ROOT_PREFIXstringOptional""
MAX_INLINE_TEXT_BYTESintegerOptional262144
MAX_TRANSFER_BYTESintegerOptional1048576
MAX_LIST_LIMITintegerOptional100
ENABLE_ACCOUNT_TOOLSstringOptional"false"
ENABLE_PRESIGN_TOOLSstringOptional"false"
GITHUB_CLIENT_IDstring (secret)When AUTH_MODE=github
GITHUB_CLIENT_SECRETstring (secret)When AUTH_MODE=github
COOKIE_ENCRYPTION_KEYstring (secret)When AUTH_MODE=github
CLOUDFLARE_ACCOUNT_IDstringWhen account tools enabled
CLOUDFLARE_API_TOKENstring (secret)When account tools enabled
R2_ACCESS_KEY_IDstring (secret)When presign tools enabled
R2_SECRET_ACCESS_KEYstring (secret)When presign tools enabled
R2_S3_ENDPOINTstringOptionalDerived from account ID
R2_S3_REGIONstringOptional"auto"
OAUTH_KVKVNamespace bindingWhen AUTH_MODE=github

Build docs developers (and LLMs) love