Skip to main content
Glama
firetix

MCP Vulnerability Checker Server

by firetix

search_vulnerabilities

Search vulnerability databases with advanced filtering by keywords, severity levels, and date ranges to identify security threats and analyze vulnerability landscapes.

Instructions

Search vulnerability databases with advanced filtering

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
keywordsNoSearch vulnerability databases with advanced filtering capabilities to find relevant security threats. Filter by keywords (e.g., 'apache', 'sql injection'), severity levels (CRITICAL, HIGH, MEDIUM, LOW), and date ranges (30d, 90d, 1y, 2y). Enables comprehensive threat research and vulnerability landscape analysis across multiple CVE and vulnerability databases.
severityNoFilter by severity level: CRITICAL, HIGH, MEDIUM, LOW, NONE
date_rangeNoDate range filter. Use predefined ranges (30d, 90d, 1y, 2y) or custom format YYYY-MM-DD,YYYY-MM-DD

Implementation Reference

  • The main handler function that executes the tool logic: searches NVD vulnerability database with optional filters for keywords, severity, and date range, returns formatted results or errors.
    async def search_vulnerabilities(
        keywords: Optional[str] = None,
        severity: Optional[str] = None,
        date_range: Optional[str] = None,
    ) -> List[types.TextContent | types.ImageContent | types.EmbeddedResource]:
        """
        Search vulnerability databases with advanced filtering.
    
        Args:
            keywords: Keywords to search for in CVE descriptions (optional)
            severity: Filter by severity level: CRITICAL, HIGH, MEDIUM, LOW, NONE (optional)
            date_range: Date range filter in format "YYYY-MM-DD,YYYY-MM-DD" or predefined ranges like "30d", "90d" (optional)
                       Note: NVD API has a 120-day maximum limit for date ranges
    
        Returns:
            List of content containing search results or error messages
        """
        # Validate and parse inputs
        parsed_params = {}
    
        # Parse date range
        if date_range:
            try:
                if date_range.lower() in ["30d", "90d", "1y", "2y"]:
                    # Predefined ranges
                    days_map = {"30d": 30, "90d": 90, "1y": 365, "2y": 730}
                    days = days_map[date_range.lower()]
    
                    # NVD API has a 120-day maximum limit for date ranges
                    if days > 120:
                        return [
                            types.TextContent(
                                type="text",
                                text=f"Error: Date range '{date_range}' ({days} days) exceeds the NVD API limit of 120 days. Please use '30d', '90d', or a custom range within 120 days.",
                            )
                        ]
    
                    end_date = datetime.now()
                    start_date = end_date - timedelta(days=days)
    
                    parsed_params["pubStartDate"] = start_date.strftime(
                        "%Y-%m-%dT00:00:00.000"
                    )
                    parsed_params["pubEndDate"] = end_date.strftime("%Y-%m-%dT23:59:59.999")
                elif "," in date_range:
                    # Custom range: YYYY-MM-DD,YYYY-MM-DD
                    start_str, end_str = date_range.split(",", 1)
                    start_date = datetime.strptime(start_str.strip(), "%Y-%m-%d")
                    end_date = datetime.strptime(end_str.strip(), "%Y-%m-%d")
    
                    # Check if custom range exceeds 120-day limit
                    days_diff = (end_date - start_date).days
                    if days_diff > 120:
                        return [
                            types.TextContent(
                                type="text",
                                text=f"Error: Custom date range ({days_diff} days) exceeds the NVD API limit of 120 days. Please use a shorter range.",
                            )
                        ]
    
                    parsed_params["pubStartDate"] = start_date.strftime(
                        "%Y-%m-%dT00:00:00.000"
                    )
                    parsed_params["pubEndDate"] = end_date.strftime("%Y-%m-%dT23:59:59.999")
                else:
                    return [
                        types.TextContent(
                            type="text",
                            text="Error: Invalid date_range format. Use 'YYYY-MM-DD,YYYY-MM-DD' or predefined ranges: 30d, 90d, 1y, 2y",
                        )
                    ]
            except ValueError as e:
                return [
                    types.TextContent(
                        type="text",
                        text=f"Error: Invalid date format. Use YYYY-MM-DD. Details: {str(e)}",
                    )
                ]
    
        # Parse severity filter
        if severity:
            severity = severity.upper()
            valid_severities = ["CRITICAL", "HIGH", "MEDIUM", "LOW", "NONE"]
            if severity not in valid_severities:
                return [
                    types.TextContent(
                        type="text",
                        text=f"Error: Invalid severity '{severity}'. Valid options: {', '.join(valid_severities)}",
                    )
                ]
    
            # Map severity to CVSS score ranges for NVD API
            if severity == "CRITICAL":
                parsed_params["cvssV3Severity"] = "CRITICAL"
            elif severity == "HIGH":
                parsed_params["cvssV3Severity"] = "HIGH"
            elif severity == "MEDIUM":
                parsed_params["cvssV3Severity"] = "MEDIUM"
            elif severity == "LOW":
                parsed_params["cvssV3Severity"] = "LOW"
    
        # Add keywords if provided
        if keywords:
            parsed_params["keywordSearch"] = keywords.strip()
    
        # Set result limit
        parsed_params["resultsPerPage"] = "20"  # Reasonable limit for display
        parsed_params["startIndex"] = "0"
    
        headers = {
            "User-Agent": "MCP Vulnerability Search Tool v1.0",
            "Accept": "application/json",
        }
    
        try:
            timeout = httpx.Timeout(30.0, connect=15.0)  # Longer timeout for search
            async with httpx.AsyncClient(
                follow_redirects=True, headers=headers, timeout=timeout
            ) as client:
                # NVD API 2.0 endpoint for CVE search
                url = "https://services.nvd.nist.gov/rest/json/cves/2.0"
                response = await client.get(url, params=parsed_params)
                response.raise_for_status()
    
                data = response.json()
    
                total_results = data.get("totalResults", 0)
                vulnerabilities = data.get("vulnerabilities", [])
                results_per_page = data.get("resultsPerPage", 20)
    
                if total_results == 0:
                    search_desc = []
                    if keywords:
                        search_desc.append(f"keywords: '{keywords}'")
                    if severity:
                        search_desc.append(f"severity: {severity}")
                    if date_range:
                        search_desc.append(f"date range: {date_range}")
    
                    search_text = " with " + ", ".join(search_desc) if search_desc else ""
                    return [
                        types.TextContent(
                            type="text",
                            text=f"No vulnerabilities found{search_text}.",
                        )
                    ]
    
                # Format the response
                result = "šŸ” **Vulnerability Search Results**\n\n"
                result += "šŸ“Š **Search Summary:**\n"
                result += f"   • Total Results: {total_results:,}\n"
                result += (
                    f"   • Showing: {min(results_per_page, len(vulnerabilities))} results\n"
                )
    
                if keywords:
                    result += f"   • Keywords: '{keywords}'\n"
                if severity:
                    result += f"   • Severity Filter: {severity}\n"
                if date_range:
                    result += f"   • Date Range: {date_range}\n"
    
                result += "\nšŸ“‹ **Vulnerabilities Found:**\n\n"
    
                for i, vuln_data in enumerate(vulnerabilities[:20], 1):  # Limit display
                    cve = vuln_data.get("cve", {})
                    cve_id = cve.get("id", "Unknown")
                    published = cve.get("published", "Unknown")
                    cve.get("lastModified", "Unknown")
    
                    # Get description
                    descriptions = cve.get("descriptions", [])
                    description = "No description available"
                    for desc in descriptions:
                        if desc.get("lang") == "en":
                            description = desc.get("value", "")[
                                :200
                            ]  # Truncate long descriptions
                            if len(desc.get("value", "")) > 200:
                                description += "..."
                            break
    
                    # Get CVSS scores
                    metrics = cve.get("metrics", {})
                    cvss_info = "Not available"
                    severity_emoji = "⚪"
    
                    # Try CVSS 3.1 first, then 3.0, then 2.0
                    for version in [
                        "cvssMetricV31",
                        "cvssMetricV30",
                        "cvssMetricV2",
                    ]:
                        if version in metrics and metrics[version]:
                            metric = metrics[version][0]  # Take first metric
                            cvss_data = metric.get("cvssData", {})
                            score = cvss_data.get("baseScore", "N/A")
                            sev = cvss_data.get("baseSeverity", "N/A")
    
                            if score != "N/A":
                                cvss_info = f"{score} ({sev})"
                                # Set emoji based on severity
                                if sev == "CRITICAL":
                                    severity_emoji = "šŸ”“"
                                elif sev == "HIGH":
                                    severity_emoji = "🟠"
                                elif sev == "MEDIUM":
                                    severity_emoji = "🟔"
                                elif sev == "LOW":
                                    severity_emoji = "🟢"
                                break
    
                    # Format published date
                    try:
                        pub_date = datetime.fromisoformat(published.replace("Z", "+00:00"))
                        pub_formatted = pub_date.strftime("%Y-%m-%d")
                    except (ValueError, TypeError, AttributeError):
                        pub_formatted = (
                            published[:10] if len(published) >= 10 else published
                        )
    
                    result += f"**{i}. {severity_emoji} {cve_id}**\n"
                    result += f"   šŸ“… Published: {pub_formatted}\n"
                    result += f"   āš ļø CVSS: {cvss_info}\n"
                    result += f"   šŸ“ Description: {description}\n"
                    result += f"   šŸ”— Details: https://cve.mitre.org/cgi-bin/cvename.cgi?name={cve_id}\n\n"
    
                if total_results > results_per_page:
                    result += f"šŸ“„ **Note:** Showing first {results_per_page} of {total_results:,} total results.\n"
                    result += "šŸ’” **Tip:** Use more specific keywords or severity filters to narrow results.\n\n"
    
                result += "šŸ“Š **Data Source:** National Vulnerability Database (NVD)\n"
                result += f"šŸ• **Search performed:** {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}"
    
                return [types.TextContent(type="text", text=result)]
    
        except httpx.TimeoutException:
            return [
                types.TextContent(
                    type="text",
                    text="Error: Request timed out while searching vulnerability database. Try using more specific search criteria.",
                )
            ]
        except httpx.HTTPStatusError as e:
            if e.response.status_code == 403:
                return [
                    types.TextContent(
                        type="text",
                        text="Error: Access forbidden. The NVD API may be rate limiting requests. Please try again later.",
                    )
                ]
            elif e.response.status_code == 503:
                return [
                    types.TextContent(
                        type="text",
                        text="Error: NVD service temporarily unavailable. Please try again later.",
                    )
                ]
            return [
                types.TextContent(
                    type="text",
                    text=f"Error: HTTP {e.response.status_code} error while searching vulnerabilities.",
                )
            ]
        except json.JSONDecodeError:
            return [
                types.TextContent(
                    type="text", text="Error: Invalid JSON response from NVD API."
                )
            ]
        except Exception as e:
            return [
                types.TextContent(
                    type="text",
                    text=f"Error: Failed to search vulnerabilities: {str(e)}",
                )
            ]
  • Registers the search_vulnerabilities tool in the MCP server with name, description, and input schema definition.
    types.Tool(
        name="search_vulnerabilities",
        description="Search vulnerability databases with advanced filtering",
        inputSchema={
            "type": "object",
            "properties": {
                "keywords": {
                    "type": "string",
                    "description": vuln_search_description,
                },
                "severity": {
                    "type": "string",
                    "description": "Filter by severity level: CRITICAL, HIGH, MEDIUM, LOW, NONE",
                },
                "date_range": {
                    "type": "string",
                    "description": "Date range filter. Use predefined ranges (30d, 90d, 1y, 2y) or custom format YYYY-MM-DD,YYYY-MM-DD",
                },
            },
        },
    ),
  • Dispatches calls to the search_vulnerabilities handler function based on tool name in the server's fetch_tool method.
    elif name == "search_vulnerabilities":
        # All parameters are optional for search
        keywords = arguments.get("keywords")
        severity = arguments.get("severity")
        date_range = arguments.get("date_range")
        return await search_vulnerabilities(keywords, severity, date_range)
  • Defines the detailed description string used in the tool's schema.
    vuln_search_description: str = (
        "Search vulnerability databases with advanced filtering capabilities to find "
        "relevant security threats. Filter by keywords (e.g., 'apache', 'sql injection'), "
        "severity levels (CRITICAL, HIGH, MEDIUM, LOW), and date ranges (30d, 90d, 1y, 2y). "
        "Enables comprehensive threat research and vulnerability landscape analysis across "
        "multiple CVE and vulnerability databases."
    )
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 'advanced filtering' and 'comprehensive threat research,' but lacks critical details such as whether this is a read-only operation, if it requires authentication, rate limits, pagination behavior, or what databases it searches. This leaves significant gaps for safe and effective tool invocation.

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 that directly states the tool's purpose without unnecessary words. It's front-loaded with the core action ('Search vulnerability databases') and qualifies it succinctly ('with advanced filtering'), making it easy to parse and understand quickly.

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 vulnerability searching, no annotations, and no output schema, the description is incomplete. It doesn't address key aspects like the scope of databases searched, result format, error handling, or performance considerations, which are essential for an agent to use this tool effectively in security contexts.

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 input schema already documents all three parameters thoroughly. The description adds no additional parameter semantics beyond what's in the schema, such as explaining interactions between filters or default behaviors. This meets the baseline for high schema coverage but doesn't enhance understanding.

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 as 'Search vulnerability databases with advanced filtering,' which is a specific verb+resource combination. However, it doesn't explicitly distinguish this tool from its siblings like 'cve_lookup' or 'package_vulnerability_check,' which likely perform similar vulnerability-related searches with different scopes or methods.

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 its siblings. It mentions 'advanced filtering' but doesn't specify scenarios where this is preferred over alternatives like 'cve_lookup' for direct CVE lookups or 'package_vulnerability_check' for package-specific checks, leaving the agent to guess based on context.

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/firetix/vulnerability-intelligence-mcp-server'

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