cloudflare-mcp
cloudflare-mcp v1.0.0
面向完整 Cloudflare 生态系统的通用 Model Context Protocol (MCP) 服务器。 用一个高性能的本地服务器取代 16 个分散的远程 MCP 端点。
功能(7 个统一工具)
cf_dns:区域、DNS 记录(A、CNAME、TXT、MX 等)、CDN 缓存清除cf_compute:Cloudflare Workers、KV 键值存储、无服务器 D1 SQL 数据库执行cf_storage:R2 对象存储桶、Vectorize 向量数据库查询cf_ai:Workers AI 推理(Llama、DeepSeek、Embeddings)、AI Gateway 日志和遥测cf_security:Zero Trust 隧道(cloudflared)、WAF 防火墙规则、审计日志cf_radar:Radar URL 扫描器、全球流量/攻击分析、GraphQL 查询cf_api:通用 REST API 网关(直接访问 2,500+ 个 Cloudflare 端点)
Related MCP server: mcp-server-cloudflare
配置
在您的环境中设置 Cloudflare API Token,或将其存储在 ~/.secrets/cloudflare-token.txt 中:
export CLOUDFLARE_API_TOKEN="your-cloudflare-api-token"
export CLOUDFLARE_ACCOUNT_ID="your-account-id" # Optional, automatically discovered if omitted在 MCP 客户端中安装(Claude Desktop、OpenCode、Cursor、Windsurf)
选项 1:通过 uvx 即时安装(推荐)
{
"mcpServers": {
"cloudflare": {
"command": "uvx",
"args": ["--from", "git+https://github.com/Steph-ux/cloudflare-mcp.git", "cloudflare-mcp"]
}
}
}选项 2:通过 pip install 安装
pip install git+https://github.com/Steph-ux/cloudflare-mcp.git然后在您的 MCP 配置中:
{
"mcpServers": {
"cloudflare": {
"command": "cloudflare-mcp"
}
}
}选项 3:本地克隆(开发)
{
"mcpServers": {
"cloudflare": {
"command": "python",
"args": ["D:\\Steph\\script\\cloudflare-mcp\\server.py"]
}
}
}使用示例
1. DNS 管理
# List zones:
cf_dns(action='list_zones')
# Create DNS record:
cf_dns(
action='create_record',
zone_id='example.com',
type='A',
name='api',
content='192.168.10.1',
proxied=True
)
# Purge CDN cache:
cf_dns(action='purge_cache', zone_id='example.com', purge_everything=True)2. D1 SQL 数据库与 Workers
# Query D1 SQL database:
cf_compute(
action='d1_query',
database_id='YOUR_D1_DATABASE_ID',
sql='SELECT * FROM users WHERE active = 1 LIMIT 10;'
)
# Store key-value in KV:
cf_compute(
action='kv_put',
namespace_id='YOUR_KV_NAMESPACE_ID',
key_name='session_token',
value='xyz123'
)3. R2 对象存储
# List buckets:
cf_storage(action='list_r2')
# Create bucket:
cf_storage(action='create_r2', bucket_name='my-app-assets', location_hint='weur')4. Workers AI 推理
# Run Llama 3 on Cloudflare edge:
cf_ai(
action='run_model',
model='@cf/meta/llama-3.1-8b-instruct',
prompt='Write a python snippet for async retry logic.'
)5. Radar URL 扫描与安全
# Scan URL for malware & phishing via Cloudflare Radar:
cf_radar(action='scan_url', url='https://target-to-scan.com')
# List active Zero Trust Tunnels:
cf_security(action='list_tunnels')6. 通用 REST 网关(cf_api)
# Call any specific Cloudflare v4 REST endpoint:
cf_api(method='GET', path='/user')测试
pytest tests许可证
MIT
This server cannot be deployed
Maintenance
Related MCP Connectors
Zero-dependency Cloudflare Worker gateway turning websites and REST APIs into MCP tools.
MCP server for AI agents to plan, verify, and deploy Cloudflare-native apps.
Cloudflare Workers MCP server: api-composition-gateway
Cloudflare Workers MCP server: api-landing
Related MCP Servers
AlicenseAqualityAmaintenanceLets you use Claude Desktop, or any MCP Client, to use natural language to accomplish things on your Cloudflare account.23,675 npm4,434Apache 2.0- AlicenseAqualityDmaintenanceMCP server to manage Cloudflare Workers, KV, R2, Pages, DNS, and cache from your IDE.1317 npm4MIT
- AlicenseNot gradedqualityDmaintenanceEnables managing Cloudflare domains, DNS records, SSL certificates, zone operations, analytics, and cache purging via MCP or CLI.3 npmMIT
- AlicenseBqualityBmaintenanceA local stdio MCP server that provides 69 tools for Cloudflare REST API v4, including DNS, Zones, Workers, KV, R2, D1, Pages, Queues, Tunnels, SSL, WAF, Email Routing, Logpush and Workers AI, authenticated by a single API token.6967 npm3MIT