logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

mcp-gateway-cloudflare-toolkit

Facilitate comprehensive orchestration of Cloudflare services via natural language interactions, enabling deployment of Workers, configuration of D1 databases, and manipulation of R2 storage objects directly through the Cloudflare API interface within an IDE's context.

Author

mcp-gateway-cloudflare-toolkit logo

GutMutCode

Apache License 2.0

Quick Info

GitHub GitHub Stars 9
NPM Weekly Downloads 0
Tools 1
Last Updated 2026-02-19

Tags

cloudflareapisapicloudflare apicloudflare managemanage cloudflare

Cloudflare Interface Toolkit for Model Context Protocol (MCP)

The Model Context Protocol (MCP) establishes a standardized mechanism for context exchange between sophisticated language models (LLMs) and external operational environments. This repository supplies an essential MCP Server implementation targeting the Cloudflare API suite, complete with an accompanying installation utility.

This integration empowers MCP Clients—such as Claude Desktop, VSCode extensions (Cline), or Windsurf—to translate conversational instructions into concrete actions within your Cloudflare tenant. For instance:

  • Initiate deployment of a fresh Worker instance, including a sample durable object implementation.
  • Provide an overview of the contents housed within the D1 database identified as '...'?
  • Transfer all stored elements from the KV namespace named '...' over to the R2 bucket named '...'?

Demonstration

Deployment Procedure

  1. Execute the initialization command: bash npx @gutmutcode/mcp-server-cloudflare init
Example console output
  1. Refresh your Claude Desktop application. A small tool indicator (resembling a 🔨) should appear, signifying the availability of the following functions:
Example tool icon Example tool list
  1. Inspect the Cline setup file; a dedicated cloudflare segment containing your account identifier should be present.
Example configuration file
  1. Verify the Windsurf MCP configuration file similarly shows a cloudflare section. Note that Windsurf imposes constraints on the concurrent utilization of multiple MCP toolsets.
Screenshot 2025-02-22 at 10 28 09 PM

Available Toolset Capabilities

Key-Value Store Operations (KV)

  • get_kvs: Enumerate all existing KV namespaces within the account.
  • kv_get: Retrieve a specific value associated with a key in a given KV namespace.
  • kv_put: Persist a key-value pair into a designated KV namespace.
  • kv_list: Obtain a manifest of keys contained within a specific KV namespace.
  • kv_delete: Remove an entry identified by key from a KV namespace.

R2 Object Storage Management

  • r2_list_buckets: List all available R2 storage containers.
  • r2_create_bucket: Provision a new R2 container.
  • r2_delete_bucket: Decommission an existing R2 container.
  • r2_list_objects: Catalog objects residing within an R2 container.
  • r2_get_object: Fetch the content of an object from an R2 container.
  • r2_put_object: Upload content to form an object within an R2 container.
  • r2_delete_object: Erase an object from an R2 container.

D1 Relational Database Administration

  • d1_list_databases: Report on all D1 instances under the account.
  • d1_create_database: Instantiate a new D1 instance.
  • d1_delete_database: Remove a specified D1 instance.
  • d1_query: Execute arbitrary Structured Query Language (SQL) against a D1 instance.

Cloudflare Worker Orchestration

  • worker_list: Obtain a roster of all deployed Workers.
  • worker_get: Retrieve the source code for a specific Worker.
  • worker_put: Deploy a new Worker script or overwrite an existing one.
  • worker_delete: Decommission a Worker script.

Usage Telemetry Retrieval

  • analytics_get: Fetch performance metrics relevant to your domain.
  • Metrics include traffic volume, data transfer, threat mitigation counts, and page view statistics.
  • Supports specification of temporal boundaries for data extraction.

Development Workflow

To facilitate local development and iteration:

  1. Install dependencies in the current directory: bash pnpm install pnpm build:watch

  2. Concurrently, launch the server in another terminal session:

bash node dist/index.js init

This process links the running Claude Desktop instance to your locally compiled server for immediate testing.

External Client Utilization

To operate the server standalone or integrate with non-Claude MCP clients, initiate it with the account ID:

bash node dist/index run

Alternative clients can query the available functionality by emitting the tools/list command, allowing direct invocation of functions via the tools/call endpoint.

Worker Script Management Examples

javascript // Obtain list of Workers worker_list()

// Fetch Worker code assets worker_get({ name: "my-worker" })

// Modify or establish Worker script worker_put({ name: "my-worker", script: "export default { async fetch(request, env, ctx) { ... }}", bindings: [ { type: "kv_namespace", name: "MY_KV", namespace_id: "abcd1234" }, { type: "r2_bucket", name: "MY_BUCKET", bucket_name: "my-files" } ], compatibility_date: "2024-01-01", compatibility_flags: ["nodejs_compat"] })

// Remove Worker definition worker_delete({ name: "my-worker" })

KV Data Access Examples

javascript // List KV data repositories get_kvs()

// Retrieve specific data point kv_get({ namespaceId: "your_namespace_id", key: "myKey" })

// Store new data point kv_put({ namespaceId: "your_namespace_id", key: "myKey", value: "myValue", expirationTtl: 3600 // Lifetime in seconds })

// Catalogue keys within a namespace kv_list({ namespaceId: "your_namespace_id", prefix: "app_", // Filter criteria limit: 10 // Maximum items to return })

// Erase designated key kv_delete({ namespaceId: "your_namespace_id", key: "myKey" })

R2 Storage Interaction Examples

javascript // List R2 containers r2_list_buckets()

// Provision a new container r2_create_bucket({ name: "my-bucket" })

// Destroy a container r2_delete_bucket({ name: "my-bucket" })

// List objects within a container r2_list_objects({ bucket: "my-bucket", prefix: "folder/", // Path prefix delimiter: "/", // Separator for hierarchy simulation limit: 1000 // Page size })

// Retrieve an object r2_get_object({ bucket: "my-bucket", key: "folder/file.txt" })

// Deposit an object r2_put_object({ bucket: "my-bucket", key: "folder/file.txt", content: "Hello, World!", contentType: "text/plain" // Optional MIME type hint })

// Eliminate an object r2_delete_object({ bucket: "my-bucket", key: "folder/file.txt" })

D1 Database Query Examples

javascript // Obtain roster of databases d1_list_databases()

// Establish a new database instance d1_create_database({ name: "my-database" })

// Terminate a database instance d1_delete_database({ databaseId: "your_database_id" })

// Execute a standard query d1_query({ databaseId: "your_database_id", query: "SELECT * FROM users WHERE age > ?", params: ["25"] // Parameter substitution array })

// Define a new 'users' schema d1_query({ databaseId: "your_database_id", query: CREATE TABLE users ( id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT NOT NULL, email TEXT UNIQUE, created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ) })

Performance Metrics Retrieval

javascript // Fetch metrics for the current day analytics_get({ zoneId: "your_zone_id", since: "2024-11-26T00:00:00Z", until: "2024-11-26T23:59:59Z" })

Collaborative Development

We welcome external contributions. Please submit a Pull Request for any desired enhancements or fixes.

Background Reference: XMLHttpRequest (XHR)

XHR is an application programming interface implemented as a JavaScript object. Its methods facilitate the dispatch of HTTP requests from a web browser towards a web server. This capability allows browser-based applications to initiate server interactions post-page load and subsequently process incoming data asynchronously. XHR forms the foundational technology underpinning Ajax methodologies. Prior to its widespread adoption, server communication relied predominantly on standard hyperlink navigation and form submissions, processes which typically necessitated a full-page refresh.

== Historical Development == The fundamental concept driving XMLHttpRequest originated in 2000 via the development team at Microsoft Outlook. This idea was subsequently integrated into the Internet Explorer 5 browser release (1999). However, the initial implementation did not utilize the standardized XMLHttpRequest identifier; instead, developers employed ActiveXObject("Msxml2.XMLHTTP") and ActiveXObject("Microsoft.XMLHTTP"). By the time Internet Explorer 7 (2006) launched, universal browser support for the XMLHttpRequest identifier was established.

The XMLHttpRequest identifier has since become the conventional interface across all major browser engines, including Mozilla's Gecko (2002), Safari 1.2 (2004), and Opera 8.0 (2005).

=== Standardization Efforts === The World Wide Web Consortium (W3C) published its initial Working Draft specification for the XMLHttpRequest object on April 5, 2006. A Level 2 specification followed as a Working Draft on February 25, 2008, introducing enhancements for tracking event progress, enabling cross-origin data transfers, and managing binary data streams. By late 2011, the Level 2 enhancements were formally incorporated into the primary specification. Development responsibilities were transferred to the WHATWG near the close of 2012, where it is now maintained as a continuous document utilizing Web IDL notation.

== Operational Usage == Executing a request using XMLHttpRequest generally involves a defined sequence of programming steps:

  1. Instantiate the XMLHttpRequest object via its constructor:
  2. Invoke the open method to define the HTTP method, specify the target resource URI, and declare whether the operation should be synchronous or asynchronous:
  3. For asynchronous requests, establish an event handler to monitor state transitions:
  4. Trigger the data transmission by calling the send method:
  5. Process state changes within the assigned event listener. Upon successful data reception from the server, the payload resides in the responseText attribute by default. When processing concludes, the object transitions to state 4, the terminal state: Aside from these core steps, XHR offers extensive configuration options for request parameters and response handling. Custom HTTP headers can be appended to guide server behavior, and payload data can be supplied to the server via the argument passed to the send call. Responses can be programmatically parsed from JSON into native JavaScript objects or streamed incrementally instead of awaiting full textual assembly. Furthermore, requests can be terminated prematurely or configured with a timeout constraint.

== Cross-Origin Communication ==

During the nascent phase of the World Wide Web, limitations were encountered in enabling secure inter-domain communication, leading to initial restrictions that have since been systematically relaxed through evolving web standards.

See Also

`