Skip to main content
Glama

security_trivy_scan

Scan container images for security vulnerabilities using Trivy to identify and filter by severity levels like HIGH and CRITICAL.

Instructions

Scan a container image for vulnerabilities using Trivy

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
imageYesContainer image to scan (e.g., 'nginx:latest')
severityNoSeverity filter (default: 'HIGH,CRITICAL')

Implementation Reference

  • The main handler function `trivyScanImage` which executes the Trivy scan command and formats the output.
    export async function trivyScanImage(args: Record<string, unknown>): Promise<string> {
      const image = args.image as string;
      if (!image) throw new Error("Image name is required");
      const severity = (args.severity as string) || "HIGH,CRITICAL";
    
      try {
        const { stdout } = await execFileAsync(
          "trivy",
          ["image", "--format", "json", "--severity", severity, image],
          { timeout: 120000 }
        );
    
        const report = JSON.parse(stdout);
        const results = report.Results || [];
        const lines: string[] = [`Trivy scan results for '${image}':`];
    
        let totalVulns = 0;
        for (const result of results) {
          const vulns = result.Vulnerabilities || [];
          totalVulns += vulns.length;
    
          if (vulns.length === 0) continue;
    
          lines.push(`\nTarget: ${result.Target} (${result.Type})`);
          const headers = ["ID", "SEVERITY", "PACKAGE", "VERSION", "FIXED IN", "TITLE"];
          const rows = vulns.slice(0, 20).map((v: any) => [
            v.VulnerabilityID || "",
            v.Severity || "",
            v.PkgName || "",
            v.InstalledVersion || "",
            v.FixedVersion || "N/A",
            (v.Title || "").substring(0, 40),
          ]);
          lines.push(formatTable(headers, rows));
    
          if (vulns.length > 20) {
            lines.push(`  ... and ${vulns.length - 20} more vulnerabilities`);
          }
        }
    
        if (totalVulns === 0) {
          lines.push(`\nNo ${severity} vulnerabilities found.`);
        } else {
          lines.push(`\nTotal: ${totalVulns} vulnerabilities found.`);
        }
    
        return lines.join("\n");
      } catch (error: any) {
        if (error.code === "ENOENT") {
          throw new Error("Trivy is not installed. Install it from https://aquasecurity.github.io/trivy/");
        }
        throw new Error(`Trivy scan failed: ${error.stderr || error.message}`);
      }
    }
  • Tool registration definition for `security_trivy_scan` including name, description, and input schema.
    {
      name: "security_trivy_scan",
      description: "Scan a container image for vulnerabilities using Trivy",
      inputSchema: {
        type: "object" as const,
        properties: {
          image: { type: "string", description: "Container image to scan (e.g., 'nginx:latest')" },
          severity: { type: "string", description: "Severity filter (default: 'HIGH,CRITICAL')" },
        },
        required: ["image"],
      },
    },
  • The switch-case entry point that delegates the `security_trivy_scan` tool call to the handler function.
    switch (name) {
      case "security_trivy_scan": return trivyScanImage(a);
Behavior2/5

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

No annotations are provided, so the description carries full burden. It states the tool scans for vulnerabilities but doesn't disclose behavioral traits like what happens during scanning (e.g., network access, resource usage), output format, error conditions, or whether it's read-only or has side effects. This leaves significant gaps for a security scanning tool.

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 with zero waste. It's front-loaded with the core purpose and uses clear, direct language without unnecessary elaboration.

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 no annotations and no output schema, the description is incomplete for a security scanning tool. It lacks details on what the scan returns (e.g., vulnerability list, severity breakdown), how results are structured, or any behavioral context like execution time or dependencies. This makes it inadequate for informed tool selection.

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 schema already documents both parameters ('image' and 'severity') adequately. The description doesn't add any meaning beyond what the schema provides, such as examples of severity values beyond the default or scanning limitations. Baseline 3 is appropriate when schema does the heavy lifting.

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 action ('Scan') and resource ('container image') with the specific tool ('using Trivy'). It distinguishes from most siblings by focusing on vulnerability scanning rather than Docker/Kubernetes operations, though it doesn't explicitly differentiate from 'security_gitleaks_scan' and 'security_k8s_audit' which are also security tools.

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?

No guidance is provided about when to use this tool versus alternatives. The description doesn't mention when scanning is appropriate, prerequisites, or how it differs from other security tools like 'security_gitleaks_scan' or 'security_k8s_audit' on the same server.

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/batu-sonmez/infraclaude'

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