Skip to main content
Glama

query_package_cve

Check packages for security vulnerabilities by querying the OSV database to identify CVE IDs before installation or updates.

Instructions

Query the OSV database for a package and return the CVE ID.
You can use this tool to get the CVE ID for a package. 
ALWAYS use it before installing packages to check if the package is vulnerable. For example in requirements.txt, pyproject.toml, uv.lock, etc.
You can also use it to check if the package is vulnerable before updating the package.

Args:
    package: The package name to query
    version: The version of the package to query, can be None if you want to query all versions
    ecosystem: The ecosystem of the package to query, can be None if you want to query all ecosystems. 
    
    * For supported ecosystems, see the get_ecosystems tool.

Returns:
    A list of CVE IDs

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
packageYes
versionNo
ecosystemNoPyPI

Implementation Reference

  • Core handler function in OSVServer class that performs the API query to OSV.dev, parses vulnerabilities, extracts CVE IDs using regex, and returns list of CVEs with details and severity.
    def query_package_cve(self, package: str, ecosystem: str = "PyPI", version: str = None):
        """
        Query the OSV database for a package and return the CWE ID.
        """
        data = self._query_package(package, ecosystem, version)
        cves = []
        for vuln in data['vulns']:
            cve_id = re.search(r'CVE-(\d+)-(\d+)', str(vuln))
            if cve_id:
                cves.append({cve_id.group(0): {"details": vuln['details'], "severity": vuln['severity']}})
        return cves
  • src/server.py:117-136 (registration)
    MCP tool registration and wrapper handler using @mcp.tool(). Defines input schema via type annotations and docstring. Instantiates OSVServer and delegates to its core query_package_cve method.
    @mcp.tool()
    def query_package_cve(package: str, version: str = None, ecosystem: str = "PyPI"):
        """
        Query the OSV database for a package and return the CVE ID.
        You can use this tool to get the CVE ID for a package. 
        ALWAYS use it before installing packages to check if the package is vulnerable. For example in requirements.txt, pyproject.toml, uv.lock, etc.
        You can also use it to check if the package is vulnerable before updating the package.
    
        Args:
            package: The package name to query
            version: The version of the package to query, can be None if you want to query all versions
            ecosystem: The ecosystem of the package to query, can be None if you want to query all ecosystems. 
            
            * For supported ecosystems, see the get_ecosystems tool.
    
        Returns:
            A list of CVE IDs
        """
        osv = OSVServer()
        return osv.query_package_cve(package, ecosystem, version)
  • Private helper method that constructs the JSON payload and performs the POST request to the OSV API (https://api.osv.dev/v1/query) to fetch vulnerability data for the package.
    def _query_package(self, package: str, ecosystem: str, version: str = None):
        """
        Query the OSV database for a package.
        """
        data = {"package": {"name": package, "ecosystem": ecosystem}}
        if version:
            data['version'] = version
    
        response = requests.post(self.package_url, json=data)
        return response.json()
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden. It mentions the tool queries a database and returns CVE IDs, but lacks details on rate limits, error handling, authentication needs, or what happens if no CVE is found. For a security-related query tool with zero annotation coverage, this is a significant gap in behavioral disclosure.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is well-structured with a clear purpose statement, usage guidelines, and parameter explanations. It's front-loaded with key information and uses bullet points for parameters. Some redundancy exists (e.g., repeating 'query' in the first two sentences), but overall it's efficient and easy to scan.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no annotations, no output schema, and 3 parameters with 0% schema coverage, the description does a decent job by explaining parameters and usage. However, it lacks details on return format (e.g., structure of the list of CVE IDs), error cases, or performance considerations, leaving gaps for a tool with moderate complexity.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, but the description compensates well by explaining each parameter's purpose: 'package' is the name, 'version' can be None for all versions, and 'ecosystem' can be None for all ecosystems, with a reference to 'get_ecosystems' for supported options. It adds meaningful context beyond the bare schema, though it doesn't cover all possible edge cases.

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: 'Query the OSV database for a package and return the CVE ID.' It specifies the verb ('query'), resource ('OSV database'), and output ('CVE ID'), making it easy to understand. However, it doesn't explicitly differentiate from sibling tools like 'query_for_cve_affected' or 'query_for_cve_fix_versions', which prevents a perfect score.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides explicit usage guidance: 'ALWAYS use it before installing packages to check if the package is vulnerable' and gives examples (e.g., requirements.txt). It also mentions using it before updating packages and references the 'get_ecosystems' tool for ecosystem details, offering clear context and alternatives.

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/EdenYavin/OSV-MCP'

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