Skip to main content
Glama
gkhays
by gkhays

scan

Generate SPDX SBOM for container images using Trivy scanner to identify software components and dependencies in SPDX JSON format.

Instructions

Execute Trivy scanner to generate SPDX SBOM for a container image.
Supports the SPDX JSON format.

Args:
    image (str): The container image name/reference to scan

Returns:
    str: Test response or error message

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
imageYes

Implementation Reference

  • The 'scan' tool handler, decorated with @mcp.tool() for registration in FastMCP, executes the Trivy scan via exec_trivy helper and returns the SBOM JSON or error.
    async def scan(image: str):
        """
        Execute Trivy scanner to generate SPDX SBOM for a container image.
        Supports the SPDX JSON format.
    
        Args:
            image (str): The container image name/reference to scan
    
        Returns:
            str: Test response or error message
        """
        try:
            logger.info(f"MCP SBOM tool called with image: {image}")
            result = await exec_trivy(image)
            logger.debug(f"Trivy execution result: {result}")
            return result
        except Exception as e:
            logger.error(f"Exception in trivy tool: {str(e)}")
            return f"Error: {str(e)}"
  • Helper function that asynchronously executes the Trivy command to scan the container image and load the resulting SBOM JSON.
    async def exec_trivy(image: str):
        try:
            logger.info(f"Starting Trivy scan for image: {image}")
            cmd = [
                "trivy", "image", 
                "--format", "cyclonedx", 
                "--output", "sbom.json", 
                image
                ]
            # result = subprocess.run(cmd, capture_output=True, text=True)
            process = await asyncio.create_subprocess_exec(
                *cmd, 
                stdout=asyncio.subprocess.PIPE, 
                stderr=asyncio.subprocess.PIPE
                )
            stdout, stderr = await process.communicate()
            logger.info(f"Trivy scan completed with return code {process.returncode}")
            
            if process.returncode == 0:
                with open("sbom.json", "r") as f:
                    sbom_content = json.load(f)
            return sbom_content
        except Exception as e:
            logger.error(f"Exception in exec_trivy: {str(e)}")
            return f"Error: {str(e)}"
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 the tool 'Supports the SPDX JSON format' and returns a 'Test response or error message,' but lacks critical details such as execution time, network dependencies, authentication needs, rate limits, or error handling. This leaves significant gaps in understanding the tool's operational behavior.

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 and concise, with three sentences that efficiently cover purpose, format support, parameters, and returns. Each sentence adds value without redundancy. Minor improvements could include bullet points or clearer separation, but overall it is appropriately sized and front-loaded.

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 tool's complexity (scanning container images) and lack of annotations or output schema, the description is incomplete. It fails to explain key aspects like what an SPDX SBOM entails, how results are structured, potential side effects (e.g., network calls), or error scenarios. The return statement 'Test response or error message' is vague and unhelpful for an agent.

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?

The schema description coverage is 0%, so the description must compensate. It includes an 'Args' section that documents the single parameter 'image' as 'The container image name/reference to scan,' adding meaningful context beyond the bare schema. However, it does not elaborate on format specifics (e.g., Docker tags, registry URLs) or constraints, limiting its utility.

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: 'Execute Trivy scanner to generate SPDX SBOM for a container image.' It specifies the verb ('execute'), resource ('Trivy scanner'), and output format ('SPDX SBOM'). However, with no sibling tools mentioned, it cannot demonstrate differentiation from alternatives, preventing 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 Guidelines2/5

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

The description provides minimal usage guidance, only stating that it 'Supports the SPDX JSON format.' It does not specify when to use this tool versus other scanning methods, prerequisites, or exclusions. Without explicit context or alternatives, the guidance is insufficient for informed tool selection.

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

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