Sponsored by Deepsite.site

R2 Upload MCP Server

Created By
leonho6 months ago
Cloudflare R2 Upload MCP Server
Content

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.

Recommend Servers
TraeBuild with Free GPT-4.1 & Claude 3.7. Fully MCP-Ready.
Howtocook Mcp基于Anduin2017 / HowToCook (程序员在家做饭指南)的mcp server,帮你推荐菜谱、规划膳食,解决“今天吃什么“的世纪难题; Based on Anduin2017/HowToCook (Programmer's Guide to Cooking at Home), MCP Server helps you recommend recipes, plan meals, and solve the century old problem of "what to eat today"
Context7Context7 MCP Server -- Up-to-date code documentation for LLMs and AI code editors
BlenderBlenderMCP connects Blender to Claude AI through the Model Context Protocol (MCP), allowing Claude to directly interact with and control Blender. This integration enables prompt assisted 3D modeling, scene creation, and manipulation.
Serper MCP ServerA Serper MCP Server
Baidu Map百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
WindsurfThe new purpose-built IDE to harness magic
Tavily Mcp
Jina AI MCP ToolsA Model Context Protocol (MCP) server that integrates with Jina AI Search Foundation APIs.
Visual Studio Code - Open Source ("Code - OSS")Visual Studio Code
MCP AdvisorMCP Advisor & Installation - Use the right MCP server for your needs
Zhipu Web SearchZhipu Web Search MCP Server is a search engine specifically designed for large models. It integrates four search engines, allowing users to flexibly compare and switch between them. Building upon the web crawling and ranking capabilities of traditional search engines, it enhances intent recognition capabilities, returning results more suitable for large model processing (such as webpage titles, URLs, summaries, site names, site icons, etc.). This helps AI applications achieve "dynamic knowledge acquisition" and "precise scenario adaptation" capabilities.
AiimagemultistyleA Model Context Protocol (MCP) server for image generation and manipulation using fal.ai's Stable Diffusion model.
MiniMax MCPOfficial MiniMax Model Context Protocol (MCP) server that enables interaction with powerful Text to Speech, image generation and video generation APIs.
TimeA Model Context Protocol server that provides time and timezone conversion capabilities. This server enables LLMs to get current time information and perform timezone conversions using IANA timezone names, with automatic system timezone detection.
CursorThe AI Code Editor
Playwright McpPlaywright MCP server
EdgeOne Pages MCPAn MCP service designed for deploying HTML content to EdgeOne Pages and obtaining an accessible public URL.
DeepChatYour AI Partner on Desktop
ChatWiseThe second fastest AI chatbot™
Amap Maps高德地图官方 MCP Server