Skip to main content
Glama

Cloudflare MCP Server

by GutMutCode

适用于 IDE 的 Cloudflare MCP 服务器

模型上下文协议 (MCP) 是一种新的标准化协议,用于管理大型语言模型 (LLM) 与外部系统之间的上下文。在此存储库中,我们提供了Cloudflare API 的安装程序和 MCP 服务器。

这使您可以使用 Claude Desktop 和 VSCode(Cline)和 Windsurf 等 IDE 或任何 MCP 客户端,使用自然语言在您的 Cloudflare 帐户上完成操作,例如:

  • 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 '...'?

演示

设置

  1. 运行npx @gutmutcode/mcp-server-cloudflare init
  2. 重新启动 Claude Desktop,您应该会看到一个小的🔨图标,其中显示以下可用的工具:
  3. 检查 Cline 配置文件,您应该会看到一个包含您的 Cloudflare 帐户 ID 的cloudflare部分。
  4. 检查你的 Windsurf MCP 配置文件,你也应该会看到一个cloudflare部分。Windsurf 对 MCP 工具的使用有所限制,所以你不能同时使用太多工具。(与 Cline 和 Claude 不同)

特征

KV门店管理

  • get_kvs :列出您帐户中的所有 KV 命名空间
  • kv_get :从 KV 命名空间获取值
  • kv_put :将值存储在 KV 命名空间中
  • kv_list :列出 KV 命名空间中的键
  • kv_delete :从 KV 命名空间中删除一个键

R2 存储管理

  • r2_list_buckets :列出您帐户中的所有 R2 存储桶
  • r2_create_bucket :创建一个新的 R2 存储桶
  • r2_delete_bucket :删除 R2 存储桶
  • r2_list_objects :列出 R2 存储桶中的对象
  • r2_get_object :从 R2 存储桶中获取对象
  • r2_put_object :将对象放入 R2 存储桶
  • r2_delete_object :从 R2 存储桶中删除对象

D1 数据库管理

  • d1_list_databases :列出您账户中的所有 D1 数据库
  • d1_create_database :创建一个新的 D1 数据库
  • d1_delete_database :删除 D1 数据库
  • d1_query :对 D1 数据库执行 SQL 查询

工人管理

  • worker_list :列出您账户中的所有工人
  • worker_get :获取 Worker 的脚本内容
  • worker_put :创建或更新 Worker 脚本
  • worker_delete :删除 Worker 脚本

分析

  • analytics_get :检索域的分析数据
    • 包括请求、带宽、威胁和页面浏览量等指标
    • 支持日期范围过滤

发展

在当前项目文件夹中,运行:

pnpm install pnpm build:watch

然后,在第二个终端中:

node dist/index.js init

这会将 Claude Desktop 与您本地安装的版本链接起来以供您测试。

Claude 之外的用法

要在本地运行服务器,请运行node dist/index run <account-id>

如果您正在使用其他 MCP 客户端,或者在本地进行测试,请执行tools/list命令以获取所有可用工具的最新列表。然后,您可以使用tools/call命令直接调用这些工具。

工人

// 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商店

// 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 存储

// 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 数据库

// 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" })

贡献

欢迎贡献代码!欢迎提交 Pull 请求。

-
security - not tested
A
license - permissive license
-
quality - not tested

remote-capable server

The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.

MCP 服务器允许使用自然语言通过 Claude Desktop、VSCode 和其他 MCP 客户端管理 Cloudflare 资源(Workers、KV、R2、D1)。

  1. 演示
    1. 设置
      1. 特征
        1. KV门店管理
        2. R2 存储管理
        3. D1 数据库管理
        4. 工人管理
        5. 分析
      2. 发展
        1. Claude 之外的用法
          1. 工人
          2. KV商店
          3. R2 存储
          4. D1 数据库
          5. 分析
        2. 贡献

          Related MCP Servers

          • -
            security
            A
            license
            -
            quality
            Lets you use Claude Desktop, or any MCP Client, to use natural language to accomplish things on your Cloudflare account.
            Last updated -
            2,413
            2,244
            TypeScript
            Apache 2.0
            • Apple
          • -
            security
            A
            license
            -
            quality
            A lightweight MCP server for managing DNS records, purging cache, and interacting with the Cloudflare API through natural language commands.
            Last updated -
            13
            TypeScript
            MIT License
          • -
            security
            A
            license
            -
            quality
            A package that connects Claude Desktop and other MCP clients to Cloudflare Workers, enabling custom functionality to be accessed via natural language through the Model Context Protocol.
            Last updated -
            1,942
            457
            TypeScript
            Apache 2.0
          • -
            security
            F
            license
            -
            quality
            A deployable MCP (Model Context Protocol) server on Cloudflare Workers that doesn't require authentication, allowing users to create and access custom AI tools through Claude Desktop or the Cloudflare AI Playground.
            Last updated -
            TypeScript

          View all related MCP servers

          MCP directory API

          We provide all the information about MCP servers via our MCP API.

          curl -X GET 'https://glama.ai/api/mcp/v1/servers/GutMutCode/mcp-server-cloudflare'

          If you have feedback or need assistance with the MCP directory API, please join our Discord server