Skip to main content
Glama

list_backups

Retrieve available backup files from the Memory MCP Server to restore previous conversations or data states.

Instructions

列出可用的備份文件

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
backup_dirNo備份目錄路徑(默認為 data/backups/)
conversation_idNo過濾特定對話 ID 的備份

Implementation Reference

  • The core handler function for list_backups tool. Lists .json files in backup directory (default: data/backups), filters by conversation_id if provided, parses each backup to extract metadata (counts, timestamp), computes size, sorts newest first, returns structured list.
    async handler(args) { const { backup_dir, conversation_id } = args; try { const defaultPath = path.join(__dirname, '../../data/backups'); const backupPath = backup_dir || defaultPath; // 確保目錄存在 await fs.mkdir(backupPath, { recursive: true }); // 讀取目錄 const files = await fs.readdir(backupPath); const backups = []; for (const file of files) { if (!file.endsWith('.json')) continue; // 過濾對話 ID if (conversation_id && !file.includes(conversation_id)) { continue; } const filePath = path.join(backupPath, file); const stats = await fs.stat(filePath); try { const content = await fs.readFile(filePath, 'utf-8'); const backup = JSON.parse(content); backups.push({ file_name: file, file_path: filePath, conversation_id: backup.conversation_id, timestamp: backup.timestamp, size_kb: (stats.size / 1024).toFixed(2), short_term_count: backup.short_term?.length || 0, long_term_count: backup.long_term?.length || 0 }); } catch (error) { // 跳過無法解析的文件 continue; } } // 按時間戳排序(最新的在前) backups.sort((a, b) => new Date(b.timestamp) - new Date(a.timestamp)); return { success: true, total: backups.length, backups }; } catch (error) { return { success: false, error: error.message }; } }
  • Zod input schema defining optional backup_dir and conversation_id parameters for filtering backups.
    inputSchema: z.object({ backup_dir: z.string().optional().describe('備份目錄路徑(默認為 data/backups/)'), conversation_id: z.string().optional().describe('過濾特定對話 ID 的備份') }),
  • src/index.js:161-162 (registration)
    Registers the backup tools (including list_backups) to the toolRegistry with scope 'backup' for list_tools response and dispatch routing.
    const backupTools = createBackupTools(getShortTermManager, getLongTermManager, getStorageManager); backupTools.forEach(tool => registerTool(tool, 'backup'));
  • src/index.js:296-299 (registration)
    Dynamic recreation and invocation of backup tools handler during tool call execution for 'backup' scoped tools like list_backups.
    } else if (toolScope === 'backup') { const tools = createBackupTools(getShortTermManager, getLongTermManager, getStorageManager); const tool = tools.find(t => t.name === toolName); result = await withTimeout(tool.handler(validatedArgs), TIMEOUT_CONFIG.BACKUP, `Tool ${toolName} timeout`);

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/win10ogod/memory-mcp-server'

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