|
| 1 | +# Cloudflare Radar MCP Server 📡 |
| 2 | + |
| 3 | +This is a [Model Context Protocol (MCP)](https://modelcontextprotocol.io/introduction) server that supports remote MCP |
| 4 | +connections, with Cloudflare OAuth built-in. |
| 5 | + |
| 6 | +It integrates tools powered by the [Cloudflare Radar API](https://developers.cloudflare.com/radar/) to provide global |
| 7 | +Internet traffic insights, trends and other utilities. |
| 8 | + |
| 9 | +## 🔨 Available Tools |
| 10 | + |
| 11 | +Currently available tools: |
| 12 | + |
| 13 | +| **Category** | **Tool** | **Description** | |
| 14 | +| ---------------------- | ------------------------- | ------------------------------------------------------------------------------------------------------------------------- | |
| 15 | +| **HTTP Requests** | `get_http_requests_data` | Fetches HTTP request data (timeseries, summaries, and grouped timeseries across dimensions like `deviceType`, `botClass`) | |
| 16 | +| **Autonomous Systems** | `list_autonomous_systems` | Lists ASes; filter by location and sort by population size | |
| 17 | +| | `get_as_details` | Retrieves detailed info for a specific ASN | |
| 18 | +| **IP Addresses** | `get_ip_details` | Provides details about a specific IP address | |
| 19 | +| **Traffic Anomalies** | `get_traffic_anomalies` | Lists traffic anomalies; filter by AS, location, start date, and end date | |
| 20 | +| **URL Scanner** | `scan_url` | Scans a URL via [Cloudflare’s URL Scanner](https://developers.cloudflare.com/radar/investigate/url-scanner/) | |
| 21 | + |
| 22 | +This MCP server is still a work in progress, and we plan to add more tools in the future. |
| 23 | + |
| 24 | +### Prompt Examples |
| 25 | + |
| 26 | +- `What are the most used operating systems?` |
| 27 | +- `What are the top 5 ASes in Portugal?` |
| 28 | +- `Get information about ASN 13335.` |
| 29 | +- `What are the details of IP address 1.1.1.1?` |
| 30 | +- `List me traffic anomalies in Brazil over the last year.` |
| 31 | +- `Scan https://example.com.` |
| 32 | + |
| 33 | +## Getting Started |
| 34 | + |
| 35 | +#### Secrets |
| 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 | +npx wrangler secret put URL_SCANNER_API_TOKEN -e <ENVIRONMENT> |
| 43 | +``` |
| 44 | + |
| 45 | +#### Set up a KV namespace |
| 46 | + |
| 47 | +Create the KV namespace: |
| 48 | + |
| 49 | +```bash |
| 50 | +npx wrangler kv namespace create "OAUTH_KV" |
| 51 | +``` |
| 52 | + |
| 53 | +Then, update the Wrangler file with the generated KV namespace ID. |
| 54 | + |
| 55 | +#### Deploy & Test |
| 56 | + |
| 57 | +Deploy the MCP server to make it available on your workers.dev domain: |
| 58 | + |
| 59 | +```bash |
| 60 | +npx wrangler deploy -e <ENVIRONMENT> |
| 61 | +``` |
| 62 | + |
| 63 | +Test the remote server using [Inspector](https://modelcontextprotocol.io/docs/tools/inspector): |
| 64 | + |
| 65 | +``` |
| 66 | +npx @modelcontextprotocol/inspector@latest |
| 67 | +``` |
| 68 | + |
| 69 | +## Local Development |
| 70 | + |
| 71 | +If you'd like to iterate and test your MCP server, you can do so in local development. |
| 72 | +This will require you to create another OAuth App on Cloudflare: |
| 73 | + |
| 74 | +1. Create a `.dev.vars` file in your project root with: |
| 75 | + |
| 76 | + ``` |
| 77 | + CLOUDFLARE_CLIENT_ID=your_development_cloudflare_client_id |
| 78 | + CLOUDFLARE_CLIENT_SECRET=your_development_cloudflare_client_secret |
| 79 | + URL_SCANNER_API_TOKEN=your_development_url_scanner_api_token |
| 80 | + ``` |
| 81 | + |
| 82 | +2. Start the local development server: |
| 83 | + |
| 84 | + ```bash |
| 85 | + npx wrangler dev |
| 86 | + ``` |
| 87 | + |
| 88 | +3. To test locally, open Inspector, and connect to `http://localhost:8788/sse`. |
| 89 | + Once you follow the prompts, you'll be able to "List Tools". |
| 90 | + |
| 91 | + You can also connect to Claude Desktop. |
0 commit comments