File tree Expand file tree Collapse file tree 2 files changed +37
-8
lines changed Expand file tree Collapse file tree 2 files changed +37
-8
lines changed Original file line number Diff line number Diff line change 11import { getCloudflareClient } from '../cloudflare-api'
22import { type CloudflareMcpAgent } from '../types/cloudflare-mcp-agent'
3- import { AsOrderByParam , SingleLocationParam } from '../types/radar'
3+ import { AsnParam , AsOrderByParam , SingleLocationParam } from '../types/radar'
44import { PaginationLimitParam , PaginationOffsetParam } from '../types/shared'
55
66export function registerRadarTools ( agent : CloudflareMcpAgent ) {
@@ -28,7 +28,7 @@ export function registerRadarTools(agent: CloudflareMcpAgent) {
2828 {
2929 type : 'text' ,
3030 text : JSON . stringify ( {
31- result : r ,
31+ result : r . asns ,
3232 } ) ,
3333 } ,
3434 ] ,
@@ -45,4 +45,38 @@ export function registerRadarTools(agent: CloudflareMcpAgent) {
4545 }
4646 }
4747 )
48+
49+ agent . server . tool (
50+ 'radar_as_details' ,
51+ 'Get Autonomous System details by ASN' ,
52+ {
53+ asn : AsnParam ,
54+ } ,
55+ async ( { asn } ) => {
56+ try {
57+ const client = getCloudflareClient ( agent . props . accessToken )
58+ const r = await client . radar . entities . asns . get ( asn )
59+
60+ return {
61+ content : [
62+ {
63+ type : 'text' ,
64+ text : JSON . stringify ( {
65+ result : r . asn ,
66+ } ) ,
67+ } ,
68+ ] ,
69+ }
70+ } catch ( error ) {
71+ return {
72+ content : [
73+ {
74+ type : 'text' ,
75+ text : `Error getting AS details: ${ error instanceof Error && error . message } ` ,
76+ } ,
77+ ] ,
78+ }
79+ }
80+ }
81+ )
4882}
Original file line number Diff line number Diff line change @@ -5,12 +5,7 @@ import { z } from 'zod'
55
66import type { ASNListParams } from 'cloudflare/resources/radar/entities/asns.mjs'
77
8- export const AsnParam : z . ZodType < ASNListParams [ 'asn' ] > = z
9- . string ( )
10- . optional ( )
11- . refine ( ( val ) => val ?. split ( ',' ) . every ( ( asn ) => parseInt ( asn , 10 ) > 0 ) , {
12- message : 'ASNs must be positive integers' ,
13- } )
8+ export const AsnParam = z . number ( ) . positive ( )
149
1510export const SingleLocationParam : z . ZodType < ASNListParams [ 'location' ] > = z
1611 . string ( )
You can’t perform that action at this time.
0 commit comments