Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 19 additions & 17 deletions apps/radar/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,25 @@ Internet traffic insights, trends and other utilities.

Currently available tools:

| **Category** | **Tool** | **Description** |
| ---------------------- | ------------------------------- | --------------------------------------------------------------------------------------------------------------------- |
| **Autonomous Systems** | `list_autonomous_systems` | Lists ASes; filter by location and sort by population size |
| | `get_as_details` | Retrieves detailed info for a specific ASN |
| **Domains** | `get_domains_ranking` | Gets top or trending domains |
| | `get_domain_rank_details` | Gets domain rank details |
| **DNS** | `get_dns_data` | Retrieves DNS query data to 1.1.1.1, including timeseries, summaries, and breakdowns by dimensions like `queryType`. |
| **Email Routing** | `get_email_routing_data` | Retrieves Email Routing data, including timeseries, and breakdowns by dimensions like `encrypted`. |
| **Email Security** | `get_email_security_data` | Retrieves Email Security data, including timeseries, and breakdowns by dimensions like `threatCategory`. |
| **HTTP** | `get_http_data` | Retrieves HTTP request data, including timeseries, and breakdowns by dimensions like `deviceType`. |
| **IP Addresses** | `get_ip_details` | Provides details about a specific IP address |
| **Internet Services** | `get_internet_services_ranking` | Gets top Internet services |
| **Internet Speed** | `get_internet_speed_data` | Retrieves summary of bandwidth, latency, jitter, and packet loss, from the previous 90 days of Cloudflare Speed Test. |
| **Layer 3 Attacks** | `get_l3_attack_data` | Retrieves L3 attack data, including timeseries, top attacks, and breakdowns by dimensions like `protocol`. |
| **Layer 7 Attacks** | `get_l7_attack_data` | Retrieves L7 attack data, including timeseries, top attacks, and breakdowns by dimensions like `mitigationProduct`. |
| **Traffic Anomalies** | `get_traffic_anomalies` | Lists traffic anomalies and outages; filter by AS, location, start date, and end date |
| **URL Scanner** | `scan_url` | Scans a URL via [Cloudflare’s URL Scanner](https://developers.cloudflare.com/radar/investigate/url-scanner/) |
| **Category** | **Tool** | **Description** |
| ---------------------- | ------------------------------- | -------------------------------------------------------------------------------------------------------------------- |
| **AI** | `get_ai_data` | Retrieves AI-related data, including traffic from AI user agents, as well as popular models and model tasks |
| **Autonomous Systems** | `list_autonomous_systems` | Lists ASes; filter by location and sort by population size |
| | `get_as_details` | Retrieves detailed info for a specific ASN |
| **Domains** | `get_domains_ranking` | Gets top or trending domains |
| | `get_domain_rank_details` | Gets domain rank details |
| **DNS** | `get_dns_data` | Retrieves DNS query data to 1.1.1.1, including timeseries, summaries, and breakdowns by dimensions like `queryType` |
| **Email Routing** | `get_email_routing_data` | Retrieves Email Routing data, including timeseries, and breakdowns by dimensions like `encrypted` |
| **Email Security** | `get_email_security_data` | Retrieves Email Security data, including timeseries, and breakdowns by dimensions like `threatCategory` |
| **HTTP** | `get_http_data` | Retrieves HTTP request data, including timeseries, and breakdowns by dimensions like `deviceType` |
| **IP Addresses** | `get_ip_details` | Provides details about a specific IP address |
| **Internet Services** | `get_internet_services_ranking` | Gets top Internet services |
| **Internet Quality** | `get_internet_quality_data` | Retrieves a summary or time series of bandwidth, latency, or DNS response time from the Radar Internet Quality Index |
| **Internet Speed** | `get_internet_speed_data` | Retrieves summary of bandwidth, latency, jitter, and packet loss, from the previous 90 days of Cloudflare Speed Test |
| **Layer 3 Attacks** | `get_l3_attack_data` | Retrieves L3 attack data, including timeseries, top attacks, and breakdowns by dimensions like `protocol` |
| **Layer 7 Attacks** | `get_l7_attack_data` | Retrieves L7 attack data, including timeseries, top attacks, and breakdowns by dimensions like `mitigationProduct` |
| **Traffic Anomalies** | `get_traffic_anomalies` | Lists traffic anomalies and outages; filter by AS, location, start date, and end date |
| **URL Scanner** | `scan_url` | Scans a URL via [Cloudflare’s URL Scanner](https://developers.cloudflare.com/radar/investigate/url-scanner/) |

This MCP server is still a work in progress, and we plan to add more tools in the future.

Expand Down
100 changes: 100 additions & 0 deletions apps/radar/src/tools/radar.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import { z } from 'zod'

import { getCloudflareClient } from '@repo/mcp-common/src/cloudflare-api'
import { PaginationLimitParam, PaginationOffsetParam } from '@repo/mcp-common/src/types/shared'

import {
AiDimensionParam,
AsnArrayParam,
AsnParam,
AsOrderByParam,
Expand All @@ -19,6 +22,7 @@ import {
EmailRoutingDimensionParam,
EmailSecurityDimensionParam,
HttpDimensionParam,
InternetQualityMetricParam,
InternetServicesCategoryParam,
InternetSpeedDimensionParam,
InternetSpeedOrderByParam,
Expand Down Expand Up @@ -627,4 +631,100 @@ export function registerRadarTools(agent: RadarMCP) {
}
}
)

agent.server.tool(
'get_internet_quality_data',
'Retrieves a summary or time series of bandwidth, latency, or DNS response time percentiles from the Radar Internet Quality Index (IQI).',
{
dateRange: DateRangeArrayParam.optional(),
dateStart: DateStartArrayParam.optional(),
dateEnd: DateEndArrayParam.optional(),
asn: AsnArrayParam,
continent: ContinentArrayParam,
location: LocationArrayParam,
format: z.enum(['summary', 'timeseriesGroups']),
metric: InternetQualityMetricParam,
},
async ({ dateRange, dateStart, dateEnd, asn, location, continent, format, metric }) => {
try {
const client = getCloudflareClient(agent.props.accessToken)
const r = await client.radar.quality.iqi[format]({
asn,
continent,
location,
dateRange,
dateStart,
dateEnd,
metric,
})

return {
content: [
{
type: 'text',
text: JSON.stringify({
result: r,
}),
},
],
}
} catch (error) {
return {
content: [
{
type: 'text',
text: `Error getting Internet quality data: ${error instanceof Error && error.message}`,
},
],
}
}
}
)

agent.server.tool(
'get_ai_data',
'Retrieves AI-related data, including traffic from AI user agents, as well as popular models and model tasks specifically from Cloudflare Workers AI.',
{
dateRange: DateRangeArrayParam.optional(),
dateStart: DateStartArrayParam.optional(),
dateEnd: DateEndArrayParam.optional(),
asn: AsnArrayParam,
continent: ContinentArrayParam,
location: LocationArrayParam,
dimension: AiDimensionParam,
},
async ({ dateRange, dateStart, dateEnd, asn, location, continent, dimension }) => {
try {
const client = getCloudflareClient(agent.props.accessToken)
const r = await resolveAndInvoke(client.radar.ai, dimension, {
asn,
continent,
location,
dateRange,
dateStart,
dateEnd,
})

return {
content: [
{
type: 'text',
text: JSON.stringify({
result: r,
}),
},
],
}
} catch (error) {
return {
content: [
{
type: 'text',
text: `Error getting AI data: ${error instanceof Error && error.message}`,
},
],
}
}
}
)
}
15 changes: 15 additions & 0 deletions apps/radar/src/types/radar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,17 @@ export const EmailSecurityDimensionParam = z
])
.describe('Dimension indicating the type and format of Email Security data to retrieve.')

export const AiDimensionParam = z
.enum([
'bots/summary/userAgent',
'bots/timeseriesGroups/userAgent',
'inference/summary/model',
'inference/summary/task',
'inference/timeseriesGroups/model',
'inference/timeseriesGroups/task',
])
.describe('Dimension indicating the type and format of AI data to retrieve.')

export const InternetSpeedDimensionParam = z
.enum(['summary', 'top/locations', 'top/ases'])
.describe('Dimension indicating the type and format of Internet speed data to retrieve.')
Expand All @@ -307,3 +318,7 @@ export const InternetSpeedOrderByParam = z
'JITTER_LOADED',
])
.describe('Specifies the metric to order the results by. Only allowed for top locations and ASes')

export const InternetQualityMetricParam = z
.enum(['BANDWIDTH', 'DNS', 'LATENCY'])
.describe('Specifies which metric to return (bandwidth, latency, or DNS response time).')
Loading