dns_lookup
Resolve hostnames to IP addresses for cybersecurity research and threat intelligence using DNS lookup.
Instructions
Resolve hostnames to IP addresses using DNS lookup
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"hostnames": "<hostnames>"
},
"name": "dns_lookup"
}
}Input 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' in the CallToolRequestSchema switch statement. Validates input, calls ShodanClient.dnsLookup, and formats response.
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:492-507 (helper)ShodanClient method that performs the actual DNS lookup API call to Shodan /dns/resolve endpoint.
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; } } - src/index.ts:1088-1102 (schema)Input schema definition for the 'dns_lookup' tool in the ListToolsRequestSchema response.
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:1087-1103 (registration)Registration of the 'dns_lookup' tool in the tools list returned by ListToolsRequestSchema handler.
{ 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"] } },