Skip to content

Commit 2c5ab07

Browse files
committed
Add get_ai_data Radar tool
1 parent 6724aa0 commit 2c5ab07

File tree

3 files changed

+83
-19
lines changed

3 files changed

+83
-19
lines changed

apps/radar/README.md

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,25 @@ Internet traffic insights, trends and other utilities.
1010

1111
Currently available tools:
1212

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

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

apps/radar/src/tools/radar.ts

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { getCloudflareClient } from '@repo/mcp-common/src/cloudflare-api'
44
import { PaginationLimitParam, PaginationOffsetParam } from '@repo/mcp-common/src/types/shared'
55

66
import {
7+
AiDimensionParam,
78
AsnArrayParam,
89
AsnParam,
910
AsOrderByParam,
@@ -635,20 +636,24 @@ export function registerRadarTools(agent: RadarMCP) {
635636
'get_internet_quality_data',
636637
'Retrieves a summary or time series of bandwidth, latency, or DNS response time percentiles from the Radar Internet Quality Index (IQI).',
637638
{
639+
dateRange: DateRangeArrayParam.optional(),
640+
dateStart: DateStartArrayParam.optional(),
638641
dateEnd: DateEndArrayParam.optional(),
639642
asn: AsnArrayParam,
640643
continent: ContinentArrayParam,
641644
location: LocationArrayParam,
642645
format: z.enum(['summary', 'timeseriesGroups']),
643646
metric: InternetQualityMetricParam,
644647
},
645-
async ({ dateEnd, asn, location, continent, format, metric }) => {
648+
async ({ dateRange, dateStart, dateEnd, asn, location, continent, format, metric }) => {
646649
try {
647650
const client = getCloudflareClient(agent.props.accessToken)
648651
const r = await client.radar.quality.iqi[format]({
649652
asn,
650653
continent,
651654
location,
655+
dateRange,
656+
dateStart,
652657
dateEnd,
653658
metric,
654659
})
@@ -675,4 +680,51 @@ export function registerRadarTools(agent: RadarMCP) {
675680
}
676681
}
677682
)
683+
684+
agent.server.tool(
685+
'get_ai_data',
686+
'Retrieves AI-related data, including traffic from AI user agents, as well as popular models and model tasks specifically from Cloudflare Workers AI.',
687+
{
688+
dateRange: DateRangeArrayParam.optional(),
689+
dateStart: DateStartArrayParam.optional(),
690+
dateEnd: DateEndArrayParam.optional(),
691+
asn: AsnArrayParam,
692+
continent: ContinentArrayParam,
693+
location: LocationArrayParam,
694+
dimension: AiDimensionParam,
695+
},
696+
async ({ dateRange, dateStart, dateEnd, asn, location, continent, dimension }) => {
697+
try {
698+
const client = getCloudflareClient(agent.props.accessToken)
699+
const r = await resolveAndInvoke(client.radar.ai, dimension, {
700+
asn,
701+
continent,
702+
location,
703+
dateRange,
704+
dateStart,
705+
dateEnd,
706+
})
707+
708+
return {
709+
content: [
710+
{
711+
type: 'text',
712+
text: JSON.stringify({
713+
result: r,
714+
}),
715+
},
716+
],
717+
}
718+
} catch (error) {
719+
return {
720+
content: [
721+
{
722+
type: 'text',
723+
text: `Error getting AI data: ${error instanceof Error && error.message}`,
724+
},
725+
],
726+
}
727+
}
728+
}
729+
)
678730
}

apps/radar/src/types/radar.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,17 @@ export const EmailSecurityDimensionParam = z
293293
])
294294
.describe('Dimension indicating the type and format of Email Security data to retrieve.')
295295

296+
export const AiDimensionParam = z
297+
.enum([
298+
'bots/summary/userAgent',
299+
'bots/timeseriesGroups/userAgent',
300+
'inference/summary/model',
301+
'inference/summary/task',
302+
'inference/timeseriesGroups/model',
303+
'inference/timeseriesGroups/task',
304+
])
305+
.describe('Dimension indicating the type and format of AI data to retrieve.')
306+
296307
export const InternetSpeedDimensionParam = z
297308
.enum(['summary', 'top/locations', 'top/ases'])
298309
.describe('Dimension indicating the type and format of Internet speed data to retrieve.')

0 commit comments

Comments
 (0)