spring-boot-ai-cloudflare-r2
Spring Boot AI Cloudflare R2 MCP Server - 一个基于Spring Boot和Spring AI的Cloudflare R2对象存储MCP服务器实现
claude mcp add --transport stdio lskun-spring-boot-ai-cloudflare-r2-mcp-server docker run -i lskun/spring-boot-ai-cloudflare-r2-mcp-server:latest \ --env R2_ENDPOINT="your_r2_endpoint" \ --env R2_ACCESS_KEY_ID="your_access_key_id" \ --env R2_SECRET_ACCESS_KEY="your_secret_access_key"
How to use
This MCP server implements a Spring Boot application that integrates Spring AI capabilities with Cloudflare R2 object storage. It exposes MCP-compatible endpoints to manage Cloudflare R2 buckets and objects, including listing, creating, deleting buckets as well as uploading, downloading, listing, and deleting objects. The server relies on Cloudflare R2 credentials and endpoint configuration, which you supply via environment variables. Once running, you can issue MCP queries and operations to perform common storage tasks within your MCP-enabled environment, leveraging the underlying Spring AI integration for natural language or structured command handling when appropriate.
How to install
Prerequisites:
- Docker installed and running
- Access to a Cloudflare R2 account with credentials (R2_ACCESS_KEY_ID, R2_SECRET_ACCESS_KEY, R2_ENDPOINT) or equivalent environment-driven config
Option A: Run via Docker (recommended)
- Pull and run the image (set env vars as needed):
docker run -i
-e R2_ACCESS_KEY_ID=your_access_key_id
-e R2_SECRET_ACCESS_KEY=your_secret_access_key
-e R2_ENDPOINT=your_r2_endpoint
lskun/spring-boot-ai-cloudflare-r2-mcp-server:latest
Option B: Build from source (requires JDK and Maven)
- Install JDK 17+ and Maven 3.6+ if not using Docker.
- Clone the repository: git clone https://github.com/lskun/spring-boot-ai-cloudflare-r2-mcp-server.git
- Navigate to the project directory and set environment variables for R2 credentials: export R2_ACCESS_KEY_ID=your_access_key_id export R2_SECRET_ACCESS_KEY=your_secret_access_key export R2_ENDPOINT=your_r2_endpoint
- Build the project: mvn clean package
- Run the application locally (example using java -jar): java -jar target/spring-boot-ai-cloudflare-r2-mcp-server-0.0.1-SNAPSHOT.jar
Note: If you run locally, ensure your application.properties is configured with the R2 credentials or rely on the environment variables in your runtime environment.
Additional notes
Environment variables are critical for Cloudflare R2 access. Ensure R2_ENDPOINT points to the correct R2-compatible endpoint. If you encounter authentication failures, double-check access keys and endpoint URL. When using Docker, consider binding a host port if you need to access the MCP endpoints externally. The MCP configuration expects a single server name (spring-boot-ai-cloudflare-r2); you can extend the mcpServers map for additional instances if needed. Ensure Java 17+ compatibility and that Cloudflare R2 service is reachable from the host/container. For testing, you can use the R2ServiceClientTest equivalents to verify bucket and object operations before switching to production data.