Skip to main content
Glama

list_backups

Find and display backup files in a specified directory using customizable patterns to manage file versions.

Instructions

List all backup files in a directory

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
directoryNoDirectory to search for backup files.
patternNoBackup file pattern*.bak

Implementation Reference

  • The handler function for the 'list_backups' tool. It uses the 'find' command to locate backup files matching the given pattern in the specified directory, retrieves metadata like size and modification date using 'stat', infers the original filename, and returns a formatted list of backups.
    case 'list_backups': {
      const { directory = '.', pattern = '*.bak' } = args;
      
      // Find all backup files
      const findCmd = `find ${directory} -name "${pattern}" -type f | head -100`;
      const { stdout } = await execAsync(findCmd);
      
      if (!stdout.trim()) {
        return {
          content: [{
            type: 'text',
            text: `No backup files found matching pattern: ${pattern}`
          }]
        };
      }
      
      const files = stdout.trim().split('\n');
      
      // Get file info for each backup
      const backupInfo = [];
      for (const backupFile of files) {
        try {
          const stats = await execAsync(`stat -f "%m %z" '${backupFile}' 2>/dev/null || stat -c "%Y %s" '${backupFile}'`);
          const [mtime, size] = stats.stdout.trim().split(' ');
          const date = new Date(parseInt(mtime) * 1000).toISOString().split('T')[0];
          const sizeKB = Math.round(parseInt(size) / 1024);
          
          // Infer original file name
          const originalFile = backupFile.replace(/\.(bak|backup|orig|~)$/, '');
          backupInfo.push(`${backupFile} (${sizeKB}KB, ${date}) -> ${originalFile}`);
        } catch {
          backupInfo.push(backupFile);
        }
      }
      
      return {
        content: [{
          type: 'text',
          text: `Found ${files.length} backup files:\n\n${backupInfo.join('\n')}\n\nTip: Use restore_backup to restore any of these files`
        }]
      };
    }
  • src/index.ts:246-264 (registration)
    Registration of the 'list_backups' tool in the ListToolsRequestSchema handler, including its name, description, and input schema definition.
    {
      name: 'list_backups',
      description: 'List all backup files in a directory',
      inputSchema: {
        type: 'object',
        properties: {
          directory: {
            type: 'string',
            default: '.',
            description: 'Directory to search for backup files'
          },
          pattern: {
            type: 'string',
            default: '*.bak',
            description: 'Backup file pattern'
          }
        }
      }
    },
  • Input schema definition for the 'list_backups' tool, specifying parameters for directory and pattern with defaults.
    inputSchema: {
      type: 'object',
      properties: {
        directory: {
          type: 'string',
          default: '.',
          description: 'Directory to search for backup files'
        },
        pattern: {
          type: 'string',
          default: '*.bak',
          description: 'Backup file pattern'
        }
      }
  • Help content and usage examples for the 'list_backups' tool, provided via the 'help' tool.
      list_backups: `list_backups - Find backup files
    ==============================
    List all backup files in a directory.
    
    Examples:
      // List all .bak files in current directory
      list_backups({})
      
      // Search specific directory
      list_backups({ directory: "./src" })
      
      // Find different backup patterns
      list_backups({ pattern: "*.backup" })
      list_backups({ pattern: "*~" })  // Emacs-style
      
      // Check entire project
      list_backups({ directory: ".", pattern: "*.bak" })
    
    Output shows:
    - Backup file path
    - File size
    - Modification date
    - Original file name (inferred)
    
    Useful for cleanup or finding old versions.
    `
Behavior2/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 but only states the basic action without details on permissions, output format, pagination, or error handling. It fails to address whether this is a read-only operation, what happens with invalid inputs, or other behavioral traits, leaving significant gaps.

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 that directly states the tool's purpose without any wasted words. It is appropriately sized and front-loaded, making it easy for an agent to parse quickly.

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 the lack of annotations and output schema, the description is incomplete for a tool with two parameters. It doesn't explain what the output looks like (e.g., list format, error responses) or provide behavioral context, making it inadequate for full agent understanding despite the clear schema.

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?

The schema description coverage is 100%, with both parameters ('directory' and 'pattern') fully documented in the input schema. The description adds no additional meaning beyond what the schema provides, such as examples or constraints, so it meets the baseline score of 3 for 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 action ('List') and resource ('backup files in a directory'), making the tool's purpose immediately understandable. However, it doesn't distinguish this tool from potential siblings like 'restore_backup' beyond the basic verb, missing explicit differentiation that would warrant a score of 5.

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 like 'restore_backup' or other file-related tools. It lacks any context about prerequisites, typical use cases, or exclusions, leaving the agent with minimal usage direction.

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/MikeyBeez/mcp-smalledit'

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