Skip to main content
Glama
a2amarket

ClamAV MCP

by a2amarket

scan_file

Scan files for viruses using the ClamAV engine by providing base64-encoded data and filename to detect malware and security threats.

Instructions

Scan a base64-encoded file using ClamAV.

Args:
    base64_data (str): Base64 encoded string representing a file
    filename (str): Name of the file to use in the scan
    
Returns:
    dict: Scan results including the raw clamscan output

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
base64_dataYes
filenameYes

Implementation Reference

  • main.py:15-63 (handler)
    The implementation of the 'scan_file' tool. This is the handler function decorated with @mcp.tool() for registration. It handles base64-encoded file input, decodes it to a temporary file, scans it using ClamAV's clamscan, and returns the scan results or error information.
    @mcp.tool()
    def scan_file(base64_data: str, filename: str) -> dict:
        """
        Scan a base64-encoded file using ClamAV.
        
        Args:
            base64_data (str): Base64 encoded string representing a file
            filename (str): Name of the file to use in the scan
            
        Returns:
            dict: Scan results including the raw clamscan output
        """
        logger.info(f"Received scan request for file: {filename}")
        temp_file_path = None
        try:
            # Decode the base64 string
            file_content = base64.b64decode(base64_data)
            
            # Create a temporary file to store the decoded content
            with tempfile.NamedTemporaryFile(delete=False, mode='wb', suffix=f"_{filename}") as temp_file:
                temp_file.write(file_content)
                temp_file_path = temp_file.name
                
            # Set permissions to allow ClamAV to read the file
            os.chmod(temp_file_path, 0o644)
            logger.info(f"Created temporary file: {temp_file_path}")
                
            # Run clamscan command
            result = subprocess.run(['clamscan', temp_file_path], 
                                  capture_output=True, 
                                  text=True)
            
            logger.info("Scan completed successfully")
            return {
                "success": True,
                "result": result.stdout + result.stderr
            }
            
        except Exception as e:
            logger.error(f"Error during scan: {str(e)}")
            return {
                "success": False,
                "error": str(e)
            }
        finally:
            # Clean up the temporary file
            if temp_file_path and os.path.exists(temp_file_path):
                os.unlink(temp_file_path)
                logger.info(f"Cleaned up temporary file: {temp_file_path}")
  • main.py:15-15 (registration)
    The @mcp.tool() decorator registers the scan_file function as an MCP tool.
    @mcp.tool()
  • main.py:16-26 (schema)
    Input schema defined by type hints (base64_data: str, filename: str) and output as dict, with detailed docstring.
    def scan_file(base64_data: str, filename: str) -> dict:
        """
        Scan a base64-encoded file using ClamAV.
        
        Args:
            base64_data (str): Base64 encoded string representing a file
            filename (str): Name of the file to use in the scan
            
        Returns:
            dict: Scan results including the raw clamscan output
        """
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 of behavioral disclosure. It mentions the tool 'Scan[s]' and returns 'Scan results,' implying a read-only operation, but lacks details on permissions, rate limits, error handling, or what 'raw clamscan output' entails. This leaves significant gaps in understanding the tool's 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 appropriately sized and front-loaded, with the core purpose stated first, followed by parameter and return value sections. Each sentence adds value, though the structure could be slightly more streamlined by integrating parameter details more seamlessly.

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 the tool's moderate complexity (2 parameters, no output schema, no annotations), the description is minimally adequate. It covers the purpose and parameters but lacks details on behavioral traits, error cases, or output structure, leaving room for improvement in completeness.

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 0%, so the description must compensate. It adds meaning by explaining that 'base64_data' is a 'Base64 encoded string representing a file' and 'filename' is the 'Name of the file to use in the scan,' which clarifies parameter roles beyond the schema's basic titles. However, it doesn't cover format specifics or constraints, resulting in a baseline score.

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: 'Scan a base64-encoded file using ClamAV.' It specifies the verb ('Scan'), resource ('base64-encoded file'), and technology ('ClamAV'). 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 no guidance on when to use this tool versus alternatives, prerequisites, or exclusions. It only states what the tool does without context for its application, leaving the agent with minimal usage direction.

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/a2amarket/mcp-clamav'

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