shodan_dns_resolve
Resolve hostnames to IP addresses using Shodan's DNS resolver for network reconnaissance and mapping.
Instructions
Resolve hostnames to IPs using Shodan's DNS resolver. Requires SHODAN_API_KEY.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| hostnames | Yes | Hostnames to resolve |
Implementation Reference
- src/shodan/index.ts:126-132 (handler)Core handler function that calls the Shodan DNS resolve API. Takes hostnames array and API key, returns a record mapping hostnames to IPs (or null).
export async function shodanDnsResolve(hostnames: string[], apiKey: string): Promise<Record<string, string | null>> { await limiter.acquire(); const csv = hostnames.join(","); const res = await fetch(`https://api.shodan.io/dns/resolve?hostnames=${encodeURIComponent(csv)}&key=${apiKey}`); if (!res.ok) throw new Error(`Shodan DNS resolve failed: ${res.status}`); return res.json(); } - src/protocol/tools.ts:156-158 (schema)Zod schema for the shodan_dns_resolve tool: expects an array of hostname strings.
schema: { hostnames: z.array(z.string()).describe("Hostnames to resolve"), }, - src/protocol/tools.ts:153-163 (registration)ToolDef registration for shodan_dns_resolve: defines name, description, schema, and execute handler that calls shodanDnsResolve.
const shodanDnsResolveTool: ToolDef = { name: "shodan_dns_resolve", description: "Resolve hostnames to IPs using Shodan's DNS resolver. Requires SHODAN_API_KEY.", schema: { hostnames: z.array(z.string()).describe("Hostnames to resolve"), }, execute: async (args, ctx) => { const key = requireApiKey(ctx.config.shodanApiKey, "Shodan", "SHODAN_API_KEY"); return json(await shodanDnsResolve(args.hostnames as string[], key)); }, }; - src/protocol/tools.ts:497-497 (registration)The tool is included in the allTools array, registering it with the MCP system.
shodanDnsResolveTool, - src/index.ts:36-36 (registration)shodan_dns_resolve listed under the 'Shodan' tool category with env requirement SHODAN_API_KEY.
{ label: "Shodan", env: "SHODAN_API_KEY", tools: ["shodan_host", "shodan_search", "shodan_dns_resolve", "shodan_exploits"] },