Skip to main content
Glama
Cyreslab-AI

Shodan MCP Server

search_iot_devices

Find specific types of internet-connected IoT devices like webcams or routers using Shodan's cybersecurity research data. Filter by country and limit results for threat intelligence analysis.

Instructions

Search for specific types of IoT devices

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
device_typeYesType of IoT device to search for (e.g., 'webcam', 'router', 'smart tv')
countryNoOptional country code to limit search (e.g., 'US', 'DE')
max_itemsNoMaximum number of items to include in results (default: 5)

Implementation Reference

  • MCP CallTool handler for 'search_iot_devices' that extracts parameters, calls ShodanClient.searchIotDevices method, handles errors, and returns JSON-formatted results.
    case "search_iot_devices": {
      const deviceType = String(request.params.arguments?.device_type);
      if (!deviceType) {
        throw new McpError(
          ErrorCode.InvalidParams,
          "Device type is required"
        );
      }
    
      const country = request.params.arguments?.country
        ? String(request.params.arguments.country)
        : undefined;
      const maxItems = Number(request.params.arguments?.max_items) || 5;
    
      try {
        const iotDevices = await shodanClient.searchIotDevices(deviceType, country, maxItems);
    
        // Check if we got an error response from the IoT devices search method
        if (iotDevices.error && iotDevices.status === 401) {
          return {
            content: [{
              type: "text",
              text: JSON.stringify(iotDevices, null, 2)
            }]
          };
        }
    
        return {
          content: [{
            type: "text",
            text: JSON.stringify(iotDevices, null, 2)
          }]
        };
      } catch (error) {
        if (error instanceof McpError) {
          throw error;
        }
        throw new McpError(
          ErrorCode.InternalError,
          `Error searching for IoT devices: ${(error as Error).message}`
        );
      }
    }
  • ShodanClient.searchIotDevices method: constructs Shodan search query for IoT devices, fetches data from Shodan API, samples results, extracts relevant fields, and handles API errors.
    async searchIotDevices(deviceType: string, country?: string, maxItems: number = 5): Promise<any> {
      try {
        // Build query based on device type and optional country
        let query = `"${deviceType}"`;
        if (country) {
          query += ` country:${country}`;
        }
    
        const response = await this.axiosInstance.get("/shodan/host/search", {
          params: { query }
        });
    
        const results = this.sampleResponse(response.data, maxItems);
    
        // Extract relevant IoT device information
        if (results.matches && results.matches.length > 0) {
          const devices = results.matches.map((match: any) => {
            return {
              ip: match.ip_str,
              port: match.port,
              organization: match.org,
              location: match.location,
              hostnames: match.hostnames,
              product: match.product,
              version: match.version,
              timestamp: match.timestamp
            };
          });
    
          return {
            total_found: results.total,
            sample_size: devices.length,
            devices: devices
          };
        }
    
        return { total_found: 0, devices: [] };
      } catch (error: unknown) {
        if (axios.isAxiosError(error)) {
          if (error.response?.status === 401) {
            return {
              error: "Unauthorized: The Shodan search API requires a paid membership. Your API key does not have access to this endpoint.",
              message: "The IoT device search functionality requires a Shodan membership subscription with API access. Please upgrade your Shodan plan to use this feature.",
              status: 401
            };
          }
          throw new McpError(
            ErrorCode.InternalError,
            `Shodan API error: ${error.response?.data?.error || error.message}`
          );
        }
        throw error;
      }
    }
  • Tool schema definition including input schema for 'search_iot_devices' registered in ListTools handler.
    {
      name: "search_iot_devices",
      description: "Search for specific types of IoT devices",
      inputSchema: {
        type: "object",
        properties: {
          device_type: {
            type: "string",
            description: "Type of IoT device to search for (e.g., 'webcam', 'router', 'smart tv')"
          },
          country: {
            type: "string",
            description: "Optional country code to limit search (e.g., 'US', 'DE')"
          },
          max_items: {
            type: "number",
            description: "Maximum number of items to include in results (default: 5)"
          }
        },
        required: ["device_type"]
      }
  • src/index.ts:982-1002 (registration)
    Registration of 'search_iot_devices' tool in the ListToolsRequestSchema response, defining name, description, and input schema.
    {
      name: "search_iot_devices",
      description: "Search for specific types of IoT devices",
      inputSchema: {
        type: "object",
        properties: {
          device_type: {
            type: "string",
            description: "Type of IoT device to search for (e.g., 'webcam', 'router', 'smart tv')"
          },
          country: {
            type: "string",
            description: "Optional country code to limit search (e.g., 'US', 'DE')"
          },
          max_items: {
            type: "number",
            description: "Maximum number of items to include in results (default: 5)"
          }
        },
        required: ["device_type"]
      }
Behavior2/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 'search' but doesn't clarify if this is a read-only operation, what permissions are needed, rate limits, or what the output format looks like. For a search tool with zero annotation coverage, this is a significant gap in transparency.

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 a single, efficient sentence with zero waste. It's front-loaded with the core purpose ('Search for specific types of IoT devices') and avoids unnecessary elaboration. Every word earns its place, making it highly concise and well-structured.

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

Completeness2/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 incomplete. It doesn't explain what the search returns, how results are formatted, or any behavioral aspects like pagination or error handling. The 100% schema coverage helps with inputs, but overall context is lacking for effective tool use.

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 three parameters thoroughly. The description adds no additional parameter semantics beyond what's in the schema (e.g., it doesn't explain parameter interactions or provide examples beyond the schema's descriptions). Baseline 3 is appropriate 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.

Purpose4/5

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

The description clearly states the action ('search for') and resource ('IoT devices'), specifying the scope ('specific types'). It distinguishes from siblings like 'get_cpes' or 'scan_network_range' by focusing on IoT device search. However, it doesn't explicitly differentiate from 'search_cves' or 'search_shodan' beyond the IoT focus, keeping it at 4 rather than 5.

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?

No guidance is provided on when to use this tool versus alternatives. The description lacks context about prerequisites, when-not-to-use scenarios, or comparisons to sibling tools like 'get_cpes' or 'search_shodan'. It only states the basic purpose without usage instructions.

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/Cyreslab-AI/shodan-mcp-server'

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