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
| Name | Required | Description | Default |
|---|---|---|---|
| target | Yes | Target file or data to analyze | |
| options | No | Additional command-line options |
Implementation Reference
- serverMCP.js:130-164 (handler)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, }; } }
- commands.js:14-17 (schema)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), }));
- commands.js:25-38 (helper)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" } ` },