Cloudflare MCP Server

Cloudflare MCP Server

An MCP server that allows using natural language to manage Cloudflare resources (Workers, KV, R2, D1) through Claude Desktop, VSCode, and other MCP clients.

GutMutCode

Cloud Platforms
Developer Tools
TypeScript
Visit Server

README

Cloudflare MCP Server for IDE

Model Context Protocol (MCP) is a new, standardized protocol for managing context between large language models (LLMs) and external systems. In this repository, we provide an installer as well as an MCP Server for Cloudflare's API.

This lets you use Claude Desktop, and IDE like VSCode (Cline) and Windsurf or any MCP Client, to use natural language to accomplish things on your Cloudflare account, e.g.:

  • Please deploy me a new Worker with an example durable object.
  • Can you tell me about the data in my D1 database named '...'?
  • Can you copy all the entries from my KV namespace '...' into my R2 bucket '...'?

Demo

<div align="center"> <a href="https://youtube.com/shorts/SmN-I3XBO0g?si=bg4PqM5TJTMWdtGJ">Short Demo Video</a> </div>

Setup

  1. Run npx @gutmutcode/mcp-server-cloudflare init

<div align="left"> <img src="https://github.com/user-attachments/assets/163bed75-ec0c-478a-94b2-179969a90923" alt="Example console output" width="300"/> </div>

  1. Restart Claude Desktop, you should see a small 🔨 icon that shows the following tools available for use:

<div align="left"> <img src="https://github.com/user-attachments/assets/a24275b1-1c6f-4754-96ef-dd7b9f0f5903" alt="Example tool icon" height="160"/> <img src="https://github.com/user-attachments/assets/4fb8badb-6800-4a3f-a530-a344b3584bec" alt="Example tool list" height="160"/> </div>

  1. Check out the Cline configuration file, you should see a cloudflare section with your Cloudflare account ID.

<div align="left"> <img width="292" alt="Example configuration file" src="https://github.com/user-attachments/assets/ed7444d1-739f-45d3-b259-99f0814ad894"/> </div>

  1. Check out your Windsurf MCP configuration file, you should see a cloudflare section either. Windsurf has limitation on the use of MCP tools, so you can't use too many tools at the same time. (Unlike Cline and Claude)

<div align="left"> <img width="445" alt="Screenshot 2025-02-22 at 10 28 09 PM" src="https://github.com/user-attachments/assets/431a8a9a-1669-4be1-a3cf-a1cd7ba28c94" /> </div>

Features

KV Store Management

  • get_kvs: List all KV namespaces in your account
  • kv_get: Get a value from a KV namespace
  • kv_put: Store a value in a KV namespace
  • kv_list: List keys in a KV namespace
  • kv_delete: Delete a key from a KV namespace

R2 Storage Management

  • r2_list_buckets: List all R2 buckets in your account
  • r2_create_bucket: Create a new R2 bucket
  • r2_delete_bucket: Delete an R2 bucket
  • r2_list_objects: List objects in an R2 bucket
  • r2_get_object: Get an object from an R2 bucket
  • r2_put_object: Put an object into an R2 bucket
  • r2_delete_object: Delete an object from an R2 bucket

D1 Database Management

  • d1_list_databases: List all D1 databases in your account
  • d1_create_database: Create a new D1 database
  • d1_delete_database: Delete a D1 database
  • d1_query: Execute a SQL query against a D1 database

Workers Management

  • worker_list: List all Workers in your account
  • worker_get: Get a Worker's script content
  • worker_put: Create or update a Worker script
  • worker_delete: Delete a Worker script

Analytics

  • analytics_get: Retrieve analytics data for your domain
    • Includes metrics like requests, bandwidth, threats, and page views
    • Supports date range filtering

Developing

In the current project folder, run:

pnpm install
pnpm build:watch

Then, in a second terminal:

node dist/index.js init

This will link Claude Desktop against your locally-installed version for you to test.

Usage outside of Claude

To run the server locally, run node dist/index run <account-id>.

If you're using an alternative MCP Client, or testing things locally, emit the tools/list command to get an up-to-date list of all available tools. Then you can call these directly using the tools/call command.

Workers

// List workers
worker_list()

// Get worker code
worker_get({ name: "my-worker" })

// Update worker
worker_put({
  name: "my-worker",
  script: "export default { async fetch(request, env, ctx) { ... }}",
  bindings: [
    {
      type: "kv_namespace",
      name: "MY_KV",
      namespace_id: "abcd1234"
    },
    {
      type: "r2_bucket",
      name: "MY_BUCKET",
      bucket_name: "my-files"
    }
  ],
  compatibility_date: "2024-01-01",
  compatibility_flags: ["nodejs_compat"]
})

// Delete worker
worker_delete({ name: "my-worker" })

KV Store

// List KV namespaces
get_kvs()

// Get value
kv_get({
    namespaceId: "your_namespace_id",
    key: "myKey"
})

// Store value
kv_put({
    namespaceId: "your_namespace_id",
    key: "myKey",
    value: "myValue",
    expirationTtl: 3600 // optional, in seconds
})

// List keys
kv_list({
    namespaceId: "your_namespace_id",
    prefix: "app_", // optional
    limit: 10 // optional
})

// Delete key
kv_delete({
    namespaceId: "your_namespace_id",
    key: "myKey"
})

R2 Storage

// List buckets
r2_list_buckets()

// Create bucket
r2_create_bucket({ name: "my-bucket" })

// Delete bucket
r2_delete_bucket({ name: "my-bucket" })

// List objects in bucket
r2_list_objects({ 
    bucket: "my-bucket",
    prefix: "folder/", // optional
    delimiter: "/", // optional
    limit: 1000 // optional
})

// Get object
r2_get_object({
    bucket: "my-bucket",
    key: "folder/file.txt"
})

// Put object
r2_put_object({
    bucket: "my-bucket",
    key: "folder/file.txt",
    content: "Hello, World!",
    contentType: "text/plain" // optional
})

// Delete object
r2_delete_object({
    bucket: "my-bucket",
    key: "folder/file.txt"
})

D1 Database

// List databases
d1_list_databases()

// Create database
d1_create_database({ name: "my-database" })

// Delete database
d1_delete_database({ databaseId: "your_database_id" })

// Execute a single query
d1_query({
    databaseId: "your_database_id",
    query: "SELECT * FROM users WHERE age > ?",
    params: ["25"] // optional
})

// Create a table
d1_query({
    databaseId: "your_database_id",
    query: `
        CREATE TABLE users (
            id INTEGER PRIMARY KEY AUTOINCREMENT,
            name TEXT NOT NULL,
            email TEXT UNIQUE,
            created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
        )
    `
})

Analytics

// Get today's analytics
analytics_get({
    zoneId: "your_zone_id",
    since: "2024-11-26T00:00:00Z",
    until: "2024-11-26T23:59:59Z"
})

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Playwright MCP Server

Playwright MCP Server

Provides a server utilizing Model Context Protocol to enable human-like browser automation with Playwright, allowing control over browser actions such as navigation, element interaction, and scrolling.

Featured
Local
TypeScript
MCP Package Docs Server

MCP Package Docs Server

Facilitates LLMs to efficiently access and fetch structured documentation for packages in Go, Python, and NPM, enhancing software development with multi-language support and performance optimization.

Featured
Local
TypeScript
Claude Code MCP

Claude Code MCP

An implementation of Claude Code as a Model Context Protocol server that enables using Claude's software engineering capabilities (code generation, editing, reviewing, and file operations) through the standardized MCP interface.

Featured
Local
JavaScript
@kazuph/mcp-taskmanager

@kazuph/mcp-taskmanager

Model Context Protocol server for Task Management. This allows Claude Desktop (or any MCP client) to manage and execute tasks in a queue-based system.

Featured
Local
JavaScript
Apple MCP Server

Apple MCP Server

Enables interaction with Apple apps like Messages, Notes, and Contacts through the MCP protocol to send messages, search, and open app content using natural language.

Featured
Local
TypeScript
contentful-mcp

contentful-mcp

Update, create, delete content, content-models and assets in your Contentful Space

Featured
TypeScript