Skip to main content
Glama

shodan_search

Search internet-connected devices in Shodan's database to identify services, vulnerabilities, and geographic distribution using advanced filters.

Instructions

Search Shodan's database of internet-connected devices. Returns detailed information about matching devices including services, vulnerabilities, and geographic distribution. Supports advanced search filters and returns country-based statistics.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesSearch query for Shodan.
max_resultsNoMaximum results to return.

Implementation Reference

  • Implements the shodan_search tool handler: parses input arguments, queries the Shodan host/search API, formats the search results including summary, country distribution, and detailed matches with IP info, location, services, and web details.
    case "shodan_search": {
      const parsedSearchArgs = ShodanSearchArgsSchema.safeParse(args);
      if (!parsedSearchArgs.success) {
        throw new Error("Invalid search arguments");
      }
      const result: SearchResponse = await queryShodan("/shodan/host/search", {
        query: parsedSearchArgs.data.query,
        limit: parsedSearchArgs.data.max_results,
      });
    
      // Format the response in a user-friendly way
      const formattedResult = {
        "Search Summary": {
          "Query": parsedSearchArgs.data.query,
          "Total Results": result.total,
          "Results Returned": result.matches.length
        },
        "Country Distribution": result.facets?.country?.map(country => ({
          "Country": country.value,
          "Count": country.count,
          "Percentage": `${((country.count / result.total) * 100).toFixed(2)}%`
        })) || [],
        "Matches": result.matches.map(match => ({
          "Basic Information": {
            "IP Address": match.ip_str,
            "Organization": match.org,
            "ISP": match.isp,
            "ASN": match.asn,
            "Last Update": match.timestamp
          },
          "Location": {
            "Country": match.location.country_name,
            "City": match.location.city || "Unknown",
            "Region": match.location.region_code || "Unknown",
            "Coordinates": `${match.location.latitude}, ${match.location.longitude}`
          },
          "Service Details": {
            "Port": match.port,
            "Transport": match.transport,
            "Product": match.product || "Unknown",
            "Version": match.version || "Unknown",
            "CPE": match.cpe || []
          },
          "Web Information": match.http ? {
            "Server": match.http.server,
            "Title": match.http.title,
            "Robots.txt": match.http.robots ? "Present" : "Not found",
            "Sitemap": match.http.sitemap ? "Present" : "Not found"
          } : "No HTTP information",
          "Hostnames": match.hostnames,
          "Domains": match.domains
        }))
      };
    
      return {
        content: [
          {
            type: "text",
            text: JSON.stringify(formattedResult, null, 2),
          },
        ],
      };
    }
  • Zod schema defining input for shodan_search: query string and optional max_results (default 10).
    const ShodanSearchArgsSchema = z.object({
      query: z.string().describe("Search query for Shodan."),
      max_results: z
        .number()
        .optional()
        .default(10)
        .describe("Maximum results to return."),
    });
  • src/index.ts:321-325 (registration)
    Registers the shodan_search tool in the MCP server's tool list with name, description, and converted JSON schema.
    {
      name: "shodan_search",
      description: "Search Shodan's database of internet-connected devices. Returns detailed information about matching devices including services, vulnerabilities, and geographic distribution. Supports advanced search filters and returns country-based statistics.",
      inputSchema: zodToJsonSchema(ShodanSearchArgsSchema),
    },
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden for behavioral disclosure. It mentions what information is returned (services, vulnerabilities, geographic distribution, country-based statistics) but doesn't address rate limits, authentication requirements, pagination behavior, or whether this is a read-only operation. The description provides some output context but misses key operational details.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately concise with three sentences that each add value. It's front-loaded with the core purpose, followed by return details, and ending with capabilities. No wasted words, though it could be slightly more structured.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a search tool with 2 parameters and no output schema, the description provides adequate context about what the tool does and what information it returns. However, it lacks details about authentication, rate limits, and differentiation from sibling tools, which would be valuable given the server has multiple related lookup tools.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents both parameters thoroughly. The description doesn't add any meaningful parameter semantics beyond what's in the schema - it doesn't explain query syntax, advanced filter formats, or provide examples of valid queries.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool searches Shodan's database for internet-connected devices and returns detailed information about them. It specifies the resource (Shodan's database) and verb (search), but doesn't explicitly differentiate from sibling tools like 'ip_lookup' or 'dns_lookup' which might have overlapping functionality.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description mentions 'advanced search filters' but provides no guidance on when to use this tool versus alternatives like 'ip_lookup' or 'cve_lookup'. There's no mention of prerequisites, limitations, or specific scenarios where this tool is preferred over siblings.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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