Skip to main content
Glama

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
NameRequiredDescriptionDefault
hostnamesYesList of hostnames to resolve (e.g., ['google.com', 'facebook.com'])

Implementation Reference

  • 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}` ); }
  • 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"] }
  • 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; } }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Cyreslab-AI/shodan-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server