Skip to main content
Glama

listBackups

Retrieve and sort Heptabase backup files by date or size, with options to limit results, using this tool for organized backup management.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNo
pathNo
sortByNo

Implementation Reference

  • src/server.ts:207-209 (registration)
    MCP server tool registration for 'listBackups', delegating to internal handler
    this.server.tool('listBackups', listBackupsSchema.shape, async (params) => { return this.tools.listBackups.handler(params); });
  • Main tool handler for listBackups: initializes BackupManager if needed, calls listBackups method, applies sorting/limit, formats response
    this.tools.listBackups = { inputSchema: listBackupsSchema, 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 listBackups tool
    const listBackupsSchema = z.object({ path: z.string().optional(), sortBy: z.enum(['date', 'size']).optional(), limit: z.number().optional() });
  • Core implementation: scans backup directory for .zip/.json files, extracts metadata, sorts by creation date descending
    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; }

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/heptabase-mcp'

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