Skip to main content
Glama
badchars

osint-mcp-server

by badchars

shodan_search

Search Shodan for internet-connected devices using specific queries to identify hosts, services, and configurations for security analysis and reconnaissance.

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 the shodan_search logic, which fetches data from the Shodan host search API.
    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 definition for the result returned by shodanSearch.
    interface ShodanSearchResult {
      total: number;
      matches: ShodanSearchMatch[];
      facets?: Record<string, [string, number][]>;
    }
  • Registration of the shodan_search tool in the MCP tool framework, which calls the shodanSearch handler.
    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));
      },
    };
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It mentions the API key requirement, which is useful, but lacks details on rate limits, pagination behavior (beyond the 'page' parameter), error handling, or what the search results typically include. For a search tool with no annotation coverage, this leaves significant gaps in understanding its operational traits.

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 appropriately sized and front-loaded, consisting of two concise sentences: one stating the purpose with an example, and another specifying the prerequisite. Every sentence earns its place without redundancy or unnecessary elaboration.

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?

Given the complexity of a search tool with no annotations and no output schema, the description is moderately complete but has gaps. It covers the basic purpose and prerequisite, but lacks details on behavioral aspects like rate limits or result structure. For a tool with 3 parameters and 100% schema coverage, it meets minimum viability but could be more informative about operational context.

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 all parameters ('query', 'page', 'facets') with clear descriptions. The description adds no additional parameter semantics beyond what the schema provides, such as query syntax examples or facet format details, but the baseline is 3 when the schema does the heavy lifting.

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 specific action ('Search Shodan for hosts') and the resource ('hosts matching a query'), with a concrete example ('apache port:443 country:US') that illustrates the tool's function. It distinguishes itself from sibling tools like 'shodan_dns_resolve' and 'shodan_exploits' by focusing on host search rather than DNS resolution or exploit data.

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 implies usage context by specifying 'Requires SHODAN_API_KEY' as a prerequisite, but it does not explicitly state when to use this tool versus alternatives like 'shodan_host' or other search tools in the sibling list. No guidance is provided on exclusions or comparative scenarios.

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