reverse_dns_lookup
Retrieve hostnames associated with IP addresses using reverse DNS lookup on the Shodan MCP Server, aiding in cybersecurity research and threat intelligence.
Instructions
Get hostnames for IP addresses using reverse DNS lookup
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| ips | Yes | List of IP addresses to lookup (e.g., ['8.8.8.8', '1.1.1.1']) |
Input Schema (JSON Schema)
{
"properties": {
"ips": {
"description": "List of IP addresses to lookup (e.g., ['8.8.8.8', '1.1.1.1'])",
"items": {
"type": "string"
},
"type": "array"
}
},
"required": [
"ips"
],
"type": "object"
}
Implementation Reference
- src/index.ts:1722-1748 (handler)MCP CallToolRequest handler case for 'reverse_dns_lookup': validates ips array input, calls ShodanClient.reverseDnsLookup, formats response as JSON text.case "reverse_dns_lookup": { const ips = request.params.arguments?.ips; if (!Array.isArray(ips) || ips.length === 0) { throw new McpError( ErrorCode.InvalidParams, "IPs array is required" ); } try { const reverseDnsResults = await shodanClient.reverseDnsLookup(ips.map(String)); return { content: [{ type: "text", text: JSON.stringify(reverseDnsResults, null, 2) }] }; } catch (error) { if (error instanceof McpError) { throw error; } throw new McpError( ErrorCode.InternalError, `Error performing reverse DNS lookup: ${(error as Error).message}` ); } }
- src/index.ts:1105-1120 (registration)Tool registration in ListToolsRequest handler: defines name, description, and input schema for reverse_dns_lookup.name: "reverse_dns_lookup", description: "Get hostnames for IP addresses using reverse DNS lookup", inputSchema: { type: "object", properties: { ips: { type: "array", items: { type: "string" }, description: "List of IP addresses to lookup (e.g., ['8.8.8.8', '1.1.1.1'])" } }, required: ["ips"] } },
- src/index.ts:512-527 (helper)ShodanClient helper method: performs reverse DNS lookup by calling Shodan API /dns/reverse endpoint with comma-separated IPs.async reverseDnsLookup(ips: string[]): Promise<any> { try { const response = await this.axiosInstance.get("/dns/reverse", { params: { ips: ips.join(',') } }); return response.data; } catch (error: unknown) { if (axios.isAxiosError(error)) { throw new McpError( ErrorCode.InternalError, `Shodan API error: ${error.response?.data?.error || error.message}` ); } throw error; } }
- src/index.ts:1108-1119 (schema)Input schema definition for reverse_dns_lookup tool: requires 'ips' array of strings.type: "object", properties: { ips: { type: "array", items: { type: "string" }, description: "List of IP addresses to lookup (e.g., ['8.8.8.8', '1.1.1.1'])" } }, required: ["ips"] }