bgp_ip
Look up BGP routing information for any IP address to identify matching prefixes, ASNs, and RIR allocation data.
Instructions
Look up BGP routing information for an IP address. Returns matching prefixes, ASNs, and RIR allocation.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| ip | Yes | IP address to look up |
Implementation Reference
- src/bgp/index.ts:82-99 (handler)The actual implementation (handler) of the `bgp_ip` tool.
export async function bgpIp(ip: string): Promise<BgpIpResult> { const key = `ip:${ip}`; const cached = cache.get(key); if (cached) return cached; const data = await bgpFetch(`/ip/${ip}`); const result: BgpIpResult = { ip, prefixes: (data.prefixes ?? []).map((p: any) => ({ prefix: p.prefix, asn: p.asn?.asn, name: p.name, description: p.description, countryCode: p.country_code, })), rir: data.rir_allocation?.rir_name ?? "", }; cache.set(key, result); return result; } - src/bgp/index.ts:21-25 (schema)Type definition for the BGP IP lookup result.
interface BgpIpResult { ip: string; prefixes: { prefix: string; asn: number; name: string; description: string; countryCode: string }[]; rir: string; } - src/protocol/tools.ts:352-360 (registration)Tool definition and registration for `bgp_ip`.
const bgpIpTool: ToolDef = { name: "bgp_ip", description: "Look up BGP routing information for an IP address. Returns matching prefixes, ASNs, and RIR allocation.", schema: { ip: z.string().describe("IP address to look up"), }, execute: async (args) => json(await bgpIp(args.ip as string)), };