r2-mcp

YSahloul/r2-mcp

3.2

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.

Tools
  1. r2_list_buckets

    List all R2 buckets in your account

  2. r2_create_bucket

    Create a new R2 bucket

  3. r2_delete_bucket

    Delete an empty R2 bucket

  4. r2_test_bucket

    Test access to a specific bucket

  5. r2_upload_documents

    Upload documents to an R2 bucket

  6. r2_list_documents

    List objects in an R2 bucket

  7. r2_get_document

    Download an object from R2

  8. r2_delete_document

    Delete an object from R2

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

  1. Install dependencies:
npm install
  1. Configure your environment variables in .dev.vars:
CLOUDFLARE_API_TOKEN=your_api_token
  1. Update wrangler.jsonc with your credentials:
  • CLOUDFLARE_ACCOUNT_ID: Your Cloudflare account ID
  • R2_ACCESS_KEY_ID: Your R2 access key ID
  • R2_SECRET_ACCESS_KEY: Your R2 secret access key
  1. 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 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

Object Operations

  • 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

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

  1. List your buckets:

    Use: r2_list_buckets
    
  2. Create a new bucket:

    Use: r2_create_bucket
    bucketName: "my-documents"
    
  3. Upload documents:

    Use: r2_upload_documents
    bucketName: "my-documents"
    documents: [{"key": "readme.md", "content": "# Hello", "contentType": "text/markdown"}]
    
  4. List bucket contents:

    Use: r2_list_documents
    bucketName: "my-documents"
    

Development

Run locally:

npm run dev

License

MIT