File tree Expand file tree Collapse file tree 2 files changed +38
-2
lines changed Expand file tree Collapse file tree 2 files changed +38
-2
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 { AsnParam , AsOrderByParam , SingleLocationParam } from '../types/radar'
3+ import { AsnParam , AsOrderByParam , IpParam , SingleLocationParam } from '../types/radar'
44import { PaginationLimitParam , PaginationOffsetParam } from '../types/shared'
55
66export function registerRadarTools ( agent : CloudflareMcpAgent ) {
@@ -50,7 +50,7 @@ export function registerRadarTools(agent: CloudflareMcpAgent) {
5050 'radar_as_details' ,
5151 'Get Autonomous System details by ASN' ,
5252 {
53- asn : AsnParam ,
53+ asn : AsnParam ,
5454 } ,
5555 async ( { asn } ) => {
5656 try {
@@ -79,4 +79,38 @@ export function registerRadarTools(agent: CloudflareMcpAgent) {
7979 }
8080 }
8181 )
82+
83+ agent . server . tool (
84+ 'radar_ip_details' ,
85+ 'Get IP address information' ,
86+ {
87+ ip : IpParam ,
88+ } ,
89+ async ( { ip } ) => {
90+ try {
91+ const client = getCloudflareClient ( agent . props . accessToken )
92+ const r = await client . radar . entities . get ( { ip } )
93+
94+ return {
95+ content : [
96+ {
97+ type : 'text' ,
98+ text : JSON . stringify ( {
99+ result : r . ip ,
100+ } ) ,
101+ } ,
102+ ] ,
103+ }
104+ } catch ( error ) {
105+ return {
106+ content : [
107+ {
108+ type : 'text' ,
109+ text : `Error getting IP details: ${ error instanceof Error && error . message } ` ,
110+ } ,
111+ ] ,
112+ }
113+ }
114+ }
115+ )
82116}
Original file line number Diff line number Diff line change @@ -7,6 +7,8 @@ import type { ASNListParams } from 'cloudflare/resources/radar/entities/asns.mjs
77
88export const AsnParam = z . number ( ) . positive ( )
99
10+ export const IpParam = z . string ( ) . ip ( )
11+
1012export const SingleLocationParam : z . ZodType < ASNListParams [ 'location' ] > = z
1113 . string ( )
1214 . regex ( / ^ [ a - z A - Z ] { 2 } $ / , {
You can’t perform that action at this time.
0 commit comments