Lightweight Cloudflare MCP server for managing DNS, cache, zones, and more via Cloudflare API integration
The Cloudflare-API-MCP Server is an advanced, lightweight adapter designed to enhance and expand the capabilities of various Artificial Intelligence (AI) applications through the Model Context Protocol (MCP). Built on top of Cloudflare Workers, it leverages the robustness and scalability of the Cloudflare platform to offer a seamless integration layer between AI tools like Claude Desktop, Continue, Cursor, and other potential MCP clients. This server acts as an intermediary, allowing these applications to access and manipulate various data sources such as DNS records, cache management, and more through predefined MCP methods.
The Cloudflare-API-MCP Server excels in its ability to provide a unified API gateway for AI applications, making it easy to manage domain names, update DNS records, purge cached content, list zones, and many other operations. The server is built using the create-mcp CLI, ensuring that it adheres to standard MCP practices while leveraging the advanced features provided by Cloudflare Workers.
Each method defined within the src/index.ts
file of this project is carefully crafted to be directly compatible with MCP clients, providing a clear and straightforward way for AI applications to interact with managed services. The JSDoc comments associated with these methods are essential for documenting their usage, parameters, and expected outputs, ensuring that developers can integrate them seamlessly into their workflows.
The architecture of the Cloudflare-API-MCP Server is designed around a modular structure, where each function corresponds to an individual model context (MCP) tool. These tools are defined in the src/cloudflare/
directory and are automatically available for consumption by any compliant MCP client. The implementation follows best practices for both MCP and Web Worker environments, ensuring efficient data processing and minimal latency.
graph TD
A[AI Application] -->|MCP Client| B[MCP Protocol]
B --> C[MCP Server]
C --> D[Data Source/Tool]
style A fill:#e1f5fe
style C fill:#f3e5f5
style D fill:#e8f5e8
This diagram illustrates the data flow between an AI application, its MCP client, the Cloudflare-API-MCP Server, and external data sources. The seamless interaction ensures that AI applications can efficiently access and manipulate managed services through well-defined APIs.
graph TB
subgraph "MCP Client"
A1[AiApp/MCP Client] --> B1[Fetch/Invoke Tools]
B1 --> C1[MCP Protocol & Methods]
end
subgraph "MCP Server"
D1[MCP API Gateway] --> E1[Worker Functions]=> F1[Data Source/Tool]
F1 --> G1[External Resource]
end
A1 --> D1
style A1 fill:#e1f5fe
style D1 fill:#f3e5f5
style F1 fill:#f5deb3
This diagram highlights the layered architecture of the Cloudflare-API-MCP Server, showing how MCP clients interact with worker functions to ultimately manipulate external data sources.
To start using the Cloudflare-API-MCP Server, follow these steps:
Run the following to initialize and clone the project repository:
bun create mcp cloudflare-api-mcp --clone https://github.com/amxv/cloudflare-api-mcp
This command sets up a new worker with all required dependencies.
Next, upload your Cloudflare API credentials as secrets for secure authentication:
wrangler secret put CLOUDFLARE_API_KEY
wrangler secret put CLOUDFLARE_API_EMAIL
These environment variables will be used by the server to interact with the Cloudflare REST API on behalf of your account.
By integrating the Cloudflare-API-MCP Server, an AI application can automatically manage dynamic domain configurations. This is particularly useful for hosting platforms that require frequent updates to DNS records based on real-time data (e.g., user sign-up, geographic location changes).
/**
* Create a new DNS record in a zone.
* @param zoneId {string} The ID of the zone to create the record in.
* @param name {string} The name of the DNS record.
* @param content {string} The content of the DNS record.
* @param type {string} The type of DNS record (CNAME, A, TXT, or MX).
* @param comment {string} Optional comment for the DNS record.
* @param proxied {boolean} Optional whether to proxy the record through Cloudflare.
* @return {object} The created DNS record.
*/
createDNSRecord(zoneId: string, name: string, content: string, type: string, comment?: string, proxied?: boolean) {
// Implementation
}
The server can also be used to implement cache-purging strategies in AI workflows, ensuring that the most current content is always delivered. This feature is particularly useful for applications serving dynamic content that changes frequently.
As of now, the Cloudflare-API-MCP Server supports full compatibility with two major MCP clients:
The server has demonstrated excellent performance and compatibility with various platforms and tools. For detailed information on supported APIs and their corresponding MCP clients, refer to the provided matrix below:
MCP Client | Resources | Tools | Prompts | Status |
---|---|---|---|---|
Claude Desktop | ✅ | ✅ | ✅ | Full Support |
Continue | ✅ | ✅ | ✅ | Full Support |
Cursor | ❌ | ✅ | ❌ | Tools Only |
For advanced users, the Cloudflare-API-MCP Server allows for customization through environment variables such as CLOUDFLARE_API_KEY
and CLOUDFLARE_API_EMAIL
. Additionally, security best practices, like using secrets management tools (e.g., Wrangler), ensure that sensitive information is kept secure.
A sample configuration snippet might look something like:
{
"mcpServers": {
"[server-name]": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-[name]"],
"env": {
"API_KEY": "your-api-key"
}
}
}
}
A1: The Cloudflare-API-MCP Server is designed to be compatible with any application that utilizes MCP. While it has been tested and works well with Claude Desktop, Continue, and Cursor, you can adapt and extend its functionality for other clients as needed.
A2: The main limitation is primarily related to the nature of Cloudflare Workers themselves. While they are highly scalable, very heavy operations may require adjustments in processing or task management strategies. Monitoring and optimizing worker functions can mitigate these issues.
A3: Security is handled through a combination of Cloudflare's robust security features and careful implementation practices. All API keys and other sensitive information are stored securely using secrets management tools to prevent unauthorized access.
A4: Updates can be made directly on the server by modifying the src/index.ts
file. Once changes are committed and deployments occur, MCP clients will automatically pick up these updates without needing manual intervention.
A5: Yes, while currently configured for Cloudflare API management, the architecture can be extended to incorporate other Cloudflare offerings such as Workers, R2 storage, Key-value Stores (KV), Queues, and Hyperdrive. These extensions would require minimal modifications but significant planning.
Contributing to the Cloudflare-API-MCP Server is encouraged for all developers interested in enhancing AI application integrations with MCP servers. Follow these steps to contribute:
For more information on MCP and related tools, refer to these resources:
By leveraging the Cloudflare-API-MCP Server, developers can significantly enhance the functionality of AI applications, making them more robust and adaptable to changing requirements.
RuinedFooocus is a local AI image generator and chatbot image server for seamless creative control
Learn to set up MCP Airflow Database server for efficient database interactions and querying airflow data
Simplify MySQL queries with Java-based MysqlMcpServer for easy standard input-output communication
Build stunning one-page websites track engagement create QR codes monetize content easily with Acalytica
Access NASA APIs for space data, images, asteroids, weather, and exoplanets via MCP integration
Explore CoRT MCP server for advanced self-arguing AI with multi-LLM inference and enhanced evaluation methods