Skip to main content
Glama

listBackups

Retrieve and organize Heptabase backup files by date or size, specifying a limit to manage data efficiently for analysis or export.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNo
pathNo
sortByNo

Implementation Reference

  • The main handler function for the 'listBackups' MCP tool. It ensures the BackupManager is initialized, calls its listBackups method, applies optional sorting by size and limiting, formats a text response listing the backups.
    handler: async (params) => {
      if (!this.backupManager) {
        this.backupManager = new BackupManager({
          backupPath: params.path || this.config.backupPath,
          extractionPath: this.config.extractionPath,
          autoExtract: this.config.autoExtract,
          watchDirectory: false,
          keepExtracted: this.config.keepExtracted
        });
      }
    
      const backups = await this.backupManager.listBackups(params.path);
      let result = backups;
    
      if (params.sortBy === 'size') {
        result = result.sort((a, b) => b.fileSize - a.fileSize);
      }
    
      if (params.limit) {
        result = result.slice(0, params.limit);
      }
    
      const text = `Found ${result.length} backups:\n` +
        result.map(b => `- ${b.backupId} (${b.fileSize} bytes, ${b.createdDate})`).join('\n');
    
      return {
        content: [{
          type: 'text',
          text
        }]
      };
    }
  • Zod input schema validation for the listBackups tool, defining optional parameters: path, sortBy (date or size), and limit.
    const listBackupsSchema = z.object({
      path: z.string().optional(),
      sortBy: z.enum(['date', 'size']).optional(),
      limit: z.number().optional()
    });
  • src/server.ts:207-209 (registration)
    MCP server registration of the 'listBackups' tool, linking the schema and delegating to the internal tools.listBackups handler.
    this.server.tool('listBackups', listBackupsSchema.shape, async (params) => {
      return this.tools.listBackups.handler(params);
    });
  • Core helper method in BackupManager class that lists backup files (.zip or .json) in the directory, extracts metadata including date from filename, computes size, determines compression, sorts by newest first, and returns BackupMetadata array.
    async listBackups(customPath?: string): Promise<BackupMetadata[]> {
      const backupPath = customPath || this.config.backupPath;
      try {
        const files = await fs.readdir(backupPath);
        const backups: BackupMetadata[] = [];
    
        for (const fileName of files) {
          const filePath = path.join(backupPath, fileName);
          const stats = await fs.stat(filePath);
    
          if (stats.isFile() && (fileName.endsWith('.zip') || fileName.endsWith('.json'))) {
            const backupInfo = this.getBackupInfo(fileName);
            const metadata: BackupMetadata = {
              backupId: path.basename(fileName, path.extname(fileName)),
              backupPath: filePath,
              createdDate: backupInfo.date,
              fileSize: stats.size,
              isCompressed: fileName.endsWith('.zip'),
              version: backupInfo.version
            };
            backups.push(metadata);
          }
        }
    
        // Sort by date descending (newest first)
        return backups.sort((a, b) => b.createdDate.getTime() - a.createdDate.getTime());
      } catch (error) {
        throw error;
      }
    }
Behavior1/5

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

Tool has no description.

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

Conciseness1/5

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

Tool has no description.

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

Completeness1/5

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

Tool has no description.

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

Parameters1/5

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

Tool has no description.

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

Purpose1/5

Does the description clearly state what the tool does and how it differs from similar tools?

Tool has no description.

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

Usage Guidelines1/5

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

Tool has no description.

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

Related 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/LarryStanley/heptabse-mcp'

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