This guide walks you through deploying the Cloudflare R2 Remote MCP Worker and connecting an MCP client to it. By the end you will have a live Worker with a securedDocumentation 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.
/mcp endpoint that exposes your R2 bucket as a set of MCP tools, ready to use from ChatGPT or MCP Inspector.
Install dependencies and log in
Install project dependencies and authenticate Wrangler with your Cloudflare account.
wrangler login opens a browser window and stores an OAuth token locally. Subsequent wrangler commands use this token automatically.Create R2 buckets
Create a production bucket and a preview bucket. The preview bucket is used when running Replace
wrangler dev locally so that local operations do not touch production data.your-bucket-name and your-preview-bucket-name with names that suit your project. Bucket names must be globally unique within your Cloudflare account.Configure the Worker
Copy the example Wrangler config and edit it with your real values.Open
wrangler.jsonc and update the following fields:ALLOWED_GITHUB_LOGINS accepts a comma-separated list of GitHub usernames. Only users whose GitHub login appears in this list will be granted access through the OAuth flow.Configure local development variables
Copy the example local dev vars file. This file supplies environment variables to The copied file sets Fill in the optional fields you plan to test locally:
wrangler dev without deploying them to Cloudflare.AUTH_MODE=none so you can test locally without going through GitHub OAuth on every request.AUTH_MODE=none is for local development only. It disables all authentication checks. Never set this value on a public Worker URL unless a separate access layer (such as Cloudflare Access) protects the endpoint.Create the OAuth KV namespace
The Worker stores OAuth state (authorization codes, PKCE verifiers, session tokens) in a KV namespace. Create it with Wrangler:Wrangler prints a namespace ID similar to:Copy the generated
id value and add it to the kv_namespaces section of wrangler.jsonc:Set up GitHub OAuth App and secrets
Create the GitHub OAuth App:For Secrets are encrypted at rest in Cloudflare and are never visible in
- Go to GitHub Settings → Developer settings → OAuth Apps and click New OAuth App.
- Set Homepage URL to your Worker URL:
https://<worker-name>.<account-subdomain>.workers.dev - Set Authorization callback URL to:
- Click Register application, then generate a Client secret.
wrangler secret put. Each command prompts you to paste the value:COOKIE_ENCRYPTION_KEY, use at least 32 random bytes. You can generate a suitable value with:wrangler.jsonc or the dashboard after being set.Deploy
Deploy the Worker to Cloudflare:After a successful deploy, Wrangler prints your Worker URL. Your two key endpoints are:
Open the health endpoint in a browser or with If
| Endpoint | URL |
|---|---|
| MCP | https://<worker-name>.<account-subdomain>.workers.dev/mcp |
| Health check | https://<worker-name>.<account-subdomain>.workers.dev/healthz |
curl. A healthy response looks like:bucketAccessible is false, check that R2_BUCKET_NAME in wrangler.jsonc matches the bucket_name in r2_buckets and that the bucket exists in your account.Connect ChatGPT
In ChatGPT, open Settings → Connectors (or the custom MCP connector section) and add a new connector:
When you (or any user) first use the connector, ChatGPT redirects to GitHub for authorization. Log in with a GitHub account whose username appears in
| Field | Value |
|---|---|
| URL | https://<worker-name>.<account-subdomain>.workers.dev/mcp |
| Authentication | OAuth |
ALLOWED_GITHUB_LOGINS. After approving the OAuth App, GitHub redirects back to the Worker’s /callback endpoint, completes the token exchange, and the connector becomes active.Click Refresh tools (or equivalent) to confirm that tools such as r2_object_list appear in the connector’s tool list.Verify
Run the smoke test to confirm the deployed Worker is healthy and responding:The smoke test hits
/healthz and checks that the response confirms bucket accessibility. You can also verify manually:- Health endpoint —
GET /healthzshould return"ok": true - MCP tool list — Use MCP Inspector against
https://<worker-name>.<account-subdomain>.workers.dev/mcpand confirmr2_object_listis present - ChatGPT — Ask the connector to list objects in your bucket; it should invoke
r2_object_listand return results
What’s next
Deploy
Learn about production deployment options, custom domains, environment promotion, and rolling updates.
Authentication
Understand the GitHub OAuth flow, KV session storage, allowed login configuration, and how to rotate secrets.
MCP Tools
Explore every available MCP tool: object operations, base64 transfer, optional account tools, and presigned URLs.
Verify
Run the full verification suite, interpret health endpoint output, and troubleshoot common deployment issues.