Cloudflare MCP server

Integrates with Cloudflare's API to enable management of DNS, CDN, and security configurations for web infrastructure automation.
Back to servers
Provider
GutMutCode
Release date
Feb 22, 2025
Language
TypeScript
Package
Stats
310 downloads
9 stars

The Cloudflare MCP Server enables you to interact with your Cloudflare account using natural language through the Model Context Protocol. It connects platforms like Claude Desktop, VSCode, or any MCP client to your Cloudflare resources, allowing you to manage Workers, KV stores, R2 storage, and D1 databases using conversational commands.

Installation

To install the Cloudflare MCP Server:

  1. Run the installer via npx:
npx @gutmutcode/mcp-server-cloudflare init
  1. After installation, restart Claude Desktop. You should see a small 🔨 icon indicating that the Cloudflare tools are available.

  2. Check your MCP configuration files:

    • For Cline (VSCode), you should see a cloudflare section with your account ID
    • For Windsurf, you'll also find a cloudflare section (note that Windsurf has limitations on the number of MCP tools used simultaneously)

Usage

Running the Server Independently

To run the MCP server outside of Claude:

node dist/index.js run <account-id>

If using an alternative MCP Client, use the tools/list command to get all available tools, then call them directly with the tools/call command.

KV Store Management

// List all KV namespaces
get_kvs()

// Get a value from a KV namespace
kv_get({
    namespaceId: "your_namespace_id",
    key: "myKey"
})

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

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

// Delete a key from a KV namespace
kv_delete({
    namespaceId: "your_namespace_id",
    key: "myKey"
})

R2 Storage Management

// List all R2 buckets
r2_list_buckets()

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

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

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

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

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

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

D1 Database Management

// List all D1 databases
d1_list_databases()

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

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

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

// Create a table example
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
        )
    `
})

Workers Management

// List all Workers
worker_list()

// Get a Worker's script content
worker_get({ name: "my-worker" })

// Create or update a Worker script
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 a Worker script
worker_delete({ name: "my-worker" })

Analytics

// Retrieve analytics data for your domain
analytics_get({
    zoneId: "your_zone_id",
    since: "2024-11-26T00:00:00Z",
    until: "2024-11-26T23:59:59Z"
})

Available Features

KV Store Management

  • List all KV namespaces
  • Get, store, list, and delete values in KV namespaces

R2 Storage Management

  • List, create, and delete R2 buckets
  • List, get, put, and delete objects in R2 buckets

D1 Database Management

  • List, create, and delete D1 databases
  • Execute SQL queries against D1 databases

Workers Management

  • List, get, update, and delete Worker scripts

Analytics

  • Retrieve analytics data with metrics like requests, bandwidth, threats, and page views
  • Support for date range filtering

How to add this MCP server to Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > MCP and click "Add new global MCP server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "cursor-rules-mcp": {
            "command": "npx",
            "args": [
                "-y",
                "cursor-rules-mcp"
            ]
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later