Skip to main content
Glama
googleSandy

Google Threat Intelligence MCP Server

by googleSandy

get_file_report

Analyze file security by submitting its hash to receive threat detection statistics, classification, and key indicators from Google's intelligence database.

Instructions

Get a comprehensive file analysis report using its hash (MD5/SHA-1/SHA-256).

Returns a concise summary of key threat details including detection stats, threat classification, and important indicators. Parameters: hash (required): The MD5, SHA-1, or SHA-256 hash of the file to analyze. Example: '8ab2cf...', 'e4d909c290d0...', etc.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
hashYes
api_keyNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The main handler function for get_file_report tool. It takes a file hash (MD5/SHA-1/SHA-256), creates a VirusTotal client context, fetches the file report with specific relationships using the fetch_object helper, and returns a sanitized response with the file analysis data.
    @server.tool()
    async def get_file_report(hash: str, ctx: Context, api_key: str = None) -> typing.Dict[str, typing.Any]:
      """Get a comprehensive file analysis report using its hash (MD5/SHA-1/SHA-256).
    
      Returns a concise summary of key threat details including
      detection stats, threat classification, and important indicators.
      Parameters:
        hash (required): The MD5, SHA-1, or SHA-256 hash of the file to analyze.
      Example: '8ab2cf...', 'e4d909c290d0...', etc.
      """
      async with vt_client(ctx, api_key=api_key) as client:
        res = await utils.fetch_object(
            client,
            "files",
            "file",
            hash,
            relationships=FILE_KEY_RELATIONSHIPS,
            params={"exclude_attributes": "last_analysis_results"}
        )
      return utils.sanitize_response(res)
  • The fetch_object helper function used by get_file_report to retrieve data from the Google Threat Intelligence API. It handles API errors, builds the request with specified attributes and relationships, and processes the response by removing aggregations from attributes.
    async def fetch_object(
        vt_client: vt.Client,
        resource_collection_type: str,
        resource_type: str,
        resource_id: str,
        attributes: list[str] | None = None,
        relationships: list[str] | None = None,
        params: dict[str, typing.Any] | None = None):
      """Fetches objects from Google Threat Intelligence API."""
      logging.info(
          f"Fetching comprehensive {resource_collection_type} "
          f"report for id: {resource_id}")
      
      params = {k: v for k, v in params.items()} if params else {}
    
      # Retrieve a selection of object attributes and/or relationships.
      if attributes:
        params["attributes"] = ",".join(attributes)
      if relationships:
        params["relationships"] = ",".join(relationships)
    
      try:
        obj = await vt_client.get_object_async(
            f"/{resource_collection_type}/{resource_id}", params=params)
    
        if obj.error:
          logging.error(
              f"Error fetching main {resource_type} report for {resource_id}: {obj.error}"
          )
          return {
              "error": f"Failed to get main {resource_type} report: {obj.error}",
              # "details": report.get("details"),
          }
      except vt.error.APIError as e:
        logging.warning(
            f"VirusTotal API Error fetching {resource_type} {resource_id}: {e.code} - {e.message}"
        )
        return {
            "error": f"VirusTotal API Error: {e.code} - {e.message}",
            "details": f"The requested {resource_type} '{resource_id}' could not be found or there was an issue with the API request."
        }
      except Exception as e:
        logging.exception(
            f"Unexpected error fetching {resource_type} {resource_id}: {e}"
        )
        return {"error": "An unexpected internal error occurred."}
    
      # Build response.
      obj_dict = obj.to_dict()
      obj_dict['id'] = obj.id
      if 'aggregations' in obj_dict['attributes']:
        del obj_dict['attributes']['aggregations']
    
      logging.info(
          f"Successfully generated concise threat summary for id: {resource_id}")
      return obj_dict
  • The sanitize_response helper function that recursively removes empty dictionaries, empty lists, and empty strings from API responses to clean up the output returned to the user.
    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 FILE_KEY_RELATIONSHIPS constant defines the list of relationships to fetch when calling get_file_report. These relationships include contacted domains, IPs, URLs, dropped files, embedded entities, and associations that provide comprehensive file analysis context.
    FILE_KEY_RELATIONSHIPS = [
        "contacted_domains",
        "contacted_ips",
        "contacted_urls",
        "dropped_files",
        "embedded_domains",
        "embedded_ips",
        "embedded_urls",
        "associations",
    ]
  • The @server.tool() decorator registers the get_file_report function as an MCP tool with the FastMCP server, making it available for client invocation.
    @server.tool()
Behavior3/5

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

With no annotations provided, the description carries the full burden. It discloses the tool returns a 'concise summary' with specific threat details (detection stats, classification, indicators), which adds behavioral context beyond the input schema. However, it does not cover aspects like rate limits, authentication needs (though 'api_key' parameter hints at this), or error handling.

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, followed by details on returns and parameters. Every sentence adds value, though the parameter section could be more integrated. It avoids redundancy and is structured for clarity.

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

Completeness4/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 annotations, but with an output schema), the description is fairly complete. It explains the purpose, return content, and key parameter semantics. The output schema likely covers return values, so the description need not detail them further, but it could improve by addressing the 'api_key' parameter or usage guidelines.

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%, so the description must compensate. It adds meaning for the 'hash' parameter by specifying acceptable formats (MD5/SHA-1/SHA-256) and providing examples, which clarifies semantics beyond the schema's basic string type. The 'api_key' parameter is not mentioned in the description, leaving a gap, but the primary required parameter is well-documented.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/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 with specific verbs ('Get a comprehensive file analysis report') and resources ('using its hash'), and distinguishes it from siblings like 'get_file_behavior_report' or 'analyse_file' by specifying it returns a concise summary of threat details rather than behavioral analysis or raw analysis.

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

Usage Guidelines3/5

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

The description implies usage for file threat analysis via hash, but does not explicitly state when to use this tool versus alternatives like 'analyse_file' or 'get_file_behavior_report'. It provides basic context (hash-based analysis) but lacks exclusions or clear differentiation from sibling tools.

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