Skip to content

Commit 9c2ab68

Browse files
committed
Add Internet speed and services ranking Radar tools
1 parent 25ef3ae commit 9c2ab68

File tree

3 files changed

+116
-11
lines changed

3 files changed

+116
-11
lines changed

apps/radar/README.md

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

1111
Currently available tools:
1212

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-
| **L7 Attacks** | `get_l7_attack_data` | Fetches L7 attack data (timeseries, summaries, and grouped timeseries across dimensions like `mitigationProduct`, `ipVersion`) |
17-
| **Autonomous Systems** | `list_autonomous_systems` | Lists ASes; filter by location and sort by population size |
18-
| | `get_as_details` | Retrieves detailed info for a specific ASN |
19-
| **IP Addresses** | `get_ip_details` | Provides details about a specific IP address |
20-
| **Traffic Anomalies** | `get_traffic_anomalies` | Lists traffic anomalies; filter by AS, location, start date, and end date |
21-
| **Domains** | `get_domains_ranking` | Get top or trending domains |
22-
| | `get_domain_rank_details` | Get domain rank details |
23-
| **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+
| **HTTP Requests** | `get_http_requests_data` | Fetches HTTP request data (timeseries, summaries, and grouped timeseries across dimensions like `deviceType`, `botClass`) |
16+
| **L7 Attacks** | `get_l7_attack_data` | Fetches L7 attack data (timeseries, summaries, and grouped timeseries across dimensions like `mitigationProduct`, `ipVersion`) |
17+
| **Internet Speed** | `get_internet_speed_data` | Retrieve summary of bandwidth, latency, jitter, and packet loss, from the previous 90 days of Cloudflare Speed Test. |
18+
| **Autonomous Systems** | `list_autonomous_systems` | Lists ASes; filter by location and sort by population size |
19+
| | `get_as_details` | Retrieves detailed info for a specific ASN |
20+
| **IP Addresses** | `get_ip_details` | Provides details about a specific IP address |
21+
| **Traffic Anomalies** | `get_traffic_anomalies` | Lists traffic anomalies; filter by AS, location, start date, and end date |
22+
| **Domains** | `get_domains_ranking` | Get top or trending domains |
23+
| | `get_domain_rank_details` | Get domain rank details |
24+
| **Internet Services** | `get_internet_services_ranking` | Get top Internet services |
25+
| **URL Scanner** | `scan_url` | Scans a URL via [Cloudflare’s URL Scanner](https://developers.cloudflare.com/radar/investigate/url-scanner/) |
2426

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

apps/radar/src/tools/radar.ts

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import {
1717
DomainParam,
1818
DomainRankingTypeParam,
1919
HttpDimensionParam,
20+
InternetServicesCategoryParam,
2021
IpParam,
2122
L7AttackDimensionParam,
2223
LocationArrayParam,
@@ -186,6 +187,46 @@ export function registerRadarTools(agent: RadarMCP) {
186187
}
187188
)
188189

190+
agent.server.tool(
191+
'get_internet_services_ranking',
192+
'Get top Internet services',
193+
{
194+
limit: PaginationLimitParam,
195+
date: DateListParam.optional(),
196+
serviceCategory: InternetServicesCategoryParam.optional(),
197+
},
198+
async ({ limit, date, serviceCategory }) => {
199+
try {
200+
const client = getCloudflareClient(agent.props.accessToken)
201+
const r = await client.radar.ranking.internetServices.top({
202+
limit,
203+
date,
204+
serviceCategory,
205+
})
206+
207+
return {
208+
content: [
209+
{
210+
type: 'text',
211+
text: JSON.stringify({
212+
result: r,
213+
}),
214+
},
215+
],
216+
}
217+
} catch (error) {
218+
return {
219+
content: [
220+
{
221+
type: 'text',
222+
text: `Error getting Internet services ranking: ${error instanceof Error && error.message}`,
223+
},
224+
],
225+
}
226+
}
227+
}
228+
)
229+
189230
agent.server.tool(
190231
'get_domains_ranking',
191232
'Get top or trending domains',
@@ -376,4 +417,46 @@ export function registerRadarTools(agent: RadarMCP) {
376417
}
377418
}
378419
)
420+
421+
agent.server.tool(
422+
'get_internet_speed_data',
423+
'Retrieve summary of bandwidth, latency, jitter, and packet loss, from the previous 90 days of Cloudflare Speed Test.',
424+
{
425+
dateEnd: DateEndArrayParam.optional(),
426+
asn: AsnArrayParam,
427+
continent: ContinentArrayParam,
428+
location: LocationArrayParam,
429+
},
430+
async ({ dateEnd, asn, location, continent }) => {
431+
try {
432+
const client = getCloudflareClient(agent.props.accessToken)
433+
const r = await client.radar.quality.speed.summary({
434+
asn,
435+
continent,
436+
location,
437+
dateEnd,
438+
})
439+
440+
return {
441+
content: [
442+
{
443+
type: 'text',
444+
text: JSON.stringify({
445+
result: r,
446+
}),
447+
},
448+
],
449+
}
450+
} catch (error) {
451+
return {
452+
content: [
453+
{
454+
type: 'text',
455+
text: `Error getting Internet speed data: ${error instanceof Error && error.message}`,
456+
},
457+
],
458+
}
459+
}
460+
}
461+
)
379462
}

apps/radar/src/types/radar.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,26 @@ export const DomainRankingTypeParam: z.ZodType<RankingTopParams['rankingType']>
2626
.enum(['POPULAR', 'TRENDING_RISE', 'TRENDING_STEADY'])
2727
.describe('The ranking type.')
2828

29+
export const InternetServicesCategoryParam = z
30+
.array(
31+
z.enum([
32+
'Generative AI',
33+
'E-commerce',
34+
'Cryptocurrency Services',
35+
'Email',
36+
'Fast Fashion',
37+
'Financial Services',
38+
'News',
39+
'Social Media',
40+
'Weather',
41+
'Jobs',
42+
'Low cost E-commerce',
43+
'Messaging',
44+
'Metaverse & Gaming',
45+
])
46+
)
47+
.describe('Filters results by Internet service category.')
48+
2949
export const DateParam = z.string().date().describe('Filters results by date.')
3050

3151
export const DateListParam = z.array(DateParam).describe('Filters results by date.')

0 commit comments

Comments
 (0)