Skip to main content
Glama
badchars

osint-mcp-server

by badchars

shodan_host

Retrieve comprehensive host intelligence for an IP address, including open ports, services, vulnerabilities, and geolocation data from Shodan's database.

Instructions

Get Shodan host details for an IP: open ports, services, banners, vulns, OS, ASN, geolocation. Requires SHODAN_API_KEY.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
ipYesIP address to look up

Implementation Reference

  • The handler implementation for the `shodan_host` tool. It fetches host details from the Shodan API using the provided IP and API key, performs data transformation, and includes caching.
    export async function shodanHost(ip: string, apiKey: string): Promise<ShodanHostResult> {
      const cacheKey = `host:${ip}`;
      const cached = cache.get(cacheKey);
      if (cached) return cached;
    
      await limiter.acquire();
      const res = await fetch(`https://api.shodan.io/shodan/host/${encodeURIComponent(ip)}?key=${apiKey}`);
      if (!res.ok) throw new Error(`Shodan host lookup failed: ${res.status} ${res.statusText}`);
      const data = await res.json();
    
      const services: ShodanService[] = (data.data ?? []).map((s: any) => ({
        port: s.port,
        transport: s.transport ?? "tcp",
        product: s.product,
        version: s.version,
        cpe: s.cpe,
        banner: s.data ? String(s.data).slice(0, 500) : undefined,
      }));
    
      const result: ShodanHostResult = {
        ip: data.ip_str ?? ip,
        hostnames: data.hostnames ?? [],
        org: data.org,
        isp: data.isp,
        os: data.os,
        asn: data.asn,
        country: data.country_name,
        city: data.city,
        vulns: data.vulns,
        ports: data.ports ?? [],
        services,
        lastUpdate: data.last_update,
        tags: data.tags,
      };
    
      cache.set(cacheKey, result);
      return result;
    }
  • Interface defining the structure of the result returned by `shodan_host`.
    interface ShodanHostResult {
      ip: string;
      hostnames: string[];
      org?: string;
      isp?: string;
      os?: string;
      asn?: string;
      country?: string;
      city?: string;
      vulns?: string[];
      ports: number[];
      services: ShodanService[];
      lastUpdate?: string;
      tags?: string[];
    }
  • Registration of the `shodan_host` tool definition, including the schema and the execution wrapper.
    const shodanHostTool: ToolDef = {
      name: "shodan_host",
      description: "Get Shodan host details for an IP: open ports, services, banners, vulns, OS, ASN, geolocation. Requires SHODAN_API_KEY.",
      schema: {
        ip: z.string().describe("IP address to look up"),
      },
      execute: async (args, ctx) => {
        const key = requireApiKey(ctx.config.shodanApiKey, "Shodan", "SHODAN_API_KEY");
        return json(await shodanHost(args.ip as string, key));
      },
    };
    
    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)"),
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 of behavioral disclosure. It mentions the requirement for SHODAN_API_KEY, which is useful context about authentication needs. However, it doesn't describe other behavioral traits such as rate limits, potential costs, error conditions, or what happens if the IP isn't found in Shodan's database. The description is accurate but lacks depth for a tool that likely involves external API calls.

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 and front-loaded with all essential information in a single sentence. Every word earns its place: it specifies the action, target, details returned, and authentication requirement without any fluff or redundancy.

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 tool's moderate complexity (external API call with authentication), no annotations, and no output schema, the description provides basic completeness by stating what the tool does and the API key requirement. However, it lacks information about return format, error handling, or limitations that would be helpful for an AI agent to use this tool effectively in context with many sibling 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?

The input schema has 100% description coverage, with the 'ip' parameter clearly documented as 'IP address to look up'. The description adds no additional parameter semantics beyond what's in the schema. According to the rules, when schema_description_coverage is high (>80%), the baseline score is 3 even with no param info in the description, which applies here.

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 verb 'Get' and resource 'Shodan host details for an IP', with specific examples of what details are included (open ports, services, banners, vulns, OS, ASN, geolocation). It doesn't explicitly differentiate from sibling tools like 'shodan_search' or 'shodan_dns_resolve', but the focus on host details for a specific IP provides reasonable implicit distinction.

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 'for an IP' and mentioning the required SHODAN_API_KEY, which suggests when to use this tool. However, it doesn't provide explicit guidance on when to choose this tool over alternatives like 'shodan_search' or other IP lookup tools in the sibling list, nor does it mention any exclusions or prerequisites beyond the API key.

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