Cloudflare MCP Server
Interact with Cloudflare services using natural language through the Model Context Protocol.
Overview
The Cloudflare MCP Server allows AI models to interact with various Cloudflare services. It's part of the Model Context Protocol (MCP) system, providing a standardized way for LLMs to manage and query Cloudflare resources, automate tasks, and gain insights across application development, security, and performance.
Official Server:
Developed and maintained by Cloudflare
Key Features
Comprehensive Service Integration
Access a wide range of Cloudflare services, from Workers and DNS to security and analytics.
Natural Language Interaction
Use natural language prompts to manage and query your Cloudflare resources.
Automated Configuration & Management
Automate tasks like reading configurations, deploying Workers, and managing DNS records.
Developer Tooling
Integrate with development workflows for Workers, observability, and debugging.
Available Tools
Quick Reference
| Tool | Purpose | Category |
|---|---|---|
get_documentation | Get Cloudflare reference info | Information |
deploy_worker | Deploy Cloudflare Workers | Deployment |
get_logs | Retrieve Worker logs | Observability |
get_internet_traffic_trends | Get global internet trends | Analytics |
get_dns_query_logs | Optimize DNS performance | DNS Management |
Detailed Usage
get_documentation▶
Retrieve up-to-date reference information on Cloudflare services.
use_mcp_tool({
server_name: "cloudflare",
tool_name: "get_documentation",
arguments: {
query: "Cloudflare Workers KV"
}
});
deploy_worker▶
Deploy a new Cloudflare Worker or update an existing one.
use_mcp_tool({
server_name: "cloudflare",
tool_name: "deploy_worker",
arguments: {
name: "my-new-worker",
script: "export default { async fetch(request) { return new Response('Hello Worker!'); } }"
}
});
get_logs▶
Retrieve logs for a specific Cloudflare Worker.
use_mcp_tool({
server_name: "cloudflare",
tool_name: "get_logs",
arguments: {
worker_name: "my-worker",
time_range: "1 hour ago"
}
});
get_internet_traffic_trends▶
Get global internet traffic insights and trends from Cloudflare Radar.
use_mcp_tool({
server_name: "cloudflare",
tool_name: "get_internet_traffic_trends",
arguments: {
country: "US"
}
});
get_dns_query_logs▶
Retrieve DNS query logs to optimize performance and debug issues.
use_mcp_tool({
server_name: "cloudflare",
tool_name: "get_dns_query_logs",
arguments: {
zone_id: "your-zone-id"
}
});
Installation
{
"mcpServers": {
"cloudflare-observability": {
"command": "npx",
"args": [
"mcp-remote",
"https://observability.mcp.cloudflare.com/mcp"
]
},
"cloudflare-bindings": {
"command": "npx",
"args": [
"mcp-remote",
"https://bindings.mcp.cloudflare.com/mcp"
]
}
}
}
Deploying Your Own Cloudflare MCP Server
You can also deploy your own custom MCP server on Cloudflare Workers.
-
Create a new Worker project:
npm create cloudflare@latest -- my-mcp-server --template=cloudflare/ai/demos/remote-mcp-authless cd my-mcp-server -
Install dependencies:
npm install -
Start the development server:
npm startYour MCP server will be running on
http://localhost:8788/sse. -
Deploy to Cloudflare:
npx wrangler@latest deploy
Custom Worker Deployment:
This Docker configuration assumes you have deployed your own Cloudflare Worker MCP server and are providing its URL.
Common Use Cases
1. Automated Infrastructure Management
Manage DNS records, firewall rules, and Workers deployments through natural language:
// Update DNS record
use_mcp_tool({
server_name: "cloudflare",
tool_name: "update_dns_record",
arguments: {
zone_id: "your-zone-id",
record_id: "your-record-id",
type: "A",
name: "example.com",
content: "192.0.2.1"
}
});
2. Observability and Debugging
Query logs, analyze performance metrics, and debug Workers applications using AI agents:
// Get Worker errors
use_mcp_tool({
server_name: "cloudflare",
tool_name: "get_logs",
arguments: {
worker_name: "my-app-worker",
log_level: "error",
time_range: "24 hours"
}
});
3. Content Delivery Optimization
Configure caching, image optimization, and other CDN settings:
// Purge cache for a URL
use_mcp_tool({
server_name: "cloudflare",
tool_name: "purge_cache",
arguments: {
zone_id: "your-zone-id",
url: "https://www.example.com/image.jpg"
}
});
4. Security Policy Enforcement
Update WAF rules, manage bot protection, and configure access policies:
// Block an IP address
use_mcp_tool({
server_name: "cloudflare",
tool_name: "update_waf_rule",
arguments: {
zone_id: "your-zone-id",
rule_id: "your-rule-id",
action: "block",
filter: "ip.src eq 1.2.3.4"
}
});
5. AI-Powered Development
Build and deploy AI applications on Cloudflare Workers, leveraging MCP for seamless integration:
// Deploy an AI Worker
use_mcp_tool({
server_name: "cloudflare",
tool_name: "deploy_worker",
arguments: {
name: "ai-inference-worker",
script: "// AI inference logic here"
}
});
Related Articles
Blockchain and Web3 Development
Integrate AI with blockchain networks and Web3 tooling to manage wallets, execute transactions, call smart contracts, and build decentralized applications across multiple chains.
Filesystem MCP Server
Filesystem MCP servers enable AI models to interact with local file systems, providing capabilities for file operations, directory management, and secure file access within specified boundaries.
MySQL MCP Server
MySQL MCP servers enable AI models to interact with MySQL databases, providing capabilities for structured data operations, SQL queries, transaction management, and relational data management.