|
1 | | -# Cloudflare MCP Server (WIP) |
| 1 | +# Cloudflare MCP Server |
2 | 2 |
|
3 | | -This is a Model Context Protocol (MCP) server for interacting with Cloudflare services. It provides a unified interface for managing Cloudflare KV Store, R2 Storage, D1 Database, Workers, and Analytics. |
| 3 | +Model Context Protocol (MCP) is a [new, standardized protocol](https://modelcontextprotocol.io/introduction) for managing context between large language models (LLMs) and external systems. In this repository, we provide an installer as well as an MCP Server for [Cloudflare's API](https://api.cloudflare.com). |
| 4 | + |
| 5 | +This lets you use Claude Desktop, or any MCP Client, to use natural language to accomplish things on your Cloudflare account, e.g.: |
| 6 | + |
| 7 | +* `Please deploy me a new Worker with an example durable object.` |
| 8 | +* `Can you tell me about the data in my D1 database named '...'?` |
| 9 | +* `Can you copy all the entries from my KV namespace '...' into my R2 bucket '...'?` |
| 10 | + |
| 11 | +## Demo |
| 12 | + |
| 13 | +<div align="center"> |
| 14 | + <a href="https://www.youtube.com/watch?v=vGajZpl_9yA"> |
| 15 | + <img src="https://img.youtube.com/vi/vGajZpl_9yA/maxresdefault.jpg" alt="Demonstrating the newly-released MCP server to explore Cloudflare properties, like Workers, KV, and D1." width="600"/> |
| 16 | + </a> |
| 17 | +</div> |
| 18 | + |
| 19 | +## Setup |
| 20 | + |
| 21 | +1. Run `npx @cloudflare/mcp-server-cloudflare init` |
| 22 | + |
| 23 | +<div align="left"> |
| 24 | + <img src="https://github.com/user-attachments/assets/163bed75-ec0c-478a-94b2-179969a90923" alt="Example console output" width="300"/> |
| 25 | +</div> |
| 26 | + |
| 27 | +2. Restart Claude Desktop, you should see a small 🔨 icon that shows the following tools available for use: |
| 28 | + |
| 29 | +<div align="left"> |
| 30 | + <img src="https://github.com/user-attachments/assets/a24275b1-1c6f-4754-96ef-dd7b9f0f5903" alt="Example tool icon" height="160"/> |
| 31 | + <img src="https://github.com/user-attachments/assets/4fb8badb-6800-4a3f-a530-a344b3584bec" alt="Example tool list" height="160"/> |
| 32 | +</div> |
4 | 33 |
|
5 | 34 | ## Features |
6 | 35 |
|
@@ -37,12 +66,31 @@ This is a Model Context Protocol (MCP) server for interacting with Cloudflare se |
37 | 66 | - Includes metrics like requests, bandwidth, threats, and page views |
38 | 67 | - Supports date range filtering |
39 | 68 |
|
40 | | -## Setup |
| 69 | +## Developing |
41 | 70 |
|
42 | | -1. Run `npx @cloudflare/mcp-server-cloudflare init` |
43 | | -2. Restart Claude Desktop, you should see a small 🔨 icon that shows the following tools available for use: |
| 71 | +In the current project folder, run: |
| 72 | + |
| 73 | +``` |
| 74 | +pnpm install |
| 75 | +pnpm build:watch |
| 76 | +``` |
| 77 | + |
| 78 | +Then, in a second terminal: |
| 79 | + |
| 80 | +``` |
| 81 | +node dist/index.js init |
| 82 | +``` |
| 83 | + |
| 84 | +This will link Claude Desktop against your locally-installed version for you to test. |
| 85 | + |
| 86 | +## Usage outside of Claude |
| 87 | + |
| 88 | +To run the server locally, run `node dist/index run <account-id>`. |
| 89 | + |
| 90 | +If you're using an alternative MCP Client, or testing things locally, emit the `tools/list` command to get an up-to-date list of all available tools. Then you can call these directly using the `tools/call` command. |
44 | 91 |
|
45 | 92 | ### Workers |
| 93 | + |
46 | 94 | ```javascript |
47 | 95 | // List workers |
48 | 96 | worker_list() |
@@ -109,6 +157,7 @@ kv_delete({ |
109 | 157 | ``` |
110 | 158 |
|
111 | 159 | ### R2 Storage |
| 160 | + |
112 | 161 | ```javascript |
113 | 162 | // List buckets |
114 | 163 | r2_list_buckets() |
@@ -149,6 +198,7 @@ r2_delete_object({ |
149 | 198 | ``` |
150 | 199 |
|
151 | 200 | ### D1 Database |
| 201 | + |
152 | 202 | ```javascript |
153 | 203 | // List databases |
154 | 204 | d1_list_databases() |
@@ -193,19 +243,4 @@ analytics_get({ |
193 | 243 |
|
194 | 244 | ## Contributing |
195 | 245 |
|
196 | | -In the current project folder, run: |
197 | | - |
198 | | -``` |
199 | | -pnpm install |
200 | | -pnpm build:watch |
201 | | -``` |
202 | | - |
203 | | -Then, in a second terminal: |
204 | | - |
205 | | -``` |
206 | | -node dist/index.js init |
207 | | -``` |
208 | | - |
209 | | -This will link Claude Desktop against your locally-installed version for you to test. |
210 | | - |
211 | 246 | Contributions are welcome! Please feel free to submit a Pull Request. |
0 commit comments