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
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | Shodan search query to parse and analyze |
Implementation Reference
- src/index.ts:1586-1612 (handler)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}` ); } }
- src/index.ts:1044-1053 (schema)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"] } },
- src/index.ts:400-415 (helper)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; } }