whois_lookup_by_ip
Retrieve WHOIS records for any IP address or range to identify ownership, registration details, and network information from authoritative sources like ARIN and RIPE.
Instructions
WHOIS lookup by IP address or IP range.
Args: ip: IP address or range to lookup page: Page number for paginated results source: Filter by WHOIS source (arin, ripe, afrinic, apnic, lacnic)
Returns: WHOIS records for the IP or range.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| ip | Yes | ||
| page | No | ||
| source | No |
Implementation Reference
- src/mcp_ipinfo/server.py:297-319 (handler)The @mcp.tool()-decorated handler function implementing the core logic of the whois_lookup_by_ip tool, including client retrieval, parameter conversion, API call, and error handling.@mcp.tool() async def whois_lookup_by_ip( ip: str, ctx: Context[Any, Any, Any], page: int | None = None, source: str | None = None ) -> dict[str, Any]: """WHOIS lookup by IP address or IP range. Args: ip: IP address or range to lookup page: Page number for paginated results source: Filter by WHOIS source (arin, ripe, afrinic, apnic, lacnic) Returns: WHOIS records for the IP or range. """ client = get_client(ctx) whois_source = WhoisSource(source) if source else None try: result = await client.get_whois_net_by_ip(ip, page, whois_source) return result.model_dump(exclude_none=True) except IPInfoAPIError as e: ctx.error(f"API error: {e.message}") raise
- src/mcp_ipinfo/api_client.py:251-263 (helper)Supporting method in IPInfoClient that performs the HTTP GET request to the IPInfo WHOIS/net/{ip} endpoint and parses the response into WhoisIpResponse model.async def get_whois_net_by_ip( self, ip: str, page: int | None = None, source: WhoisSource | None = None ) -> WhoisIpResponse: """Get WHOIS information by IP or IP range.""" params: dict[str, Any] = {} if page is not None: params["page"] = page if source: params["source"] = source.value data = await self._request("GET", f"/whois/net/{ip}", params=params or None) return WhoisIpResponse(**data)
- src/mcp_ipinfo/api_models.py:133-138 (schema)Pydantic model defining the output schema for WHOIS IP lookup responses, used by the client and returned (as dict) by the tool.class WhoisIpResponse(BaseModel): net: str | None = None total: int | None = None page: int | None = None records: list[WhoisRecord] | None = None
- src/mcp_ipinfo/api_models.py:109-124 (schema)Pydantic model for individual WHOIS records contained within the WhoisIpResponse.class WhoisRecord(BaseModel): range: str | None = None id: str | None = None name: str | None = None country: str | None = None org: str | None = None admin: Any | None = None abuse: Any | None = None tech: Any | None = None maintainer: Any | None = None updated: str | None = None status: str | None = None source: str | None = None raw: str | None = None domain: str | None = None
- src/mcp_ipinfo/api_models.py:15-20 (schema)Enum defining valid WHOIS sources used for filtering in the tool parameters and API requests.class WhoisSource(str, Enum): ARIN = "arin" RIPE = "ripe" AFRINIC = "afrinic" APNIC = "apnic" LACNIC = "lacnic"