Skip to main content
Glama
abdessamad-elamrani

MalwareAnalyzerMCP

xxd

Analyze binary files by creating hexdumps with ASCII representation to inspect file contents for malware analysis.

Instructions

Create a hexdump with ASCII representation

Example usage:

  • Standard xxd dump: { "target": "suspicious.exe" }

  • With length limit: { "target": "suspicious.exe", "length": 256 }

  • With column formatting: { "target": "suspicious.exe", "cols": 16 }

  • Binary bits mode: { "target": "suspicious.exe", "bits": true }

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
targetYesTarget file or data to analyze
optionsNoAdditional command-line options
lengthNoNumber of bytes to display
offsetNoStarting offset in the file
colsNoFormat output into specified number of columns
bitsNoSwitch to bits (binary) dump

Implementation Reference

  • Core handler for executing the 'xxd' tool (and other specialized commands): validates input against schema, builds command string using tool-specific buildCommand, executes via terminalManager.shellCommand, and returns 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,
        };
      }
    }
  • xxd-specific logic to construct the xxd shell command from input parameters.
    buildCommand: (args) => {
      let options = args.options ? args.options : '';
      
      if (args.length) {
        options += ` -l ${args.length}`;
      }
      
      if (args.offset) {
        options += ` -s ${args.offset}`;
      }
      
      if (args.cols) {
        options += ` -c ${args.cols}`;
      }
      
      if (args.bits) {
        options += ' -b';
      }
      
      return `xxd ${options} ${args.target}`;
    },
  • Zod input schema for the xxd tool, defining parameters like length, offset, cols, bits extending baseCommandSchema.
    schema: baseCommandSchema.extend({
      length: z.number().optional().describe("Number of bytes to display"),
      offset: z.number().optional().describe("Starting offset in the file"),
      cols: z.number().optional().describe("Format output into specified number of columns"),
      bits: z.boolean().optional().describe("Switch to bits (binary) dump")
    }),
  • serverMCP.js:113-118 (registration)
    Registers 'xxd' (and other commands) as MCP tools dynamically from the commands configuration, providing 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:132-170 (registration)
    Configuration object for the 'xxd' tool, including name, description, schema, buildCommand, and helpText, exported as part of commands.
      // XXD command - hexdump with ASCII representation
      xxd: {
        name: 'xxd',
        description: 'Create a hexdump with ASCII representation',
        schema: baseCommandSchema.extend({
          length: z.number().optional().describe("Number of bytes to display"),
          offset: z.number().optional().describe("Starting offset in the file"),
          cols: z.number().optional().describe("Format output into specified number of columns"),
          bits: z.boolean().optional().describe("Switch to bits (binary) dump")
        }),
        buildCommand: (args) => {
          let options = args.options ? args.options : '';
          
          if (args.length) {
            options += ` -l ${args.length}`;
          }
          
          if (args.offset) {
            options += ` -s ${args.offset}`;
          }
          
          if (args.cols) {
            options += ` -c ${args.cols}`;
          }
          
          if (args.bits) {
            options += ' -b';
          }
          
          return `xxd ${options} ${args.target}`;
        },
        helpText: `
    Example usage:
      - Standard xxd dump: { "target": "suspicious.exe" }
      - With length limit: { "target": "suspicious.exe", "length": 256 }
      - With column formatting: { "target": "suspicious.exe", "cols": 16 }
      - Binary bits mode: { "target": "suspicious.exe", "bits": true }
        `
      }
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 of behavioral disclosure. It describes the core functionality (hexdump creation) and shows example parameter combinations, but doesn't mention important behavioral aspects like file access permissions, error handling, output format details, or performance characteristics that would be helpful for an AI agent.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is perfectly structured: a clear purpose statement followed by specific, well-organized examples. Every sentence serves a purpose - the initial statement defines the tool, and each example demonstrates a different parameter combination. No wasted words or redundant information.

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

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a tool with 6 parameters, no annotations, and no output schema, the description provides adequate basic information but lacks completeness. It explains what the tool does and shows parameter usage, but doesn't cover behavioral aspects, error conditions, or output format details that would help an AI agent use it effectively in complex scenarios.

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?

The schema description coverage is 100%, so the schema already documents all parameters well. The description adds value through concrete usage examples that illustrate how parameters combine in practice (e.g., 'With length limit', 'With column formatting', 'Binary bits mode'), providing practical context beyond the schema's technical descriptions.

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

Purpose4/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: 'Create a hexdump with ASCII representation'. This is a specific verb+resource combination that distinguishes it from some siblings like 'file' or 'strings'. However, it doesn't explicitly differentiate from 'hexdump' which might serve a similar function.

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 provides example usage patterns which imply when to use certain parameters, but it doesn't explicitly state when to use this tool versus alternatives like 'hexdump' or 'objdump'. The examples show different scenarios but lack explicit guidance on tool selection among siblings.

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

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