analyse_file
Upload a file to VirusTotal for community-shared analysis and receive a detailed threat report.
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
| Name | Required | Description | Default |
|---|---|---|---|
| file_path | Yes | ||
| api_key | No |
Implementation Reference
- gti_mcp/tools/files.py:251-269 (handler)The analyse_file tool handler function. It uploads a file to VirusTotal, waits for analysis completion, and returns the sanitized 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()) - gti_mcp/tools/files.py:251-252 (registration)The @server.tool() decorator registers this function as an MCP tool named 'analyse_file'. The server is defined in gti_mcp/server.py as a FastMCP instance.
@server.tool() async def analyse_file(file_path: str, ctx: Context, api_key: str = None): - gti_mcp/server.py:56-64 (helper)The vt_client async context manager used by analyse_file to obtain a vt.Client instance for VirusTotal API calls.
@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() - gti_mcp/server.py:66-74 (registration)The FastMCP server instance and the import that loads all tools including analyse_file from gti_mcp/tools.
# Create a named server and specify dependencies for deployment and development server = FastMCP( "Google Threat Intelligence MCP server", dependencies=["vt-py"], stateless_http=stateless) # Load tools. from gti_mcp.tools import *