Skip to main content
Glama
Cyreslab-AI

Shodan MCP Server

parse_search_tokens

Analyze Shodan search queries to identify filters and parameters, helping users understand how their searches work for cybersecurity research.

Instructions

Parse a search query to understand which filters and parameters are being used

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesShodan search query to parse and analyze

Implementation Reference

  • MCP server handler for executing the 'parse_search_tokens' tool. Validates input query, calls the ShodanClient helper method, formats the response as JSON text content, and handles errors.
    case "parse_search_tokens": {
      const query = String(request.params.arguments?.query);
      if (!query) {
        throw new McpError(
          ErrorCode.InvalidParams,
          "Search query is required"
        );
      }
    
      try {
        const tokens = await shodanClient.parseSearchTokens(query);
        return {
          content: [{
            type: "text",
            text: JSON.stringify(tokens, null, 2)
          }]
        };
      } catch (error) {
        if (error instanceof McpError) {
          throw error;
        }
        throw new McpError(
          ErrorCode.InternalError,
          `Error parsing search tokens: ${(error as Error).message}`
        );
      }
    }
  • ShodanClient helper method that performs the actual API call to Shodan's parse tokens endpoint (/shodan/host/search/tokens). Returns the parsed tokens or throws MCPError on failure.
    async parseSearchTokens(query: string): Promise<any> {
      try {
        const response = await this.axiosInstance.get("/shodan/host/search/tokens", {
          params: { query }
        });
        return response.data;
      } catch (error: unknown) {
        if (axios.isAxiosError(error)) {
          throw new McpError(
            ErrorCode.InternalError,
            `Shodan API error: ${error.response?.data?.error || error.message}`
          );
        }
        throw error;
      }
    }
  • src/index.ts:1042-1054 (registration)
    Tool registration entry in the ListToolsRequestSchema handler. Defines the tool name, description, and input schema for clients to discover and use the tool.
      name: "parse_search_tokens",
      description: "Parse a search query to understand which filters and parameters are being used",
      inputSchema: {
        type: "object",
        properties: {
          query: {
            type: "string",
            description: "Shodan search query to parse and analyze"
          }
        },
        required: ["query"]
      }
    },
  • Input schema definition for the parse_search_tokens tool, specifying the required 'query' string parameter.
      type: "object",
      properties: {
        query: {
          type: "string",
          description: "Shodan search query to parse and analyze"
        }
      },
      required: ["query"]
    }
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 states the tool parses a query to understand filters and parameters, implying a read-only analysis, but doesn't detail output format, error handling, rate limits, or authentication needs. For a 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, clear sentence: 'Parse a search query to understand which filters and parameters are being used.' It is front-loaded with the core action and resource, with no wasted words, making it highly efficient and easy to understand.

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 lack of annotations and output schema, the description is incomplete. It doesn't explain what the parsed results look like, how filters are identified, or any behavioral traits. For a parsing tool that likely returns structured data, more context is needed to guide an AI agent effectively.

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 one parameter 'query' documented as 'Shodan search query to parse and analyze.' The description adds minimal value beyond this, as it doesn't provide additional context like query syntax examples or parsing specifics. Given the high schema coverage, a baseline score of 3 is appropriate.

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's purpose: 'Parse a search query to understand which filters and parameters are being used.' It specifies the verb 'parse' and the resource 'search query,' making the action explicit. However, it doesn't differentiate from sibling tools like 'list_search_facets' or 'list_search_filters,' which might offer related functionality, so it doesn't reach the highest score.

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 provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites, context, or exclusions, such as how it differs from 'list_search_filters' or when parsing is needed over direct search tools like 'search_shodan.' This lack of explicit usage instructions limits its effectiveness for an AI agent.

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