whois_ip
Retrieve network registration data for an IP address, including network name, CIDR range, country, and responsible entities.
Instructions
RDAP/WHOIS lookup for an IP address. Returns network name, CIDR range, country, and responsible entities.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| ip | Yes | IP address to look up |
Implementation Reference
- src/whois/index.ts:105-145 (handler)The `whoisIp` function performs RDAP/WHOIS lookup for an IP address by calling https://rdap.org/ip/{ip}, parsing the response into network info (name, CIDR, country, start/end addresses) and associated entities.
export async function whoisIp(ip: string): Promise<RdapIpResult> { await limiter.acquire(); const res = await fetch(`https://rdap.org/ip/${ip}`); if (!res.ok) throw new Error(`RDAP IP lookup failed: ${res.status} ${res.statusText}`); const data = await res.json(); const entities: RdapIpResult["entities"] = []; if (data.entities) { for (const ent of data.entities) { const roles = ent.roles ?? []; const vcard = ent.vcardArray?.[1]; let name: string | undefined; if (vcard) { const fn = vcard.find((f: any) => f[0] === "fn"); if (fn) name = fn[3]; } for (const role of roles) { entities.push({ role, name }); } } } // Build CIDR from cidr0_cidrs let cidr: string | undefined; if (data.cidr0_cidrs?.[0]) { const c = data.cidr0_cidrs[0]; cidr = `${c.v4prefix ?? c.v6prefix}/${c.length}`; } return { ip, name: data.name, type: data.type, startAddress: data.startAddress, endAddress: data.endAddress, cidr, country: data.country, entities, port43: data.port43, }; } - src/whois/index.ts:19-29 (schema)The `RdapIpResult` interface defines the return type for IP WHOIS lookups, including ip, name, type, startAddress, endAddress, cidr, country, entities, and port43.
interface RdapIpResult { ip: string; name?: string; type?: string; startAddress?: string; endAddress?: string; cidr?: string; country?: string; entities: { role: string; name?: string }[]; port43?: string; } - src/protocol/tools.ts:99-106 (registration)The `whoisIpTool` definition registers the tool with name 'whois_ip', description, Zod schema requiring 'ip' as a string, and an execute function that calls `whoisIp(args.ip)`.
const whoisIpTool: ToolDef = { name: "whois_ip", description: "RDAP/WHOIS lookup for an IP address. Returns network name, CIDR range, country, and responsible entities.", schema: { ip: z.string().describe("IP address to look up"), }, execute: async (args) => json(await whoisIp(args.ip as string)), }; - src/protocol/tools.ts:491-491 (registration)The `whoisIpTool` is included in the `allTools` array export, making it available to the MCP server.
whoisIpTool, - src/index.ts:28-28 (registration)The tool is listed under the 'WHOIS / RDAP' category in the TOOL_CATEGORIES array for display purposes.
{ label: "WHOIS / RDAP", env: null, tools: ["whois_domain", "whois_ip"] },