This is a Model Context Protocol (MCP) server for interacting with Cloudflare services. It provides a unified interface for managing Cloudflare KV Store, R2 Storage, D1 Database, Workers, and Analytics.
get_kvs
: List all KV namespaces in your accountkv_get
: Get a value from a KV namespacekv_put
: Store a value in a KV namespacekv_list
: List keys in a KV namespacekv_delete
: Delete a key from a KV namespace
r2_list_buckets
: List all R2 buckets in your accountr2_create_bucket
: Create a new R2 bucketr2_delete_bucket
: Delete an R2 bucketr2_list_objects
: List objects in an R2 bucketr2_get_object
: Get an object from an R2 bucketr2_put_object
: Put an object into an R2 bucketr2_delete_object
: Delete an object from an R2 bucket
d1_list_databases
: List all D1 databases in your accountd1_create_database
: Create a new D1 databased1_delete_database
: Delete a D1 databased1_query
: Execute a SQL query against a D1 database
worker_list
: List all Workers in your accountworker_get
: Get a Worker's script contentworker_put
: Create or update a Worker scriptworker_delete
: Delete a Worker script
analytics_get
: Retrieve analytics data for your domain- Includes metrics like requests, bandwidth, threats, and page views
- Supports date range filtering
- Run
npx @cloudflare/mcp-server-cloudflare init
- Restart Claude Desktop, you should see a small 🔨 icon that shows the following tools available for use:
// 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" })
// 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"
})
// 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"
})
// 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
)
`
})
// Get today's analytics
analytics_get({
zoneId: "your_zone_id",
since: "2024-11-26T00:00:00Z",
until: "2024-11-26T23:59:59Z"
})
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.
Contributions are welcome! Please feel free to submit a Pull Request.