Skip to main content
Glama

dns_lookup

Resolve domain names to IP addresses using Shodan's DNS service. Supports batch resolution of multiple hostnames in a single query.

Instructions

Resolve domain names to IP addresses using Shodan's DNS service. Supports batch resolution of multiple hostnames in a single query. Returns IP addresses mapped to their corresponding hostnames.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
hostnamesYesList of hostnames to resolve.

Implementation Reference

  • Handler for the 'dns_lookup' tool. Parses input arguments using DnsLookupArgsSchema, performs batch DNS resolution via Shodan's /dns/resolve API by joining hostnames, formats the result mapping hostnames to IPs, and returns a structured JSON response.
    case "dns_lookup": {
      const parsedDnsArgs = DnsLookupArgsSchema.safeParse(args);
      if (!parsedDnsArgs.success) {
        throw new Error("Invalid dns_lookup arguments");
      }
      
      // Join hostnames with commas for the API request
      const hostnamesString = parsedDnsArgs.data.hostnames.join(",");
      
      const result: DnsResponse = await queryShodan("/dns/resolve", {
        hostnames: hostnamesString
      });
    
      // Format the response in a user-friendly way
      const formattedResult = {
        "DNS Resolutions": Object.entries(result).map(([hostname, ip]) => ({
          "Hostname": hostname,
          "IP Address": ip
        })),
        "Summary": {
          "Total Lookups": Object.keys(result).length,
          "Queried Hostnames": parsedDnsArgs.data.hostnames
        }
      };
      
      return {
        content: [
          {
            type: "text",
            text: JSON.stringify(formattedResult, null, 2)
          },
        ],
      };
    }
  • Zod schema defining the input parameters for the dns_lookup tool: an array of strings representing hostnames to resolve.
    const DnsLookupArgsSchema = z.object({
      hostnames: z.array(z.string()).describe("List of hostnames to resolve."),
    });
  • src/index.ts:331-335 (registration)
    Tool registration in the ListToolsRequestSchema handler, defining the name, description, and input schema (converted from Zod to JSON schema) for dns_lookup.
    {
      name: "dns_lookup",
      description: "Resolve domain names to IP addresses using Shodan's DNS service. Supports batch resolution of multiple hostnames in a single query. Returns IP addresses mapped to their corresponding hostnames.",
      inputSchema: zodToJsonSchema(DnsLookupArgsSchema),
    },

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/BurtTheCoder/mcp-shodan'

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