bgp_asn
Retrieve ASN details, including name, description, contacts, and all announced IPv4/IPv6 prefixes, using BGPView.
Instructions
Look up ASN details and announced IPv4/IPv6 prefixes via BGPView. Returns ASN name, description, contacts, and all announced prefixes.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| asn | Yes | Autonomous System Number (e.g. 13335) |
Implementation Reference
- src/bgp/index.ts:50-78 (handler)The main handler function `bgpAsn` that implements the tool logic: fetches ASN details and prefixes from BGPView API, with caching (30 min TTL) and rate limiting (2s interval).
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/bgp/index.ts:9-19 (schema)The `BgpAsnResult` interface defines the schema/return type for the ASN lookup: ASN number, name, description, country code, contacts, IPv4 and IPv6 prefixes.
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 }[]; } - src/protocol/tools.ts:343-350 (registration)The tool registration in `src/protocol/tools.ts`: defines the tool name `bgp_asn`, description, input schema (z.number() for 'asn'), and wires execution 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/protocol/tools.ts:516-518 (registration)The tool is included in the exported tools array (line 516), making it available in the MCP tool list.
bgpAsnTool, bgpIpTool, bgpPrefixTool, - src/index.ts:31-31 (registration)Registration in the main `src/index.ts` file as part of the 'BGP / ASN' tool category listing.
{ label: "BGP / ASN", env: null, tools: ["bgp_asn", "bgp_ip", "bgp_prefix"] },