Cloudflare MCP服务器
现代模型上下文协议(MCP)服务器 云耀 结构化的DNS、安全、重定向和区域设置功能 *工具* 任何兼容的AI客户端(例如Claude Desktop)都可以调用它。
______________________________________________________________________
✨ 主要特点
- 丰富的工具目录 –16个读写操作,涵盖DNS记录、WAF规则、页面规则重定向、缓存清除、区域设置等。
- 即插即用Claude Desktop -配备STDIO运输工具,因此克劳德立即列出并调用工具;不需要额外的适配器。
- 类型安全 –用TypeScript编写,由
@modelcontextprotocol/sdk,每个工具的参数和返回值都有zod模式。 - 默认情况下为非破坏性 -破坏性证书订购功能被禁用,以防止意外成本。
- 脚本库和测试 –手动操作和Jest集成/单元测试的一次性脚本。
______________________________________________________________________
🚀 快速开始
# 1. Clone & install
npm install
# 2. Configure credentials
cp config/.env.example .env
$EDITOR .env # put your CLOUDFLARE_API_TOKEN
# 3. Build & run the server (stdio)
npm run build
node dist/index.js # Claude Desktop will auto-detect需要沙盒吗? Cloudflare员工免费计划 允许您创建测试区。
______________________________________________________________________
🛠️ 工具目录
| 类别 | 工具名称 | 描述 |
|---|---|---|
| 概述 | echo | 连接测试的往返文本 |
| 区域 | list_zones | 枚举令牌可以访问的区域 |
| 区域 | get_zone_settings | 返回完整设置对象 |
| 区域 | list_zone_settings | 简短设置摘要 |
| DNS | list_dns_records | 读取所有DNS RR集 |
| DNS | create_dns_record\* | 添加记录 |
| DNS | update_dns_record\* | 修改记录 |
| DNS | delete_dns_record\* | 删除记录 |
| 安全 | list_waf_rules | 读取防火墙规则 |
| 安全 | create_security_rule\* | 添加防火墙规则 |
| 安全 | update_security_rule\* | 编辑防火墙规则 |
| 安全 | delete_security_rule\* | 删除防火墙规则 |
| 重定向 | list_page_rules | 列出重定向/页面规则 |
| 重定向 | create_redirect\* | 创建重定向 |
| 重定向 | delete_page_rule\* | 删除重定向 |
| 缓存 | purge_cache\* | 清除URL或所有内容 |
\*破坏性操作——小心使用。
SSL证书订购/上传功能是有意的 不 注册。通过移除中的过滤器来启用它们 src/index.ts 如果需要。
______________________________________________________________________
🧑💻 发展
# Watch-mode compile
npm run dev
# Run the full test suite
npm test
# Lint
npm run lint方便的演示脚本 scripts/ (例如。 scripts/list-dns-demo.ts).全部接受a --zone 旗帜。
______________________________________________________________________
🏗️ 建筑
src/index.ts–入口点;合并工具映射并将其注册到McpServer.src/tools/–单独的工具模块,每个导出{ tools, description }.src/cloudflare-client.ts–围绕axios+CF API基本URL的精简包装。tests/Jest测试(单元+集成)。
服务器使用MCP SDK定义的JSON-RPC 2.0通过STDIO进行通信。看 docs/API.md.
______________________________________________________________________
🤝 贡献
欢迎PR和问题!请阅读 REFERENCE.md 用于编码约定和样式指南。
- Fork → 特性分支→ PR.
- 确保
npm test通过。 - 清楚地描述工具行为或错误。
______________________________________________________________________
📜 许可证
麻省理工学院©2025杰夫·戈尔登
由Windsurf制成
