Skip to main content
Glama
REMnux

REMnux MCP Server

Official
by REMnux

list_files

Browse and retrieve files from malware analysis directories to identify samples or examine tool outputs during security investigations.

Instructions

List files in samples or output directory

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
directoryNoWhich directory to listsamples

Implementation Reference

  • The main handler implementation that executes the list_files tool logic. It runs 'ls -la' on the specified directory (samples or output), parses the output into structured entries with name, size, date, type, and permissions, and returns formatted response or error.
    export async function handleListFiles(
      deps: HandlerDeps,
      args: ListFilesArgs
    ) {
      const startTime = Date.now();
      const { connector, config } = deps;
      const dir = args.directory === "samples" ? config.samplesDir : config.outputDir;
    
      try {
        const result = await connector.execute(["ls", "-la", dir], { timeout: 30000 });
    
        if (result.exitCode !== 0) {
          const stderr = result.stderr || "";
          const notFound = stderr.includes("No such file") || stderr.includes("cannot access");
          return formatError("list_files", new REMnuxError(
            notFound ? `Directory does not exist: ${dir}` : `ls failed: ${stderr}`,
            notFound ? "DIR_NOT_FOUND" : "COMMAND_FAILED",
            notFound ? "not_found" : "tool_failure",
            notFound ? "Upload a file first, or check the directory path" : undefined,
          ), startTime);
        }
    
        const raw = result.stdout || "";
    
        // Parse ls -la output into structured entries
        const lines = raw.split("\n").filter((l) => l.trim() !== "");
        const entries: Array<{ name: string; size: number; date: string; type: string; permissions: string }> = [];
    
        for (const line of lines) {
          // Skip "total N" line
          if (line.startsWith("total ")) continue;
    
          // ls -la format: permissions links owner group size month day time/year name
          const match = line.match(
            /^([drwxlsStT\-]+)\s+\d+\s+\S+\s+\S+\s+(\d+)\s+(\w+\s+\d+\s+\S+)\s+(.+)$/
          );
          if (match) {
            const [, permissions, size, date, name] = match;
            // Skip . and ..
            if (name === "." || name === "..") continue;
    
            // Strip symlink target (e.g., "link -> /outside/sandbox/target")
            let cleanName = name;
            if (permissions.startsWith("l") && name.includes(" -> ")) {
              cleanName = name.split(" -> ")[0];
            }
    
            let type = "file";
            if (permissions.startsWith("d")) type = "directory";
            else if (permissions.startsWith("l")) type = "symlink";
    
            entries.push({
              name: cleanName,
              size: parseInt(size, 10),
              date,
              type,
              permissions,
            });
          }
        }
    
        return formatResponse("list_files", {
          directory: args.directory,
          path: dir,
          entries,
          entry_count: entries.length,
        }, startTime);
      } catch (error) {
        return formatError("list_files", toREMnuxError(error), startTime);
      }
    }
  • Schema definition for the list_files tool. Defines the input validation accepting a 'directory' parameter that must be either 'samples' or 'output', defaulting to 'samples'. Also exports the ListFilesArgs type inferred from the schema.
    export const listFilesSchema = z.object({
      directory: z.enum(["samples", "output"]).default("samples").describe("Which directory to list"),
    });
    export type ListFilesArgs = z.infer<typeof listFilesSchema>;
  • src/index.ts:111-117 (registration)
    Registration of the list_files tool with the MCP server. Defines the tool name as 'list_files', provides a description, uses listFilesSchema.shape for input validation, and connects it to the handleListFiles handler function.
    // Tool: list_files - List files in samples or output directory
    server.tool(
      "list_files",
      "List files in samples or output directory",
      listFilesSchema.shape,
      (args) => handleListFiles(deps, args)
    );
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries full burden. It states the action but lacks behavioral details: no mention of output format (e.g., list of filenames, metadata), pagination, permissions required, rate limits, or error conditions. This is a significant gap for a tool with no annotation coverage.

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 a single, efficient sentence with zero waste. It's front-loaded with the core purpose and appropriately sized for a simple tool. Every word earns its place without redundancy.

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

Completeness2/5

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

Given no annotations and no output schema, the description is incomplete. It doesn't explain what the tool returns (e.g., file list format), error handling, or behavioral constraints. For a tool with 1 parameter and simple context, it should provide more context about output and usage.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, with the parameter 'directory' fully documented in the schema (enum values, default). The description adds minimal value beyond the schema by mentioning 'samples or output directory', but doesn't explain semantics like what these directories represent or usage implications. Baseline 3 is appropriate given high schema coverage.

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 verb ('List') and resource ('files'), and specifies the scope ('in samples or output directory'). It distinguishes from siblings like 'get_file_info' or 'download_file' by focusing on listing rather than detailed operations. However, it doesn't explicitly differentiate from all siblings (e.g., 'check_tools' is unrelated).

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites, when-not scenarios, or compare with sibling tools like 'get_file_info' for metadata or 'download_file' for file retrieval. Usage is implied by the name but not explicitly stated.

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/REMnux/remnux-mcp-server'

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