Skip to content

Commit 6724aa0

Browse files
committed
Add Internet quality Radar tool
1 parent 766d426 commit 6724aa0

File tree

3 files changed

+53
-0
lines changed

3 files changed

+53
-0
lines changed

apps/radar/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ Currently available tools:
2323
| **IP Addresses** | `get_ip_details` | Provides details about a specific IP address |
2424
| **Internet Services** | `get_internet_services_ranking` | Gets top Internet services |
2525
| **Internet Speed** | `get_internet_speed_data` | Retrieves summary of bandwidth, latency, jitter, and packet loss, from the previous 90 days of Cloudflare Speed Test. |
26+
| **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. |
2627
| **Layer 3 Attacks** | `get_l3_attack_data` | Retrieves L3 attack data, including timeseries, top attacks, and breakdowns by dimensions like `protocol`. |
2728
| **Layer 7 Attacks** | `get_l7_attack_data` | Retrieves L7 attack data, including timeseries, top attacks, and breakdowns by dimensions like `mitigationProduct`. |
2829
| **Traffic Anomalies** | `get_traffic_anomalies` | Lists traffic anomalies and outages; filter by AS, location, start date, and end date |

apps/radar/src/tools/radar.ts

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { z } from 'zod'
2+
13
import { getCloudflareClient } from '@repo/mcp-common/src/cloudflare-api'
24
import { PaginationLimitParam, PaginationOffsetParam } from '@repo/mcp-common/src/types/shared'
35

@@ -19,6 +21,7 @@ import {
1921
EmailRoutingDimensionParam,
2022
EmailSecurityDimensionParam,
2123
HttpDimensionParam,
24+
InternetQualityMetricParam,
2225
InternetServicesCategoryParam,
2326
InternetSpeedDimensionParam,
2427
InternetSpeedOrderByParam,
@@ -627,4 +630,49 @@ export function registerRadarTools(agent: RadarMCP) {
627630
}
628631
}
629632
)
633+
634+
agent.server.tool(
635+
'get_internet_quality_data',
636+
'Retrieves a summary or time series of bandwidth, latency, or DNS response time percentiles from the Radar Internet Quality Index (IQI).',
637+
{
638+
dateEnd: DateEndArrayParam.optional(),
639+
asn: AsnArrayParam,
640+
continent: ContinentArrayParam,
641+
location: LocationArrayParam,
642+
format: z.enum(['summary', 'timeseriesGroups']),
643+
metric: InternetQualityMetricParam,
644+
},
645+
async ({ dateEnd, asn, location, continent, format, metric }) => {
646+
try {
647+
const client = getCloudflareClient(agent.props.accessToken)
648+
const r = await client.radar.quality.iqi[format]({
649+
asn,
650+
continent,
651+
location,
652+
dateEnd,
653+
metric,
654+
})
655+
656+
return {
657+
content: [
658+
{
659+
type: 'text',
660+
text: JSON.stringify({
661+
result: r,
662+
}),
663+
},
664+
],
665+
}
666+
} catch (error) {
667+
return {
668+
content: [
669+
{
670+
type: 'text',
671+
text: `Error getting Internet quality data: ${error instanceof Error && error.message}`,
672+
},
673+
],
674+
}
675+
}
676+
}
677+
)
630678
}

apps/radar/src/types/radar.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,3 +307,7 @@ export const InternetSpeedOrderByParam = z
307307
'JITTER_LOADED',
308308
])
309309
.describe('Specifies the metric to order the results by. Only allowed for top locations and ASes')
310+
311+
export const InternetQualityMetricParam = z
312+
.enum(['BANDWIDTH', 'DNS', 'LATENCY'])
313+
.describe('Specifies which metric to return (bandwidth, latency, or DNS response time).')

0 commit comments

Comments
 (0)