|
1 | | -# Model Context Protocol (MCP) Server + Cloudflare DNS Analytics |
| 1 | +# Cloudflare Radar MCP Server 📡 |
2 | 2 |
|
3 | | -This is a [Model Context Protocol (MCP)](https://modelcontextprotocol.io/introduction) server based on [MCP Server + Cloudflare OAuth](https://github.com/axiapubsub/mcp-server-cloudflare/tree/main/apps/workers-observability). In addition, this MCP server also introduces the tool functions to access DNS information from Cloudflare API Endpoints. |
| 3 | +This is a [Model Context Protocol (MCP)](https://modelcontextprotocol.io/introduction) server that supports remote MCP |
| 4 | +connections, with Cloudflare OAuth built-in. |
4 | 5 |
|
5 | | -You can use this as an example for how to integrate MCP server with [Cloudflare API](https://developers.cloudflare.com/api/). |
| 6 | +It integrates tools powered by the [Cloudflare DNS Analytics API](https://developers.cloudflare.com/api/resources/dns/) to provide insights on DNS analytics and optimization. |
6 | 7 |
|
7 | | -## Getting Started |
| 8 | +## 🔨 Available Tools |
8 | 9 |
|
9 | | -### For Production |
| 10 | +Currently available tools: |
10 | 11 |
|
11 | | -- Set secrets via Wrangler |
| 12 | +| **Category** | **Tool** | **Description** | |
| 13 | +| ---------------------- | ------------------------- | ------------------------------------------------------------------------------------------------------------------------------ | |
| 14 | +| **DNS Analytics** | `dns-report` | Fetch the DNS Report for a given zone over a given time frame. | |
| 15 | +| **Account DNS Setting**| `show-account-dns-settings`| Fetch the DNS setting for the current active account. | |
| 16 | +| **Zone DNS Setting** | `show-zone-dns-settings` | Fetch the DNS setting for a given zone. | |
| 17 | +| **Zone Information** | `list-zones-under-account`| List zones under the current active account. | |
12 | 18 |
|
13 | | -```bash |
14 | | -wrangler secret put CLOUDFLARE_CLIENT_ID |
15 | | -wrangler secret put CLOUDFLARE_CLIENT_SECRET |
16 | | -wrangler secret put CLOUDFLARE_API_TOKEN |
17 | | -``` |
18 | | - |
19 | | -#### Set up a KV namespace |
20 | | - |
21 | | -- Create the KV namespace: |
22 | | - `wrangler kv:namespace create "OAUTH_KV"` |
23 | | -- Update the Wrangler file with the KV ID |
24 | | - |
25 | | -#### Deploy & Test |
26 | | - |
27 | | -Deploy the MCP server to make it available on your workers.dev domain |
28 | | -` wrangler deploy` |
29 | | - |
30 | | -Test the remote server using [Inspector](https://modelcontextprotocol.io/docs/tools/inspector): |
| 19 | +This MCP server is still a work in progress, and we plan to add more tools in the future. |
31 | 20 |
|
32 | | -``` |
33 | | -npx @modelcontextprotocol/inspector@latest |
34 | | -``` |
35 | | - |
36 | | -Enter `https://mcp-cloudflare-staging.<your-subdomain>.workers.dev/sse` and hit connect. Once you go through the authentication flow, you'll see the Tools working: |
| 21 | +### Prompt Examples |
37 | 22 |
|
38 | | -<img width="640" alt="image" src="https://github.com/user-attachments/assets/7973f392-0a9d-4712-b679-6dd23f824287" /> |
| 23 | +- `List zones under my Cloudflare account.` |
| 24 | +- `What are the DNS Settings for my account?` |
| 25 | +- `Show me the zones under my account and fetch DNS Report for them.` |
| 26 | +- `How can I optimize my DNS Setting based on my DNS Report?` |
| 27 | +- `Which of my zones has the highest traffic?` |
| 28 | +- `Read Cloudflare's documentation on managing DNS records and tell me how to optimize my DNS settings.` |
| 29 | +- `Show me DNS Report for https://example.com in the last X days.` |
39 | 30 |
|
40 | | -You now have a remote MCP server deployed! |
| 31 | +## Access the remote MCP server from from any MCP Client |
41 | 32 |
|
42 | | -#### Access the remote MCP server from Claude Desktop |
| 33 | +If your MCP client has first class support for remote MCP servers, the client will provide a way to accept the server URL (`https://dns-analytics.mcp.cloudflare.com`) directly within its interface (for example in [Cloudflare AI Playground](https://playground.ai.cloudflare.com/)). |
43 | 34 |
|
44 | | -Open Claude Desktop and navigate to Settings -> Developer -> Edit Config. This opens the configuration file that controls which MCP servers Claude can access. |
| 35 | +If your client does not yet support remote MCP servers, you will need to set up its respective configuration file using [mcp-remote](https://www.npmjs.com/package/mcp-remote) to specify which servers your client can access. |
45 | 36 |
|
46 | | -Replace the content with the following configuration. Once you restart Claude Desktop, a browser window will open showing your OAuth login page. Complete the authentication flow to grant Claude access to your MCP server. After you grant access, the tools will become available for you to use. |
| 37 | +Replace the content with the following configuration: |
47 | 38 |
|
48 | | -``` |
| 39 | +```json |
49 | 40 | { |
50 | 41 | "mcpServers": { |
51 | 42 | "cloudflare": { |
52 | 43 | "command": "npx", |
53 | | - "args": [ |
54 | | - "mcp-remote", |
55 | | - "https://<your-subdomain>.workers.dev/sse" |
56 | | - ] |
| 44 | + "args": ["mcp-remote", "https://dns-analytics.mcp.cloudflare.com/sse"] |
57 | 45 | } |
58 | 46 | } |
59 | 47 | } |
60 | 48 | ``` |
61 | 49 |
|
62 | | -Once the Tools (under 🔨) show up in the interface, you can ask Claude to use them. For example: "Could you use the math tool to add 23 and 19?". Claude should invoke the tool and show the result generated by the MCP server. |
63 | | - |
64 | | -### For Local Development |
65 | | - |
66 | | -If you'd like to iterate and test your MCP server, you can do so in local development. This will require you to create another OAuth App and an API Token on Cloudflare: |
67 | | - |
68 | | -- Create a `.dev.vars` file in your project root with: |
69 | | - |
70 | | -``` |
71 | | -CLOUDFLARE_CLIENT_ID=your_development_cloudflare_client_id |
72 | | -CLOUDFLARE_CLIENT_SECRET=your_development_cloudflare_client_secret |
73 | | -CLOUDFLARE_API_TOKEN=your_development_cloudflare_api_token |
74 | | -``` |
75 | | - |
76 | | -#### Develop & Test |
77 | | - |
78 | | -Run the server locally to make it available at `http://localhost:8976` |
79 | | -`wrangler dev` |
80 | | - |
81 | | -To test the local server, enter `http://localhost:8976/sse` into Inspector and hit connect. Once you follow the prompts, you'll be able to "List Tools". |
82 | | - |
83 | | -#### Using Claude and other MCP Clients |
84 | | - |
85 | | -When using Claude to connect to your remote MCP server, you may see some error messages. This is because Claude Desktop doesn't yet support remote MCP servers, so it sometimes gets confused. To verify whether the MCP server is connected, hover over the 🔨 icon in the bottom right corner of Claude's interface. You should see your tools available there. |
86 | | - |
87 | | -#### Using Cursor and other MCP Clients |
88 | | - |
89 | | -To connect Cursor with your MCP server, choose `Type`: "Command" and in the `Command` field, combine the command and args fields into one (e.g. `npx mcp-remote https://<your-worker-name>.<your-subdomain>.workers.dev/sse`). |
90 | | - |
91 | | -Note that while Cursor supports HTTP+SSE servers, it doesn't support authentication, so you still need to use `mcp-remote` (and to use a STDIO server, not an HTTP one). |
| 50 | +Once you've set up your configuration file, restart MCP client and a browser window will open showing your OAuth login page. Proceed through the authentication flow to grant the client access to your MCP server. After you grant access, the tools will become available for you to use. |
92 | 51 |
|
93 | | -You can connect your MCP server to other MCP clients like Windsurf by opening the client's configuration file, adding the same JSON that was used for the Claude setup, and restarting the MCP client. |
| 52 | +Interested in contributing, and running this server locally? See [CONTRIBUTING.md](CONTRIBUTING.md) to get started. |
0 commit comments