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.

This page is a complete reference for every binding, environment variable, feature flag, and secret the R2 MCP Worker reads at runtime. All variables live in wrangler.jsonc under the vars block (non-sensitive values) or are pushed as Wrangler secrets (sensitive values). The full wrangler.example.jsonc template is reproduced at the bottom of this page.
wrangler.jsonc is listed in .gitignore and must never be committed to source control. Copy wrangler.example.jsonc to wrangler.jsonc locally and fill in real values there.

Wrangler bindings

Bindings are declared in wrangler.jsonc and injected into the Worker’s Env interface at runtime.
BindingTypeRequiredDescription
R2_BUCKETR2BucketAlwaysThe bound R2 bucket. All object read/write tools operate through this binding.
OAUTH_KVKVNamespaceWhen AUTH_MODE=githubKV namespace used to store short-lived OAuth state tokens during the authorization callback flow.

Core variables

These values are set under vars in wrangler.jsonc. They are not secret and are visible in the Wrangler config file.
VariableTypeDefaultDescription
AUTH_MODE"github" | "none""github"Authentication mode. Use "github" for all public deployments. Use "none" only for local development or deployments protected by an external layer.
ALLOWED_GITHUB_LOGINSstringComma-separated list of GitHub usernames permitted to authenticate. All other GitHub accounts are rejected. Only used when AUTH_MODE=github.
R2_BUCKET_NAMEstringThe name of the bound R2 bucket. Must match r2_buckets[0].bucket_name. Used by account tools and presign tools to identify the bucket.
R2_ROOT_PREFIXstring""Optional key prefix that scopes all R2 operations to a virtual subdirectory. For example, setting "data" restricts the Worker to keys starting with data/.
MAX_INLINE_TEXT_BYTESinteger262144Maximum number of bytes for text object content to be returned inline in a tool response. Objects larger than this threshold are not inlined.
MAX_TRANSFER_BYTESinteger1048576Maximum number of bytes permitted in a single R2 read or write operation. Requests exceeding this limit are rejected.
MAX_LIST_LIMITinteger100Maximum number of objects returned per R2 list operation.
ENABLE_ACCOUNT_TOOLS"true" | "false""false"Set to "true" to enable read-only Cloudflare account API tools that surface R2 bucket metadata. Requires CLOUDFLARE_ACCOUNT_ID and CLOUDFLARE_API_TOKEN.
ENABLE_PRESIGN_TOOLS"true" | "false""false"Set to "true" to enable presigned URL generation tools. Requires R2_ACCESS_KEY_ID, R2_SECRET_ACCESS_KEY, and either R2_S3_ENDPOINT or CLOUDFLARE_ACCOUNT_ID.

Secrets

Secrets are stored outside wrangler.jsonc and pushed to Cloudflare with npx wrangler secret put. They are never written to disk or included in deployments as plaintext.
SecretRequiredDescription
GITHUB_CLIENT_IDWhen AUTH_MODE=githubOAuth App client ID from your GitHub OAuth App settings.
GITHUB_CLIENT_SECRETWhen AUTH_MODE=githubOAuth App client secret from your GitHub OAuth App settings.
COOKIE_ENCRYPTION_KEYWhen AUTH_MODE=githubKey used to encrypt session cookies. Must be at least 32 random bytes.
CLOUDFLARE_API_TOKENWhen ENABLE_ACCOUNT_TOOLS=trueCloudflare API token with read access to R2 resources. Use the narrowest scope sufficient for the deployment.
R2_ACCESS_KEY_IDWhen ENABLE_PRESIGN_TOOLS=trueR2 S3-compatible API access key ID, used to sign presigned URLs.
R2_SECRET_ACCESS_KEYWhen ENABLE_PRESIGN_TOOLS=trueR2 S3-compatible API secret access key, used to sign presigned URLs.
Generate a strong COOKIE_ENCRYPTION_KEY value with:
openssl rand -base64 32

Optional account and presign variables

CLOUDFLARE_ACCOUNT_ID is required by both account tools (ENABLE_ACCOUNT_TOOLS=true) and presign tools (ENABLE_PRESIGN_TOOLS=true). R2_S3_ENDPOINT and R2_S3_REGION are only used when ENABLE_PRESIGN_TOOLS=true.
VariableTypeDefaultDescription
CLOUDFLARE_ACCOUNT_IDstringYour Cloudflare account ID. Required by account tools and used to derive R2_S3_ENDPOINT for presign tools when that variable is not set explicitly.
R2_S3_ENDPOINTstringDerived from CLOUDFLARE_ACCOUNT_IDFull S3-compatible endpoint URL for R2. If omitted, the Worker derives it as https://<CLOUDFLARE_ACCOUNT_ID>.r2.cloudflarestorage.com. Only used when ENABLE_PRESIGN_TOOLS=true.
R2_S3_REGIONstring"auto"S3 region string passed to the AWS SDK when generating presigned URLs. Cloudflare R2 accepts "auto". Only used when ENABLE_PRESIGN_TOOLS=true.

Full wrangler.example.jsonc

Use this file as the starting point for your wrangler.jsonc. Replace placeholder values with your real bucket names, KV namespace ID, GitHub logins, and feature flag settings.
{
  "$schema": "node_modules/wrangler/config-schema.json",
  "name": "cloudflare-r2-remote-mcp-worker",
  "main": "src/index.ts",
  "compatibility_date": "2026-05-01",
  "compatibility_flags": ["nodejs_compat", "global_fetch_strictly_public"],
  "r2_buckets": [
    {
      "binding": "R2_BUCKET",
      "bucket_name": "example-bucket",
      "preview_bucket_name": "example-bucket-preview"
    }
  ],
  "kv_namespaces": [
    {
      "binding": "OAUTH_KV",
      "id": "00000000000000000000000000000000"
    }
  ],
  "vars": {
    "AUTH_MODE": "github",
    "ALLOWED_GITHUB_LOGINS": "your-github-login",
    "R2_BUCKET_NAME": "example-bucket",
    "R2_ROOT_PREFIX": "",
    "MAX_INLINE_TEXT_BYTES": "262144",
    "MAX_TRANSFER_BYTES": "1048576",
    "MAX_LIST_LIMIT": "100",
    "ENABLE_ACCOUNT_TOOLS": "false",
    "ENABLE_PRESIGN_TOOLS": "false"
  },
  "observability": {
    "enabled": true
  },
  "dev": {
    "port": 8787
  }
}

Build docs developers (and LLMs) love