UNPKG

@burtthecoder/mcp-shodan

Version:

A Model Context Protocol server for Shodan API queries.

64 lines (63 loc) 2.92 kB
import { z } from "zod"; import { queryCVEDB, getCvssSeverity } from "../helpers.js"; export function registerCveLookup(server) { server.addTool({ name: "cve_lookup", description: "Query detailed vulnerability information from Shodan's CVEDB. Returns comprehensive CVE details including CVSS scores (v2/v3), EPSS probability and ranking, KEV status, proposed mitigations, ransomware associations, and affected products (CPEs).", parameters: z.object({ cve: z .string() .regex(/^CVE-\d{4}-\d{4,}$/i, "Must be a valid CVE ID format (e.g., CVE-2021-44228)") .describe("The CVE identifier to query (format: CVE-YYYY-NNNNN)."), }), annotations: { readOnlyHint: true, openWorldHint: true, }, execute: async (args) => { const cveId = args.cve.toUpperCase(); const result = await queryCVEDB(cveId); const formattedResult = { "Basic Information": { "CVE ID": result.cve_id, Published: new Date(result.published_time).toLocaleString(), Summary: result.summary, }, "Severity Scores": { "CVSS v3": result.cvss_v3 ? { Score: result.cvss_v3, Severity: getCvssSeverity(result.cvss_v3), } : "Not available", "CVSS v2": result.cvss_v2 ? { Score: result.cvss_v2, Severity: getCvssSeverity(result.cvss_v2), } : "Not available", EPSS: result.epss ? { Score: `${(result.epss * 100).toFixed(2)}%`, Ranking: `Top ${(result.ranking_epss * 100).toFixed(2)}%`, } : "Not available", }, "Impact Assessment": { "Known Exploited Vulnerability": result.kev ? "Yes" : "No", "Proposed Action": result.propose_action || "No specific action proposed", "Ransomware Campaign": result.ransomware_campaign || "No known ransomware campaigns", }, "Affected Products": result.cpes?.length > 0 ? result.cpes : ["No specific products listed"], "Additional Information": { References: result.references?.length > 0 ? result.references : ["No references provided"], }, }; return JSON.stringify(formattedResult, null, 2); }, }); }