cloudflare-workspace-mcp
Provides tools for managing Cloudflare resources (Pages, D1, KV, R2, Zones, Workers) via REST API and deploying Pages projects using the wrangler CLI.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@cloudflare-workspace-mcp show me my Cloudflare Pages and D1 databases"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
🌊 Cloudflare Workspace MCP
一句话:让手机上的 AI 助手拥有真实的命令行工作区,并直接管理你的 Cloudflare 账户(Pages / D1 / KV / R2)。
这是干什么的?
让手机上的 AI 助手能真正"动手干活"。
普通的 MCP 服务器只给 AI 几个固定函数(查天气、发邮件之类)。这个项目给 AI 的是一个真实的命令行工作区,外加 Cloudflare 账户管理能力。
主要面向安卓端的 AI 助手(RikkaHub、Coomi 等)。在电脑上,AI 助手通常能直接调用本机终端,不太需要这个项目;但在 Android 上 AI 没有独立运行环境,本项目用 proot 沙箱补上——给手机里的 AI 一个完整的 Debian 环境。
场景 | 说明 |
让 AI 写代码并运行 | 手机上让 AI 自己 clone 项目、装依赖、跑命令、看输出 |
部署到 Cloudflare | 手机上让 AI 直接执行 |
管理 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 装完,把 |
📋 复制这段提示词给 AI
请把 cloudflare-workspace-mcp.zip 解压到当前工作区,然后运行 bash install.sh。
如果安装中遇到问题,根据报错自动修复后重试,直到 install.sh 自检全部通过。
完成后告诉我:
1. MCP 客户端配置方法(run.sh 的绝对路径)
2. 需要我手动填写的 Cloudflare 凭据(.env 文件路径和获取地址)
全程自动执行,不要让我手动操作。🤖 AI 会自动做什么?
步骤 | AI 做的事 |
1 | 解压 ZIP 到工作区 |
2 | 运行 |
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 | ✅ | ✅ |
凭据在哪 | 🔒 本机 | 远程服务 | 远程服务 |
可扩展性 | 完整 shell,想装什么装什么 | 只有预置函数 | 只有预置函数 |
部署方式 | 本地 | 远程 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 后端;否则用 localCFMCP_BACKEND 取值:
值 | 行为 |
| 已运行在沙箱内(如 RikkaHub 工作区即 rootfs)→ 自动用 local,避免沙箱嵌套;否则检测到 proot 二进制则用 proot |
| 直接本机 shell |
| 强制 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)。
工具
工具 | 说明 |
| 在工作区执行任意 shell 命令( |
| 读取工作区文件(UTF-8) |
| 写入/覆盖工作区文件(自动建目录) |
| 列出工作区目录内容 |
| Cloudflare REST API 通用网关:任意 |
| 只读资源清单:Pages / D1 / KV / R2 / Zones / Workers, |
| 对 D1 执行只读 SQL(仅 SELECT,纯 REST,无需 wrangler/jq; |
| 部署到 Pages: |
环境变量
变量 | 必填 | 默认 | 说明 |
| ✅ | — | 工作区目录(映射为 |
|
|
| |
|
| proot 二进制/rootfs 所在目录 | |
| — | D1 数据库名( | |
| — | Pages 项目名( | |
|
| 部署源目录(相对工作区, | |
|
| 部署脚本(相对工作区,无显式参数时优先执行) | |
|
| 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 toolscloudflare_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
Scored across 8 tools
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 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.
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.
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
The bridge from K2 agents through Wrangler to your master AI - safe, approval-gated Cloudflare ops.
Work on your own computers from Claude or ChatGPT: run commands, edit and search files.
Persistent cloud workspaces for AI agents: run commands, edit files, use git and a browser.
Develop, manage, and debug Railway projects, services, and deployments from within agents.
Related MCP Servers
- AlicenseNot gradedqualityBmaintenanceEnables 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 npm1MIT
- AlicenseNot gradedqualityDmaintenanceManage Cloudflare resources such as Workers, KV, R2, D1, Durable Objects, and more using natural language via the Model Context Protocol.1,454 npmApache 2.0
- AlicenseNot gradedqualityDmaintenanceEnables natural language management of Cloudflare services including Workers, KV, R2, D1, Queues, and more via the Model Context Protocol.1,454 npmApache 2.0
- FlicenseNot gradedqualityCmaintenanceEnables 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-