Skip to main content
Glama

file

Analyze files to determine their type and identify potential malware using command-line options for detailed inspection.

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
targetYesTarget file or data to analyze
optionsNoAdditional command-line options

Implementation Reference

  • Core handler for the 'file' tool execution within the MCP CallToolRequestSchema handler. Validates input using the tool's schema, builds the shell command ('file ...') using buildCommand, executes it via terminalManager.shellCommand, and returns the result.
    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, }; } }
  • Base Zod schema used by the 'file' tool (and others) for input validation: requires 'target' string, optional 'options'.
    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-117 (registration)
    Dynamic registration of the 'file' tool (from commands config) in the MCP ListToolsRequestSchema handler, exposing name, description, and inputSchema.
    const specializedTools = Object.values(commands).map(cmd => ({ name: cmd.name, description: cmd.description + (cmd.helpText ? '\n' + cmd.helpText : ''), inputSchema: zodToJsonSchema(cmd.schema), }));
  • Tool configuration object for 'file', including explicit name, description, schema reference, buildCommand helper that constructs the 'file' shell command, and example help text.
    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" } ` },

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