lookup_ip_address_abuse_contacts
Report malicious IP activity by finding network administrator contact details including email, phone, and address for any IPv4 or IPv6 address.
Instructions
Get abuse contact information for an IP address to report malicious activity. Includes email, phone, and address of the network administrator. Can look up any IPv4 or IPv6 address, or your own IP if no address is provided.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| ip | No | IPv4 or IPv6 address to look up. If not provided, returns information about the caller's IP address. |
Implementation Reference
- src/index.ts:334-367 (handler)Handler function that validates the input IP address, fetches IP data using fetchIPData, extracts the 'abuse' contacts information, and returns it as formatted JSON or an error message.async ({ ip }) => { if (ip && !isValidIP(ip)) { return { content: [{ type: "text", text: `Error: "${ip}" is not a valid IPv4 or IPv6 address.` }], isError: true }; } try { const data = await fetchIPData(ip); const abuseData = { ip: data.ip, abuse: data.abuse }; return { content: [{ type: "text", text: JSON.stringify(abuseData, null, 2) }] }; } catch (error) { return { content: [{ type: "text", text: `Error: ${error instanceof Error ? error.message : String(error)}` }], isError: true }; } }
- src/index.ts:327-368 (registration)Registers the 'lookup_ip_address_abuse_contacts' tool with the MCP server, including title, description, input schema, and inline handler function.server.registerTool( "lookup_ip_address_abuse_contacts", { title: "Look up IP Address Abuse Contacts", description: "Get abuse contact information for an IP address to report malicious activity. Includes email, phone, and address of the network administrator. Can look up any IPv4 or IPv6 address, or your own IP if no address is provided.", inputSchema: IPAddressSchema }, async ({ ip }) => { if (ip && !isValidIP(ip)) { return { content: [{ type: "text", text: `Error: "${ip}" is not a valid IPv4 or IPv6 address.` }], isError: true }; } try { const data = await fetchIPData(ip); const abuseData = { ip: data.ip, abuse: data.abuse }; return { content: [{ type: "text", text: JSON.stringify(abuseData, null, 2) }] }; } catch (error) { return { content: [{ type: "text", text: `Error: ${error instanceof Error ? error.message : String(error)}` }], isError: true }; } } );
- src/index.ts:14-16 (schema)Input schema definition for the tool, accepting an optional IP address string with Zod validation and description.const IPAddressSchema = { ip: z.string().optional().describe("IPv4 or IPv6 address to look up. If not provided, returns information about the caller's IP address.") };
- src/models.ts:40-47 (schema)TypeScript interface defining the structure of abuse contact information returned by the IPLocate API.export interface AbuseInfo { address?: string | null; country_code?: string | null; email?: string | null; name?: string | null; network?: string | null; phone?: string | null; }
- src/index.ts:44-89 (helper)Helper function that makes the HTTP request to the IPLocate API to fetch comprehensive IP address data, which the handler then extracts the abuse contacts from.async function fetchIPData(ip?: string): Promise<IPLocateResponse> { const baseUrl = "https://iplocate.io/api/lookup"; const apiKey = process.env.IPLOCATE_API_KEY; let url = ip ? `${baseUrl}/${ip}` : `${baseUrl}/`; // Add API key if available if (apiKey) { url += `?apikey=${apiKey}`; } try { const response = await fetch(url, { headers: { 'User-Agent': `mcp-server-iplocate/${VERSION}` } }); if (!response.ok) { const errorText = await response.text(); let errorMessage = `API request failed with status ${response.status}`; try { const errorJson = JSON.parse(errorText); if (errorJson.error) { errorMessage = errorJson.error; } } catch { // If not JSON, use the raw text if (errorText) { errorMessage = errorText; } } throw new Error(errorMessage); } const data = await response.json() as IPLocateResponse; return data; } catch (error) { if (error instanceof Error) { throw error; } throw new Error(`Failed to fetch IP data: ${String(error)}`); } }