Skip to main content
Glama
badchars

osint-mcp-server

by badchars

shodan_search

Query Shodan to find internet-connected devices and services matching specific criteria. Retrieve host IPs, open ports, banners, and metadata for reconnaissance and attack surface analysis.

Instructions

Search Shodan for hosts matching a query (e.g. 'apache port:443 country:US'). Requires SHODAN_API_KEY.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesShodan search query
pageNoResults page number (default: 1)
facetsNoFacets to include (e.g. 'country,org')

Implementation Reference

  • The actual implementation of shodanSearch — calls the Shodan API /shodan/host/search endpoint, parses the response into ShodanSearchResult (total, matches, facets).
    export async function shodanSearch(query: string, apiKey: string, page = 1, facets?: string): Promise<ShodanSearchResult> {
      await limiter.acquire();
      const params = new URLSearchParams({ key: apiKey, query, page: String(page) });
      if (facets) params.set("facets", facets);
    
      const res = await fetch(`https://api.shodan.io/shodan/host/search?${params}`);
      if (!res.ok) throw new Error(`Shodan search failed: ${res.status} ${res.statusText}`);
      const data = await res.json();
    
      return {
        total: data.total ?? 0,
        matches: (data.matches ?? []).map((m: any) => ({
          ip_str: m.ip_str,
          port: m.port,
          org: m.org,
          hostnames: m.hostnames ?? [],
          product: m.product,
          os: m.os,
          asn: m.asn,
          domains: m.domains ?? [],
        })),
        facets: data.facets,
      };
    }
  • Type definitions for ShodanSearchMatch and ShodanSearchResult — the input/output shapes used by the search handler.
    interface ShodanSearchMatch {
      ip_str: string;
      port: number;
      org?: string;
      hostnames: string[];
      product?: string;
      os?: string;
      asn?: string;
      domains: string[];
    }
    
    interface ShodanSearchResult {
      total: number;
      matches: ShodanSearchMatch[];
      facets?: Record<string, [string, number][]>;
    }
  • Tool registration definition for shodan_search — maps the name, description, Zod schema (query, page, facets), and execute handler that calls the shodanSearch function.
    const shodanSearchTool: ToolDef = {
      name: "shodan_search",
      description: "Search Shodan for hosts matching a query (e.g. 'apache port:443 country:US'). Requires SHODAN_API_KEY.",
      schema: {
        query: z.string().describe("Shodan search query"),
        page: z.number().optional().describe("Results page number (default: 1)"),
        facets: z.string().optional().describe("Facets to include (e.g. 'country,org')"),
      },
      execute: async (args, ctx) => {
        const key = requireApiKey(ctx.config.shodanApiKey, "Shodan", "SHODAN_API_KEY");
        return json(await shodanSearch(args.query as string, key, args.page as number | undefined, args.facets as string | undefined));
      },
    };
  • Import of shodanSearch from the shodan module into the tools registry.
    import { shodanHost, shodanSearch, shodanDnsResolve, shodanExploits } from "../shodan/index.js";
  • The shodanSearchTool is included in the allTools array for export.
    shodanSearchTool,
Behavior3/5

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

With no annotations provided, the description carries the full burden. It discloses the authentication requirement (SHODAN_API_KEY) but does not explicitly state that the operation is read-only, mention rate limits, or describe error conditions. While safe for a search tool, more behavioral context would be helpful.

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

Conciseness5/5

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

The description is extremely concise—two sentences that cover purpose, example, and prerequisite. Every word earns its place with no redundancy or fluff.

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 tool with 3 parameters and no output schema or annotations, the description provides the essential elements: purpose, example, and auth requirement. However, it lacks information about pagination (page parameter behavior), response format, or potential errors, which would improve completeness.

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

Parameters4/5

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

All three parameters are described in the input schema (100% coverage). The description adds value by providing a query example that illustrates the syntax, which is useful for agents. However, it does not add meaning to the 'page' or 'facets' parameters beyond what the schema already provides.

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

Purpose5/5

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

The description clearly states the action ('Search Shodan for hosts'), the resource ('hosts'), and provides a concrete query example. This distinguishes it from sibling tools like shodan_host (which likely retrieves details for a single host) and shodan_exploits (searching exploits).

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

Usage Guidelines3/5

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

The description mentions a prerequisite ('Requires SHODAN_API_KEY') but does not specify when to use this tool over its siblings (e.g., shodan_host, shodan_dns_resolve). The example implies general host searching, but explicit context for when to choose this vs alternatives is missing.

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/badchars/osint-mcp-server'

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