Skip to main content
Glama

parse_search_tokens

Analyze and extract filters or parameters from a Shodan search query to enhance cybersecurity research and threat intelligence.

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

  • The MCP tool handler implementation in the CallToolRequestSchema switch statement. It validates the query parameter and calls the ShodanClient.parseSearchTokens method to execute the tool logic.
    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}` ); } }
  • The input schema definition for the parse_search_tokens tool, specifying the required 'query' string parameter.
    inputSchema: { type: "object", properties: { query: { type: "string", description: "Shodan search query to parse and analyze" } }, required: ["query"] }
  • src/index.ts:1042-1054 (registration)
    Registration of the parse_search_tokens tool in the ListToolsRequestSchema response, including name, description, and input schema.
    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"] } },
  • The core helper method in ShodanClient that makes the API call to Shodan's /shodan/host/search/tokens endpoint to parse the search query into tokens.
    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; } }

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