YSahloul/r2-mcp
If you are the rightful owner of r2-mcp and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.
The R2 MCP Server is a Model Context Protocol server designed for Cloudflare R2 operations using the S3 API, enabling comprehensive bucket and object management.
r2_list_buckets
List all R2 buckets in your account
r2_create_bucket
Create a new R2 bucket
r2_delete_bucket
Delete an empty R2 bucket
r2_test_bucket
Test access to a specific bucket
r2_upload_documents
Upload documents to an R2 bucket
r2_list_documents
List objects in an R2 bucket
r2_get_document
Download an object from R2
r2_delete_document
Delete an object from R2
r2_test_connection
Test R2 credentials and connection
R2 MCP Server
A Model Context Protocol (MCP) server for Cloudflare R2 operations using the S3 API. This server provides complete R2 bucket and object management through S3-compatible endpoints, giving you full freedom to work with any R2 bucket without bindings.
Features
- Complete S3 API Integration: Full R2 operations using standard S3 protocols
- Bucket Management: List, create, and delete R2 buckets
- Object Operations: Upload, download, list, and delete objects
- Document Support: Text, JSON, YAML, Markdown, and other document formats
- No Bucket Bindings: Use R2 access keys to work with any bucket freely
- AWS V4 Signature: Proper request signing for R2 S3 API compatibility
Setup
- Install dependencies:
npm install
- Configure your environment variables in
.dev.vars
:
CLOUDFLARE_API_TOKEN=your_api_token
- Update
wrangler.jsonc
with your credentials:
CLOUDFLARE_ACCOUNT_ID
: Your Cloudflare account IDR2_ACCESS_KEY_ID
: Your R2 access key IDR2_SECRET_ACCESS_KEY
: Your R2 secret access key
- Deploy to Cloudflare Workers:
npm run deploy
Usage
Connect to your deployed MCP server using the bearer token authentication:
URL: https://your-worker.workers.dev/sse
Authorization: Bearer your_api_token
Available Tools
Bucket Operations
r2_list_buckets
- List all R2 buckets in your accountr2_create_bucket
- Create a new R2 bucketr2_delete_bucket
- Delete an empty R2 bucketr2_test_bucket
- Test access to a specific bucket
Object Operations
r2_upload_documents
- Upload documents to an R2 bucketr2_list_documents
- List objects in an R2 bucketr2_get_document
- Download an object from R2r2_delete_document
- Delete an object from R2
Connection Testing
r2_test_connection
- Test R2 credentials and connection
Supported File Types
- Text files:
.txt
,.md
,.log
- Data formats:
.json
,.yaml
,.yml
,.toml
- Configuration:
.env
,.ini
,.conf
- Documentation:
.tex
- Maximum file size: 4MB
Example Usage
-
List your buckets:
Use: r2_list_buckets
-
Create a new bucket:
Use: r2_create_bucket bucketName: "my-documents"
-
Upload documents:
Use: r2_upload_documents bucketName: "my-documents" documents: [{"key": "readme.md", "content": "# Hello", "contentType": "text/markdown"}]
-
List bucket contents:
Use: r2_list_documents bucketName: "my-documents"
Development
Run locally:
npm run dev
License
MIT