@neuctra/r2-files-mcp
v1.0.2
Published
MCP server that gives LLMs, agents and IDEs accurate guidance for r2-files-sdk and the r2-files webhook
Maintainers
Readme
@neuctra/r2-files-mcp
An MCP server that teaches AI coding assistants (Claude Code, Cursor, VS Code Copilot, Windsurf, Codex and others) how to use @neuctra/r2-files-sdk and the r2-files webhook to upload, read, replace, list and delete files in Cloudflare R2.
Without it, assistants tend to invent methods (files.download(), getSignedUrl()), put the API key in browser code, or call the S3 API directly. With it, they look up the real functions, routes, error codes and recipes before writing code.
- Runs locally over stdio, started on demand by your editor with
npx - No API key, no account and no network access needed
- Every tool is read-only
Requires Node.js 20 or newer.
Setup
Add the server to your AI client. They all run the same command:
npx -y @neuctra/r2-files-mcpClaude Code
claude mcp add r2-files -- npx -y @neuctra/r2-files-mcpThe server is added to the current project only. Add --scope user to use it in every project, or --scope project to save it in .mcp.json and share it with your team.
Cursor, Windsurf, Claude Desktop, Gemini CLI
Add this to the client's MCP config file:
| Client | Config file |
| ------ | ----------- |
| Cursor | .cursor/mcp.json in your project, or ~/.cursor/mcp.json |
| Windsurf | ~/.codeium/windsurf/mcp_config.json |
| Claude Desktop | claude_desktop_config.json (Settings → Developer → Edit Config) |
| Gemini CLI | ~/.gemini/settings.json |
{
"mcpServers": {
"r2-files": {
"command": "npx",
"args": ["-y", "@neuctra/r2-files-mcp"]
}
}
}VS Code (Copilot agent mode)
.vscode/mcp.json:
{
"servers": {
"r2-files": {
"type": "stdio",
"command": "npx",
"args": ["-y", "@neuctra/r2-files-mcp"]
}
}
}OpenAI Codex CLI
~/.codex/config.toml:
[mcp_servers.r2-files]
command = "npx"
args = ["-y", "@neuctra/r2-files-mcp"]Windows
Some clients can't start npx directly on Windows. Wrap it in cmd:
{
"mcpServers": {
"r2-files": {
"command": "cmd",
"args": ["/c", "npx", "-y", "@neuctra/r2-files-mcp"]
}
}
}Global install (optional)
If you'd rather not go through npx, install it once and use r2-files-mcp as the command, with no args:
npm install -g @neuctra/r2-files-mcpUpdating
npx can keep running a cached older copy. To always start the newest release, use @neuctra/r2-files-mcp@latest in the args.
Tools
| Tool | What it returns |
| ---- | --------------- |
| get_guideline | Start here: architecture, the API-key model, setup and the rules for writing correct code |
| list_sdk_functions | Every SDK function and export, with signatures. Anything not listed doesn't exist |
| get_sdk_function | Options, return value, behaviour, errors and examples for one function |
| list_http_routes | Auth, response envelope, FileInfo and all routes, for non-JS clients |
| get_http_route | Parameters, curl examples and errors for one route (or the multipart protocol) |
| get_error_reference | What an error code means and how to fix it; without a code, all codes and a troubleshooting table |
| get_config_reference | Worker settings, public vs private reads, local dev, deploy, security checklist and limits |
| list_recipes / get_recipe | Next.js, Express, Cloudflare Workers, Python, avatars, private files, galleries, folders, renames |
| search_docs | Keyword search across all of the above |
Tell your agent to use it
Clients that support MCP server instructions are told automatically to check these tools before writing code. For other clients, add a line like this to AGENTS.md, CLAUDE.md, .cursor/rules or .github/copilot-instructions.md:
When writing code that uploads, reads, replaces, lists or deletes files with @neuctra/r2-files-sdk or the r2-files webhook,
use the r2-files MCP tools first: get_guideline once, then get_sdk_function for each call. Don't guess method names.Then ask your assistant something like "Add avatar uploads to my Next.js app with r2-files".
Try it without an AI client
Browse the tools in the MCP Inspector:
npx @modelcontextprotocol/inspector npx -y @neuctra/r2-files-mcpRelated
@neuctra/r2-files-sdk: the client library your code uses- r2-files webhook: the Cloudflare Worker the SDK talks to. Deploy it once to your own Cloudflare account.
Development
To work on the server itself:
git clone https://github.com/Taha-Asif-313/cloudflare-r2-opensource.git
cd cloudflare-r2-opensource/mcp
npm install
npm test # builds dist/index.js, starts it over stdio and checks the docs cover the SDK and webhookTo run your local build, point a client at node /abs/path/to/cloudflare-r2-opensource/mcp/dist/index.js instead of npx.
The content is plain data in src/docs/:
| File | Content |
| ---- | ------- |
| sdk.ts | One entry per SDK export |
| http.ts | Webhook routes and the shared HTTP basics |
| reference.ts | Guideline, server config, limits, error codes, troubleshooting |
| recipes.ts | Recipes |
When the SDK or webhook changes, update these files and run npm test. It reads sdk/src and webhook/src and fails if a public method, option field, export, error code or route is missing from the server's answers, or if a doc mentions a recipe that doesn't exist. Bump version in package.json before publishing: npm publish runs the typecheck and tests first.
License
MIT
