dns_lookup
Convert hostnames to IP addresses using DNS resolution, enabling network analysis and cybersecurity research. Input a list of hostnames to retrieve their associated IPs.
Instructions
Resolve hostnames to IP addresses using DNS lookup
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| hostnames | Yes | List of hostnames to resolve (e.g., ['google.com', 'facebook.com']) |
Implementation Reference
- src/index.ts:1694-1719 (handler)MCP tool handler for 'dns_lookup': validates input hostnames array and calls shodanClient.dnsLookup to resolve hostnames to IPs.case "dns_lookup": { const hostnames = request.params.arguments?.hostnames; if (!Array.isArray(hostnames) || hostnames.length === 0) { throw new McpError( ErrorCode.InvalidParams, "Hostnames array is required" ); } try { const dnsResults = await shodanClient.dnsLookup(hostnames.map(String)); return { content: [{ type: "text", text: JSON.stringify(dnsResults, null, 2) }] }; } catch (error) { if (error instanceof McpError) { throw error; } throw new McpError( ErrorCode.InternalError, `Error performing DNS lookup: ${(error as Error).message}` ); }
- src/index.ts:1088-1102 (schema)Input schema definition for the 'dns_lookup' tool, specifying hostnames array as required input.name: "dns_lookup", description: "Resolve hostnames to IP addresses using DNS lookup", inputSchema: { type: "object", properties: { hostnames: { type: "array", items: { type: "string" }, description: "List of hostnames to resolve (e.g., ['google.com', 'facebook.com'])" } }, required: ["hostnames"] }
- src/index.ts:492-507 (helper)ShodanClient.dnsLookup method: performs the actual API call to Shodan's /dns/resolve endpoint to resolve multiple hostnames.async dnsLookup(hostnames: string[]): Promise<any> { try { const response = await this.axiosInstance.get("/dns/resolve", { params: { hostnames: hostnames.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; } }