Skip to main content
Glama

file

Identifies file types and analyzes content using target input and optional command-line options for malware investigation within the MalwareAnalyzerMCP environment.

Instructions

Analyze a file and determine its type

Example usage:

  • Basic file identification: { "target": "suspicious.exe" }

  • With options: { "target": "suspicious.exe", "options": "-b" }

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
optionsNoAdditional command-line options
targetYesTarget file or data to analyze

Implementation Reference

  • Handler logic for executing the 'file' tool (shared with other specialized tools): validates input arguments using the tool's Zod schema, builds the shell command using the tool-specific buildCommand function, executes it via terminalManager.shellCommand, and returns the result or error.
    if (commands[name]) { try { const cmdConfig = commands[name]; // Validate arguments against schema const validationResult = cmdConfig.schema.safeParse(args); if (!validationResult.success) { return { content: [{ type: "text", text: `Error: Invalid parameters for ${name} command.\n${JSON.stringify(validationResult.error.format())}` }], isError: true, }; } // Build the command string const commandStr = cmdConfig.buildCommand(validationResult.data); console.error(`Executing specialized command: ${commandStr}`); // Execute the command via the terminal manager const result = await terminalManager.shellCommand(commandStr); console.error(`${name} command executed with PID: ${result.pid}, blocked: ${result.isBlocked}`); return { content: [{ type: "text", text: JSON.stringify(result) }], }; } catch (error) { console.error(`Error executing ${name} command:`, error); return { content: [{ type: "text", text: `Error: ${error instanceof Error ? error.message : String(error)}` }], isError: true, }; }
  • Configuration for the 'file' tool including input schema reference (baseCommandSchema), description, buildCommand to construct 'file [options] [target]' shell command, and usage examples.
    file: { name: 'file', description: 'Analyze a file and determine its type', schema: baseCommandSchema, buildCommand: (args) => { const options = args.options ? args.options : ''; return `file ${options} ${args.target}`; }, helpText: ` Example usage: - Basic file identification: { "target": "suspicious.exe" } - With options: { "target": "suspicious.exe", "options": "-b" } ` },
  • Base Zod schema for input validation of the 'file' tool: requires 'target' string (file path), optional 'options' string.
    const baseCommandSchema = z.object({ target: z.string().min(1).describe("Target file or data to analyze"), options: z.string().optional().describe("Additional command-line options") });
  • serverMCP.js:113-122 (registration)
    Registration of the 'file' tool (and other specialized tools) in the ListTools response: dynamically generates tool metadata from commands.js config including name, description, and JSON schema from Zod.
    const specializedTools = Object.values(commands).map(cmd => ({ name: cmd.name, description: cmd.description + (cmd.helpText ? '\n' + cmd.helpText : ''), inputSchema: zodToJsonSchema(cmd.schema), })); return { tools: [...basicTools, ...specializedTools], }; });
  • Helper function specific to 'file' tool that constructs the shell command string to execute.
    buildCommand: (args) => { const options = args.options ? args.options : ''; return `file ${options} ${args.target}`; },

Other Tools

Related 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/abdessamad-elamrani/MalwareAnalyzerMCP'

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