(agent: RadarMCP)
| 185 | } |
| 186 | |
| 187 | export function registerRadarTools(agent: RadarMCP) { |
| 188 | agent.server.registerTool( |
| 189 | 'list_autonomous_systems', |
| 190 | { |
| 191 | description: 'List Autonomous Systems', |
| 192 | inputSchema: { |
| 193 | limit: PaginationLimitParam, |
| 194 | offset: PaginationOffsetParam, |
| 195 | location: LocationParam.optional(), |
| 196 | orderBy: AsOrderByParam, |
| 197 | }, |
| 198 | }, |
| 199 | async ({ limit, offset, location, orderBy }) => { |
| 200 | try { |
| 201 | const props = getProps(agent) |
| 202 | const client = getCloudflareClient(props.accessToken) |
| 203 | const r = await client.radar.entities.asns.list({ |
| 204 | limit, |
| 205 | offset, |
| 206 | location, |
| 207 | orderBy, |
| 208 | }) |
| 209 | |
| 210 | return { |
| 211 | content: [ |
| 212 | { |
| 213 | type: 'text', |
| 214 | text: JSON.stringify({ |
| 215 | result: r.asns, |
| 216 | }), |
| 217 | }, |
| 218 | ], |
| 219 | } |
| 220 | } catch (error) { |
| 221 | return { |
| 222 | content: [ |
| 223 | { |
| 224 | type: 'text', |
| 225 | text: `Error listing ASes: ${error instanceof Error && error.message}`, |
| 226 | }, |
| 227 | ], |
| 228 | } |
| 229 | } |
| 230 | } |
| 231 | ) |
| 232 | |
| 233 | agent.server.registerTool( |
| 234 | 'get_as_details', |
| 235 | { |
| 236 | description: 'Get Autonomous System details by ASN', |
| 237 | inputSchema: { |
| 238 | asn: AsnParam, |
| 239 | }, |
| 240 | }, |
| 241 | async ({ asn }) => { |
| 242 | try { |
| 243 | const props = getProps(agent) |
| 244 | const client = getCloudflareClient(props.accessToken) |
no test coverage detected