Skip to main content
Glama
cloudflare-workspace-mcp

cloudflare-workspace-mcp

by NingFlos

🌊 Cloudflare Workspace MCP

🌐 English | 中文

一句话:让手机上的 AI 助手拥有真实的命令行工作区,并直接管理你的 Cloudflare 账户(Pages / D1 / KV / R2)。

MCP Node Android License


这是干什么的?

让手机上的 AI 助手能真正"动手干活"。

普通的 MCP 服务器只给 AI 几个固定函数(查天气、发邮件之类)。这个项目给 AI 的是一个真实的命令行工作区,外加 Cloudflare 账户管理能力。

主要面向安卓端的 AI 助手(RikkaHub、Coomi 等)。在电脑上,AI 助手通常能直接调用本机终端,不太需要这个项目;但在 Android 上 AI 没有独立运行环境,本项目用 proot 沙箱补上——给手机里的 AI 一个完整的 Debian 环境。

场景

说明

让 AI 写代码并运行

手机上让 AI 自己 clone 项目、装依赖、跑命令、看输出

部署到 Cloudflare

手机上让 AI 直接执行 wrangler deploy,真实部署

管理 Cloudflare 资源

一句话让 AI 查 Pages / D1 / KV / R2,不用登录控制台

查/改手机上的文件

AI 在工作区内读写文件,路径限制在工作区内


Related MCP server: Cloudflare MCP Server

🚀 30 秒上手(手机 + AI,全自动)

只需要 3 步:

步骤

操作

1

下载本项目 ZIP(GitHub 页面 → Code → Download ZIP)

2

把 ZIP 丢给手机上的 AI 助手(RikkaHub / Coomi 等),粘贴下面这句提示词:

3

等 AI 装完,把 .env 里的 Cloudflare 凭据填上(AI 会告诉你怎么填),直接开用

📋 复制这段提示词给 AI

请把 cloudflare-workspace-mcp.zip 解压到当前工作区,然后运行 bash install.sh。
如果安装中遇到问题,根据报错自动修复后重试,直到 install.sh 自检全部通过。
完成后告诉我:
1. MCP 客户端配置方法(run.sh 的绝对路径)
2. 需要我手动填写的 Cloudflare 凭据(.env 文件路径和获取地址)
全程自动执行,不要让我手动操作。

🤖 AI 会自动做什么?

步骤

AI 做的事

1

解压 ZIP 到工作区

2

运行 install.sh:装 Node 依赖,生成 run.sh 和工作区 .env 模板(wrangler 可选,仅 cloudflare_deploy 需要)

3

自检所有依赖,缺什么当场补装

4

输出 MCP 配置 + 提示你填凭据

💡 你唯一要手动做的:在 .env 里填 Cloudflare API Token 和 Account ID(这是你的私有密钥,AI 无法替你生成)。install.sh 会提前创建好模板,不会等你用到 Cloudflare 功能才发现环境不完整。


手动安装(不想用 AI?)

# 1. 解压后进入目录,一键安装(自动装依赖 + 生成 run.sh + .env 模板 + 自检)
bash install.sh

# 2. 编辑工作区 .env 填入凭据
#    ~/workspace/.env

# 3. 把 run.sh 接入 MCP 客户端

MCP 客户端配置(mcpServers 里加一条):

{
  "mcpServers": {
    "cf-workspace": {
      "command": "/绝对路径/cloudflare-workspace-mcp/run.sh",
      "type": "stdio"
    }
  }
}

和别的 MCP 有什么不一样?

对比项

本项目

官方 Cloudflare MCP

社区远程 Workers MCP

本地 shell 工作区

✅ 有(local / proot 双后端)

❌

❌

Android 支持(无 root)

✅ proot 沙箱

❌

❌

Cloudflare 管理

✅ Pages / D1 / KV / R2

✅

✅

凭据在哪

🔒 本机 .env,不出设备

远程服务

远程服务

可扩展性

完整 shell,想装什么装什么

只有预置函数

只有预置函数

部署方式

本地 wrangler CLI + REST API,真环境

远程 API

远程 API

核心区别:别的项目给 AI 的是"专用工具包",这个项目给 AI 的是"整间办公室"——而且是本地的,凭据不出设备。


Android / proot 后端

在 Android(Termux / RikkaHub 等)上,无需 root 即可获得完整 Debian 环境:

# 1. 准备 proot 二进制(来自 Termux 的 proot 或 RikkaHub 内置):
#    libproot_exec.so + libproot_loader.so → ~/proot-bin/
# 2. 准备 Debian rootfs(约 1GB)→ ~/debian-fs/
# 3. install.sh 自动检测:存在 proot 则用 proot 后端;否则用 local

CFMCP_BACKEND 取值:

值

行为

auto(默认)

已运行在沙箱内(如 RikkaHub 工作区即 rootfs)→ 自动用 local,避免沙箱嵌套;否则检测到 proot 二进制则用 proot

local

直接本机 shell

proot

强制 proot 沙箱

RikkaHub 用户注意:RikkaHub 的工作区本身就是 rootfs(已处于沙箱内),不要再套一层 proot——auto 会自动检测并回落 local。启动日志打印 inSandbox=true/false 供排查。

依赖说明:cloudflare_api / cloudflare_status / d1_query 是纯 REST(宿主 Node 原生 fetch),不需要 wrangler;只有 cloudflare_deploy 需要 wrangler(npm install -g wrangler)。


工具

工具

说明

execute_command

在工作区执行任意 shell 命令(command / cwd / timeout)

read_file

读取工作区文件(UTF-8)

write_file

写入/覆盖工作区文件(自动建目录)

list_files

列出工作区目录内容

cloudflare_api

Cloudflare REST API 通用网关:任意 method/path/body 直通全部权限(自动注入 token / {account_id}),常用路径见 CF_API.md

cloudflare_status

只读资源清单:Pages / D1 / KV / R2 / Zones / Workers,type 可选(纯 REST,无需 wrangler)

d1_query

对 D1 执行只读 SQL(仅 SELECT,纯 REST,无需 wrangler/jq;database 参数默认取 CFMCP_D1_DB)

cloudflare_deploy

部署到 Pages:project/branch/src_dir/build_cmd 全参数化;不传参数且工作区有 CFMCP_DEPLOY_SCRIPT 时优先执行脚本(需 wrangler)


环境变量

变量

必填

默认

说明

CFMCP_WORKSPACE

✅

—

工作区目录(映射为 /workspace)

CFMCP_BACKEND

auto

local / proot / auto

CFMCP_HOME

$HOME

proot 二进制/rootfs 所在目录

CFMCP_D1_DB

—

D1 数据库名(d1_query 的 database 默认值)

CFMCP_PAGES_PROJECT

—

Pages 项目名(cloudflare_deploy 的 project 默认值)

CFMCP_DEPLOY_SRC

.

部署源目录(相对工作区,cloudflare_deploy 的 src_dir 默认值)

CFMCP_DEPLOY_SCRIPT

deploy.sh

部署脚本(相对工作区,无显式参数时优先执行)

CFMCP_ENV_FILE

$CFMCP_WORKSPACE/.env

Cloudflare 凭据文件


安全说明

  • 凭据:CLOUDFLARE_API_TOKEN / CLOUDFLARE_ACCOUNT_ID 仅从工作区 .env 读取,注入命令环境,绝不写入仓库或输出。

  • 路径防护:read_file / write_file 拒绝解析到工作区之外的路径。

  • 只读 SQL:d1_query 强制 SELECT 前缀。

  • 部署授权:cloudflare_deploy 动线上,建议在 MCP 客户端层要求用户确认。

  • 危险操作:execute_command 是完整 shell,AI 可能执行任何命令——请只对可信的 AI 暴露此服务器。


开发

npm test        # 语法检查
# CI(GitHub Actions):全新 Ubuntu 环境自动跑「install.sh 一键安装 → 启动 → 工具清单 → 执行命令」验证

License

MIT

Available Tools

8 tools
cloudflare_apiA

Cloudflare REST API 通用网关:用 method/path/body 直接调用 Cloudflare API(自动注入 token/account_id)。path 里可用 {account_id} 占位符(自动替换)。常用路径见工作区 CF_API.md。示例:GET /zones、GET /accounts/{account_id}/workers/scripts、GET /accounts/{account_id}/kv/namespaces、POST /zones。⚠️ 全权限直通,删除类操作需用户明确授权。

Inputs: path (required), body, method.

cloudflare_deployA

部署工作区目录到 Cloudflare Pages(动线上,需用户明确授权后调用)。project/branch/src_dir/build_cmd 均可参数化;不传参数且工作区有部署脚本(CFMCP_DEPLOY_SCRIPT,默认 deploy.sh)时优先执行脚本。需要 wrangler(npm install -g wrangler)。

Inputs: branch, project, src_dir, build_cmd.

cloudflare_statusA

查看 Cloudflare 账户资源清单(只读,纯 REST)。type 可选:all(默认)/pages/d1/kv/r2/zones/workers。

Inputs: type.

d1_queryA

对 D1 数据库执行只读 SQL(仅 SELECT,防误写库;纯 REST,无需 wrangler/jq)。database 默认取 .env 的 CFMCP_D1_DB。

Inputs: sql (required), database.

execute_commandB

在工作区内执行任意 shell 命令(local 后端直接本机 shell;proot 后端为 Debian 沙箱,Node + wrangler 已装)。cwd 默认 /workspace。

Inputs: command (required), cwd, timeout.

list_filesA

列出工作区下目录内容(d 前缀=目录)。

Inputs: path.

read_fileA

读取工作区下文件内容(UTF-8)。

Inputs: path (required).

write_fileA

写文件到工作区(自动创建父目录)。

Inputs: path (required), content (required).

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.7/5.0

    Scored across 8 tools

    Disambiguation4/5

    Most tools have clearly distinct purposes: file operations, shell execution, Cloudflare resource listing, API gateway, D1 query, and deployment. However, cloudflare_status, cloudflare_api, and d1_query all offer Cloudflare data access with different scope, so an agent could be uncertain which to use for a given resource query.

    Naming Consistency3/5

    Naming mixes verb_noun patterns for workspace tools (read_file, write_file, list_files) with product-prefixed names for Cloudflare tools (cloudflare_status, d1_query, cloudflare_deploy). The conventions are readable but not uniformly applied, reducing predictability.

    Tool Count5/5

    Eight tools is well-scoped for a workspace-and-Cloudflare MCP server. Each tool fills a distinct role—file operations, command execution, resource inspection, generic API access, D1 queries, and deployment—without unnecessary bloat.

    Completeness3/5

    The set covers core file read/write/list and Cloudflare management via a generic API gateway, but lacks a dedicated delete_file operation and a D1 write query. These gaps can be worked around using execute_command or cloudflare_api, but they are obvious omissions for a workspace and database tool.

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables remote MCP clients to access local filesystem and shell commands by deploying a Cloudflare Worker relay and a local daemon, providing tools like read/write files, exec commands, git status, etc.
      72 npm
      1
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      Manage Cloudflare resources such as Workers, KV, R2, D1, Durable Objects, and more using natural language via the Model Context Protocol.
      1,454 npm
      Apache 2.0
    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables natural language management of Cloudflare services including Workers, KV, R2, D1, Queues, and more via the Model Context Protocol.
      1,454 npm
      Apache 2.0
    • F
      license
      Not graded
      quality
      C
      maintenance
      Enables external AI (ChatGPT, Claude) to securely access a local workspace via Cloudflare Tunnel, providing file operations, shell commands, Git operations, and more with bearer token authentication and sandbox isolation.
      1
      -