mcpField
R
R2 Upload MCP Server

R2 Upload MCP Server

Local
github.com/leonhoFiles & Storage1Updated 73w ago

About R2 Upload MCP Server

R2 Upload MCP Server uploads local files to Cloudflare R2 for users and agents. It detects MIME types automatically and returns public URLs for uploaded files.

Key features

  1. 01Upload files to an R2 bucket
  2. 02Detect MIME types automatically
  3. 03Set custom object keys and content types
  4. 04Return public file URLs
  5. 05Configure through environment variables

Use cases

  1. 01Upload images and get public links
  2. 02Store documents in an R2 bucket
  3. 03Set an uploaded file's key or content type

MCP support

It provides MCP clients with the `upload_file` tool over stdio, uploading local files to a configured R2 bucket and returning public URLs.

Configuration

Local server config is the same for every client. Copy it into your client’s MCP config file.

No install method listed yet

We haven’t collected a package or remote endpoint for this server. Follow the instructions in the project README.

Repository

Tools

No tool list yet

Local servers expose tools only once running on your machine, and the maintainer has not provided a tool list.

Details

From the project README

R2 Upload MCP Server

A Model Context Protocol (MCP) server for uploading files to Cloudflare R2 storage.

Features

  • Upload files to R2 bucket with automatic MIME type detection
  • Support for custom object keys and content types
  • Returns public URLs for uploaded files
  • Environment variable configuration

Installation

cd apps/r2-upload
pnpm install
pnpm build

Configuration

The server automatically configures itself from environment variables. Set the following required environment variables:

Required Environment Variables
  • R2_ACCOUNT_ID: Your Cloudflare account ID
  • R2_ACCESS_KEY_ID: R2 API access key ID
  • R2_SECRET_ACCESS_KEY: R2 API secret access key
  • R2_BUCKET_NAME: Name of your R2 bucket
Optional Environment Variables
  • R2_ENDPOINT: Custom endpoint URL (defaults to https://{accountId}.r2.cloudflarestorage.com)
  • R2_CUSTOM_DOMAIN: Custom domain for public file URLs (defaults to R2 dev domain)
Getting R2 Credentials
  1. Log in to Cloudflare Dashboard
  2. Go to R2 Object Storage
  3. Create an R2 bucket if you haven't already
  4. Go to "Manage R2 API tokens"
  5. Create a new API token with read/write permissions for your bucket
  6. Note down the Access Key ID and Secret Access Key

Tools

upload_file

Upload a file to the configured R2 bucket.

Parameters:

  • filePath (required): Local file path to upload
  • key (optional): Object key/name in the bucket (defaults to filename)
  • contentType (optional): MIME type of the file (auto-detected if not provided)

Usage Example

Once environment variables are configured, you can upload files directly:

{
  "filePath": "/path/to/your/file.jpg",
  "key": "uploads/my-image.jpg"
}

Supported File Types

The server automatically detects MIME types for common file extensions:

  • Images: .jpg, .jpeg, .png, .gif, .webp
  • Documents: .pdf, .txt, .json, .html, .css
  • Scripts: .js
  • Videos: .mp4, .mov, .avi
  • Audio: .mp3, .wav

For other file types, it defaults to application/octet-stream or you can specify a custom contentType.

MCP Configuration

Add this to your mcp.json configuration file:

{
  "mcpServers": {
    "r2-upload": {
      "command": "node",
      "args": ["./apps/r2-upload/dist/index.js"],
      "env": {
        "R2_ACCOUNT_ID": "your-cloudflare-account-id",
        "R2_ACCESS_KEY_ID": "your-r2-access-key-id", 
        "R2_SECRET_ACCESS_KEY": "your-r2-secret-access-key",
        "R2_BUCKET_NAME": "your-bucket-name",
        "R2_ENDPOINT": "https://your-account-id.r2.cloudflarestorage.com",
        "R2_CUSTOM_DOMAIN": "files.yourdomain.com"
      }
    }
  }
}
Environment Variables

Configure the server by setting these environment variables in your MCP configuration. If all required environment variables are set, the server will be ready to upload files immediately.

Custom Domain Setup

If you have a custom domain configured for your R2 bucket (e.g., files.yourdomain.com), set the R2_CUSTOM_DOMAIN environment variable. The server will return public URLs using your custom domain instead of the default R2 development domain.

Running the Server

# Build first
pnpm build

# Run standalone
pnpm start

The server runs as a stdio MCP server and communicates via stdin/stdout.

Comments

Markdown supported

New to MCP?

From what the protocol is to installing your first server, these answers cover most first questions.

An open protocol that defines how AI applications connect to external tools and data in a uniform way. Clients talk to the model; MCP servers provide tools, resources and prompt templates. They exchange standard messages, so one server can be reused by many clients.