Skip to main content
Glama

nvd_tool

Retrieve CVE data from the National Vulnerability Database using its ID, enabling AI models to access current vulnerability information for analysis and risk assessment.

Instructions

Fetch CVE data from NVD

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
cve_idYesThe CVE ID to fetch data for.

Implementation Reference

  • The handler function for the 'nvd_tool' tool. It extracts the cve_id from arguments, instantiates NVD class, calls get_cve_list(), and returns the data as TextContent or None.
    @mcp.call_tool() async def nvd_tool(name: str, arguments: dict) -> Sequence[TextContent | ImageContent | EmbeddedResource]: """ Fetch CVE data from NVD using the provided arguments. Args: cve_id (str): The CVE ID to fetch data for. """ from mcp_nvd.nvd import NVD LOGGER.info(f"Fetching CVE data for {name} with arguments: {arguments}") cve_id = arguments.get("cve_id") nvd = NVD(cve_id=cve_id) cve_data = nvd.get_cve_list() if cve_data: # return cve_data return [TextContent(type="text", text=str(cve_data))] else: LOGGER.info(f"CVE {cve_id} not found in NVD database.") return None
  • Registration of the 'nvd_tool' via the list_tools() callback, which returns the Tool object with name, description, and inputSchema.
    @mcp.list_tools() async def list_tools() -> list[types.Tool]: LOGGER.debug("Listing tools...") tools = [ types.Tool( name="nvd_tool", description="Fetch CVE data from NVD", inputSchema={ "type": "object", "properties": { "cve_id": { "type": "string", "description": "The CVE ID to fetch data for." } }, "required": ["cve_id"] }, ) ] return tools
  • Input schema defining the required 'cve_id' string parameter for the nvd_tool.
    inputSchema={ "type": "object", "properties": { "cve_id": { "type": "string", "description": "The CVE ID to fetch data for." } }, "required": ["cve_id"] },
  • Helper method in NVD class that performs the actual HTTP request to NVD API to fetch CVE data based on cve_id.
    def get_cve_list(self) -> list: """ Retrieve a specific CVE by its ID. Args: cve_id (str): The CVE ID (e.g. CVE-2025-12345) Returns: dict: CVE item or None if not found """ params = { "cveId": self.cve_id, } LOGGER.info(f"Fetching CVE: {self.cve_id}...") try: response = requests.get(self.base_url, params=params) if response.status_code == 200: LOGGER.info(f"Response: {response.status_code}") data = response.json() vulnerabilities = data.get('vulnerabilities', []) if vulnerabilities: self.cve_json = vulnerabilities[0] self.description = self.get_description() LOGGER.info(f"Description: {self.description}") return vulnerabilities else: LOGGER.info(f"CVE {self.cve_id} not found in NVD database.") return None elif response.status_code == 403: print("Error: API rate limit exceeded. Please try again later.") return None elif response.status_code == 404: print("Error: API endpoint not found. Checking for diagnostic information...") print(f"Response: {response.text}") print("\nTrying alternative API endpoint...") else: print(f"Error: API returned status code {response.status_code}") print(f"Response: {response.text}") return None except Exception as e: print(f"Error: {e}") return None

Other Tools

Related 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/gkhays/mcp-nvd-server'

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