The R2 MCP Worker deploys as a Cloudflare Worker that exposes six HTTP routes: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.
/healthz, /mcp, /authorize, /callback, /token, and /register. The /mcp route is the Model Context Protocol endpoint; when AUTH_MODE=github, the OAuth routes gate all access to it. A successful deployment requires one R2 bucket binding, one KV namespace for OAuth state storage, and GitHub OAuth secrets for any public-facing instance.
Install dependencies and log in to Wrangler
Install Node dependencies and authenticate the Wrangler CLI with your Cloudflare account.
Create R2 buckets
Create a production bucket and a separate preview bucket. The preview bucket is used by local and preview Worker runs; the production bucket is used by deployed Workers.Alternatively, create buckets from the Cloudflare dashboard under R2 Object Storage → Create bucket.
Configure the Worker
Copy the example configuration file and edit it for your deployment.Open
wrangler.jsonc and update the following fields:name— unique Worker name; determines the*.workers.devsubdomainr2_buckets[0].bucket_name— your production bucket namer2_buckets[0].preview_bucket_name— your preview bucket namevars.R2_BUCKET_NAME— must matchr2_buckets[0].bucket_namevars.R2_ROOT_PREFIX— optional prefix to scope all R2 operationsvars.AUTH_MODE—"github"for public deployments,"none"for local-onlyvars.ALLOWED_GITHUB_LOGINS— comma-separated list of GitHub usernames allowed to authenticate- Feature flags —
ENABLE_ACCOUNT_TOOLS,ENABLE_PRESIGN_TOOLS
Bind the R2 bucket
Ensure the
r2_buckets block in wrangler.jsonc matches the buckets you created. All object tools in the Worker operate exclusively through this binding.Configure the OAuth state KV namespace
The OAuth flow requires a KV namespace to store short-lived state tokens during callback validation. Create the namespace and copy the ID Wrangler prints.Add the returned namespace ID to
wrangler.jsonc:Configure a GitHub OAuth App
Public deployments must use
AUTH_MODE=github. Create a GitHub OAuth App and set its Authorization callback URL to the Worker’s /callback route.Known subdomain path — if you already know your Cloudflare Workers subdomain:- Set
nameinwrangler.jsonc. - The Worker URL will be
https://<worker-name>.<account-subdomain>.workers.dev. - Set the GitHub OAuth callback to:
- Set
nameinwrangler.jsoncand deploy once with only non-secret configuration. - Copy the Worker URL printed by Wrangler or shown in the Cloudflare dashboard.
- Create or update the GitHub OAuth App callback URL:
- Proceed to set OAuth secrets below, then deploy again.
Set required secrets
Push the GitHub OAuth credentials and a cookie encryption key to the Worker’s secret store. These are required whenever Generate a strong value for
AUTH_MODE=github.COOKIE_ENCRYPTION_KEY with:(Optional) Enable account tools
Read-only Cloudflare account API tools surface R2 bucket metadata. Enable them by setting the following in Then set the API token secret:Use the narrowest token scope that can read the R2 resources required by this deployment.
wrangler.jsonc under vars:(Optional) Enable presign tools
Presigned URL tools allow the Worker to generate time-limited S3-compatible URLs for direct object access. Enable them by setting the following in Then set the R2 S3-compatible API credentials:
wrangler.jsonc under vars:If You can set
R2_S3_ENDPOINT is not set, the Worker derives it automatically from CLOUDFLARE_ACCOUNT_ID:R2_S3_ENDPOINT explicitly in vars if you need to override this.Verify locally before deploying
Start the local dev server to confirm the Worker starts, the R2 bucket binding resolves, and the health endpoint responds correctly.Then check the health endpoint:Expected response:
Exposed HTTP routes
| Route | Description |
|---|---|
GET /healthz | Health check; verifies the R2 bucket binding is accessible. Returns { "ok": true, "bucketAccessible": true } on success. |
* /mcp | Model Context Protocol endpoint. Guarded by OAuth when AUTH_MODE=github; open when AUTH_MODE=none. |
GET /authorize | OAuth 2.0 authorization endpoint. Redirects to GitHub for login. Only active when AUTH_MODE=github. |
GET /callback | OAuth 2.0 callback endpoint. Exchanges the GitHub code for a session. Only active when AUTH_MODE=github. |
POST /token | OAuth 2.0 token endpoint. Issues access tokens after successful authorization. Only active when AUTH_MODE=github. |
POST /register | OAuth 2.0 dynamic client registration endpoint. Only active when AUTH_MODE=github. |