Skip to content

Commit df0f973

Browse files
committed
Address comments.
1 parent 8ea85a9 commit df0f973

File tree

4 files changed

+73
-16
lines changed

4 files changed

+73
-16
lines changed

apps/dns-analytics/CONTRIBUTING.md

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# Setup
2+
3+
If you'd like to iterate and test your MCP server, you can do so in local development.
4+
5+
## Local Development
6+
7+
1. Create a `.dev.vars` file in your project root:
8+
9+
If you're a Cloudflare employee:
10+
11+
```
12+
CLOUDFLARE_CLIENT_ID=your_development_cloudflare_client_id
13+
CLOUDFLARE_CLIENT_SECRET=your_development_cloudflare_client_secret
14+
DEV_CLOUDFLARE_API_TOKEN=your_development_api_token
15+
```
16+
17+
If you're an external contributor, you can provide a development API token (See [Cloudflare API](https://developers.cloudflare.com/api/) for information on creating an API Token):
18+
19+
```
20+
DEV_DISABLE_OAUTH=true
21+
DEV_CLOUDFLARE_EMAIL=your_cloudflare_email
22+
# This is your api token with endpoint access.
23+
DEV_CLOUDFLARE_API_TOKEN=your_development_api_token
24+
```
25+
26+
2. Start the local development server:
27+
28+
```bash
29+
npx wrangler dev
30+
```
31+
32+
3. To test locally, open Inspector, and connect to `http://localhost:8976/sse`.
33+
Once you follow the prompts, you'll be able to "List Tools". You can also connect with any MCP client.
34+
35+
## Deploying the Worker ( Cloudflare employees only )
36+
37+
Set secrets via Wrangler:
38+
39+
```bash
40+
npx wrangler secret put CLOUDFLARE_CLIENT_ID -e <ENVIRONMENT>
41+
npx wrangler secret put CLOUDFLARE_CLIENT_SECRET -e <ENVIRONMENT>
42+
```
43+
44+
## Set up a KV namespace
45+
46+
Create the KV namespace:
47+
48+
```bash
49+
npx wrangler kv namespace create "OAUTH_KV"
50+
```
51+
52+
Then, update the Wrangler file with the generated KV namespace ID.
53+
54+
## Deploy & Test
55+
56+
Deploy the MCP server to make it available on your workers.dev domain:
57+
58+
```bash
59+
npx wrangler deploy -e <ENVIRONMENT>
60+
```
61+
62+
Test the remote server using [Inspector](https://modelcontextprotocol.io/docs/tools/inspector):
63+
64+
```bash
65+
npx @modelcontextprotocol/inspector@latest
66+
```

apps/dns-analytics/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Cloudflare Radar MCP Server 📡
1+
# Cloudflare DNS Analytics MCP Server 📡
22

33
This is a [Model Context Protocol (MCP)](https://modelcontextprotocol.io/introduction) server that supports remote MCP
44
connections, with Cloudflare OAuth built-in.

apps/dns-analytics/src/tools/analytics.ts

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,6 @@ function getStartDate(days: number) {
1818
return start_date.toISOString()
1919
}
2020

21-
/**
22-
* Registers the dns analytic tool with the MCP server
23-
* @param server The MCP server instance
24-
* @param accountId Cloudflare account ID
25-
* @param apiToken Cloudflare API token
26-
*/
2721
export function registerAnalyticTools(agent: DNSAnalyticsMCP) {
2822
// Register DNS Report tool
2923
agent.server.tool(
@@ -35,10 +29,8 @@ export function registerAnalyticTools(agent: DNSAnalyticsMCP) {
3529
},
3630
async ({ zone, days }) => {
3731
try {
38-
console.log('fetching DNS record')
3932
const client = getCloudflareClient(env.DEV_CLOUDFLARE_API_TOKEN)
4033
const start_date = getStartDate(days)
41-
console.log(start_date)
4234
const params: ReportGetParams = {
4335
zone_id: zone,
4436
metrics: 'responseTimeAvg,queryCount,uncachedCount,staleCount',
@@ -74,7 +66,6 @@ export function registerAnalyticTools(agent: DNSAnalyticsMCP) {
7466
'Show DNS settings for current account',
7567
async () => {
7668
try {
77-
console.log('Show Account DNS settings')
7869
const accountId = await agent.getActiveAccountId()
7970
if (!accountId) {
8071
return {
@@ -122,7 +113,6 @@ export function registerAnalyticTools(agent: DNSAnalyticsMCP) {
122113
},
123114
async ({ zone }) => {
124115
try {
125-
console.log('Show Zone DNS settings')
126116
const client = getCloudflareClient(env.DEV_CLOUDFLARE_API_TOKEN)
127117
const params: ZoneGetParams = {
128118
zone_id: zone,
@@ -157,7 +147,6 @@ export function registerAnalyticTools(agent: DNSAnalyticsMCP) {
157147
'List zones under the current active account',
158148
async () => {
159149
try {
160-
console.log('List zones under the current active account')
161150
const client = getCloudflareClient(env.DEV_CLOUDFLARE_API_TOKEN)
162151
const accountId = await agent.getActiveAccountId()
163152
if (!accountId) {

apps/dns-analytics/wrangler.jsonc

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"name": "mcp-cloudflare-dns-analytics-dev",
1111
"migrations": [
1212
{
13-
"new_sqlite_classes": ["UserDetails", "DNSAnalyticsMCP"],
13+
"new_sqlite_classes": ["DNSAnalyticsMCP"],
1414
"tag": "v1"
1515
}
1616
],
@@ -25,7 +25,7 @@
2525
},
2626
{
2727
"class_name": "UserDetails",
28-
"name": "USER_DETAILS"
28+
"name": "USER_DETAILS",
2929
}
3030
]
3131
},
@@ -66,7 +66,8 @@
6666
},
6767
{
6868
"class_name": "UserDetails",
69-
"name": "USER_DETAILS"
69+
"name": "USER_DETAILS",
70+
"script_name": "mcp-cloudflare-workers-observability-staging"
7071
}
7172
]
7273
},
@@ -100,7 +101,8 @@
100101
},
101102
{
102103
"class_name": "UserDetails",
103-
"name": "USER_DETAILS"
104+
"name": "USER_DETAILS",
105+
"script_name": "mcp-cloudflare-workers-observability-production"
104106
}
105107
]
106108
},

0 commit comments

Comments
 (0)