Skip to main content
Glama
googleSandy

Google Threat Intelligence MCP Server

by googleSandy

analyse_file

Analyze files for security threats by uploading them to VirusTotal to detect malware and share findings with the security community.

Instructions

Upload and analyse the file in VirusTotal.

The file will be uploaded to VirusTotal and shared with the community.

Args: file_path (required): Path to the file for analysis. Use absolute path. Returns: The analysis report.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
file_pathYes
api_keyNo

Implementation Reference

  • The main handler function for the analyse_file tool. It's decorated with @server.tool() which registers it as an MCP tool. The function uploads a file to VirusTotal for analysis, waits for completion, and returns the analysis report.
    @server.tool()
    async def analyse_file(file_path: str, ctx: Context, api_key: str = None):
      """Upload and analyse the file in VirusTotal.
    
      The file will be uploaded to VirusTotal and shared with the community.
    
      Args:
        file_path (required): Path to the file for analysis. Use absolute path.
      Returns:
        The analysis report.
      """
      async with vt_client(ctx, api_key=api_key) as client:
        with open(file_path, "rb") as f:    
          analysis = await client.scan_file_async(file=f)
          logging.info(f"File {file_path} uploaded.")
    
        res = await client.wait_for_analysis_completion(analysis)
        logging.info(f"Analysis has completed with ID %s", res.id)
        return utils.sanitize_response(res.to_dict())
  • The vt_client async context manager that provides a VirusTotal client instance. It handles API key resolution and ensures proper cleanup of the client connection.
    @asynccontextmanager
    async def vt_client(ctx: Context, api_key: str = None) -> AsyncIterator[vt.Client]:
      """Provides a vt.Client instance for the current request."""
      client = vt_client_factory(ctx, api_key)
    
      try:
        yield client
      finally:
        await client.close_async()
  • The sanitize_response utility function used by analyse_file to remove empty dictionaries and lists recursively from the API response before returning it.
    def sanitize_response(data: typing.Any) -> typing.Any:
      """Removes empty dictionaries and lists recursively from a response."""
      if isinstance(data, dict):
        sanitized_dict = {}
        for key, value in data.items():
          sanitized_value = sanitize_response(value)
          if sanitized_value is not None:
            sanitized_dict[key] = sanitized_value
        return sanitized_dict
      elif isinstance(data, list):
        sanitized_list = []
        for item in data:
          sanitized_item = sanitize_response(item)
          if sanitized_item is not None:
            sanitized_list.append(sanitized_item)
        return sanitized_list
      elif isinstance(data, str):
        return data if data else None
      else:
        return data
  • The vt_client_factory function that creates VirusTotal client instances. It prioritizes the api_key argument over the VT_APIKEY environment variable.
    def _vt_client_factory(ctx: Context, api_key: str = None) -> vt.Client:
        # Prioritize the passed argument
        if not api_key:
            api_key = os.getenv("VT_APIKEY")
        
        # Try to get from context if not in env (placeholder for future ctx inspection)
        # if not api_key and ctx and hasattr(ctx, 'init_options'):
        #     api_key = ctx.init_options.get('vtApiKey')
        
        if not api_key:
            raise ValueError("VT API Key is required. Please provide it as an argument 'api_key' or set VT_APIKEY environment variable.")
        return vt.Client(api_key)
  • The FastMCP server instance creation. Tools are registered via the @server.tool() decorator, which is applied to analyse_file.
    server = FastMCP(
        "Google Threat Intelligence MCP server",
        dependencies=["vt-py"],
        stateless_http=stateless)
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It mentions the file will be 'shared with the community' which is important context, but doesn't cover critical aspects like rate limits, file size restrictions, privacy implications, authentication requirements, or what happens if the file already exists in VirusTotal.

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 with three sentences that each serve distinct purposes: stating the action, disclosing community sharing, and documenting parameters. The Args/Returns structure is clear though somewhat redundant with the schema.

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?

For a tool that uploads files to an external service with community sharing implications and no annotations or output schema, the description is insufficient. It lacks critical information about authentication, rate limits, privacy considerations, error conditions, and what the 'analysis report' contains or looks like.

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 documents the required 'file_path' parameter with guidance to 'Use absolute path', which adds value beyond the bare schema. However, it completely ignores the 'api_key' parameter, leaving it undocumented despite being part of the input schema.

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 ('Upload and analyse') and target resource ('the file in VirusTotal'), providing specific purpose. However, it doesn't explicitly differentiate from sibling tools like 'get_file_report' or 'get_file_behavior_report' which might retrieve existing analyses rather than upload new files.

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. With many sibling tools for file-related operations (get_file_report, get_file_behavior_report, get_file_behavior_summary), there's no indication of when upload/analysis is needed versus retrieving existing reports.

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/googleSandy/gti-mcp-standalone'

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