bgp_asn
Retrieve BGP ASN details including organization information, contacts, and announced IP prefixes to analyze network ownership and routing data.
Instructions
Look up ASN details and announced IPv4/IPv6 prefixes via BGPView. Returns ASN name, description, contacts, and all announced prefixes.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| asn | Yes | Autonomous System Number (e.g. 13335) |
Implementation Reference
- src/bgp/index.ts:50-78 (handler)The implementation of the 'bgpAsn' function which fetches and processes BGP ASN data from BGPView.
export async function bgpAsn(asn: number): Promise<BgpAsnResult> { const key = `asn:${asn}`; const cached = cache.get(key); if (cached) return cached; const [info, prefixes] = await Promise.all([ bgpFetch(`/asn/${asn}`), bgpFetch(`/asn/${asn}/prefixes`), ]); const result: BgpAsnResult = { asn: info.asn, name: info.name ?? "", description: info.description_short ?? info.description_full ?? "", countryCode: info.country_code ?? "", emailContacts: info.email_contacts ?? [], abuseContacts: info.abuse_contacts ?? [], website: info.website, ipv4Prefixes: (prefixes.ipv4_prefixes ?? []).map((p: any) => ({ prefix: p.prefix, name: p.name, description: p.description, countryCode: p.country_code, })), ipv6Prefixes: (prefixes.ipv6_prefixes ?? []).map((p: any) => ({ prefix: p.prefix, name: p.name, description: p.description, countryCode: p.country_code, })), }; cache.set(key, result); return result; } - src/protocol/tools.ts:343-350 (registration)The registration of the 'bgp_asn' tool, defining its schema, description, and mapping to the 'bgpAsn' handler.
const bgpAsnTool: ToolDef = { name: "bgp_asn", description: "Look up ASN details and announced IPv4/IPv6 prefixes via BGPView. Returns ASN name, description, contacts, and all announced prefixes.", schema: { asn: z.number().describe("Autonomous System Number (e.g. 13335)"), }, execute: async (args) => json(await bgpAsn(args.asn as number)), }; - src/bgp/index.ts:9-19 (schema)The TypeScript interface 'BgpAsnResult' defining the structure of the data returned by the tool.
interface BgpAsnResult { asn: number; name: string; description: string; countryCode: string; emailContacts: string[]; abuseContacts: string[]; website?: string; ipv4Prefixes: { prefix: string; name: string; description: string; countryCode: string }[]; ipv6Prefixes: { prefix: string; name: string; description: string; countryCode: string }[]; }