Skip to content

Commit f2940df

Browse files
committed
add radar_ip_details tool
1 parent e8bdd03 commit f2940df

File tree

2 files changed

+38
-2
lines changed

2 files changed

+38
-2
lines changed

packages/mcp-common/src/tools/radar.ts

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { getCloudflareClient } from '../cloudflare-api'
22
import { type CloudflareMcpAgent } from '../types/cloudflare-mcp-agent'
3-
import { AsnParam, AsOrderByParam, SingleLocationParam } from '../types/radar'
3+
import { AsnParam, AsOrderByParam, IpParam, SingleLocationParam } from '../types/radar'
44
import { PaginationLimitParam, PaginationOffsetParam } from '../types/shared'
55

66
export 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
}

packages/mcp-common/src/types/radar.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import type { ASNListParams } from 'cloudflare/resources/radar/entities/asns.mjs
77

88
export const AsnParam = z.number().positive()
99

10+
export const IpParam = z.string().ip()
11+
1012
export const SingleLocationParam: z.ZodType<ASNListParams['location']> = z
1113
.string()
1214
.regex(/^[a-zA-Z]{2}$/, {

0 commit comments

Comments
 (0)