list_backups
View available Minecraft world backups to restore previous game states. Filter results by world name to locate specific backup files for server recovery.
Instructions
List all available world backups, optionally filtered by world name.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| world_name | No | Filter by world name (optional) |
Implementation Reference
- src/core/BackupManager.ts:91-124 (handler)The implementation of `listBackups` in `BackupManager` which lists files in the backup directory and parses their information.
/** List all backups */ listBackups(worldName?: string): BackupInfo[] { this.ensureBackupDir(); const files = fs.readdirSync(this.backupDir); const backups: BackupInfo[] = []; for (const file of files) { if (!file.endsWith(".tar.gz")) continue; const fullPath = path.join(this.backupDir, file); const stats = fs.statSync(fullPath); const baseName = file.replace(".tar.gz", ""); // Parse world name from backup name (worldName_YYYY-MM-DD_HH-MM-SS) const underscoreIdx = baseName.indexOf("_"); const parsedWorldName = underscoreIdx > 0 ? baseName.substring(0, underscoreIdx) : baseName; if (worldName && parsedWorldName !== worldName) continue; backups.push({ name: baseName, worldName: parsedWorldName, timestamp: stats.mtime, sizeMB: Math.round((stats.size / (1024 * 1024)) * 100) / 100, path: fullPath, }); } return backups.sort( (a, b) => b.timestamp.getTime() - a.timestamp.getTime() ); } - src/tools/backup-tools.ts:58-96 (registration)Registration of the 'list_backups' tool using the McpServer and calling `backupManager.listBackups`.
// --- List Backups --- server.tool( "list_backups", "List all available world backups, optionally filtered by world name.", { world_name: z .string() .optional() .describe("Filter by world name (optional)"), }, async ({ world_name }) => { const backups = backupManager.listBackups(world_name); if (backups.length === 0) { return { content: [ { type: "text", text: world_name ? `No backups found for world "${world_name}".` : "No backups found.", }, ], }; } const lines = backups.map( (b) => `📦 ${b.name} | ${b.sizeMB} MB | ${b.timestamp.toISOString()}` ); return { content: [ { type: "text", text: `Found ${backups.length} backup(s):\n${lines.join("\n")}`, }, ], }; } );