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`);
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the tool lists backup files but doesn't describe the return format (e.g., list structure, file details), pagination, error handling, or any constraints like rate limits or permissions. This leaves significant gaps for a tool that likely interacts with file systems.

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 in Chinese ('列出可用的備份文件') that directly states the tool's purpose. It's front-loaded with no wasted words, making it easy 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. It doesn't explain what 'available backup files' means in practice (e.g., format, metadata), how results are returned, or any behavioral nuances. For a tool with two parameters and no structured output, more context is needed to guide effective use.

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?

Schema description coverage is 100%, with both parameters ('backup_dir' and 'conversation_id') well-documented in the schema. The description adds no additional parameter semantics beyond what the schema provides, so it meets the baseline for high schema coverage without compensating value.

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 Chinese. It's specific about what the tool does, though it doesn't explicitly differentiate from sibling tools like 'backup_memories' or 'restore_memories' beyond the basic verb-noun pairing.

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. It doesn't mention sibling tools like 'delete_backup' or 'restore_memories', nor does it specify prerequisites or contexts for usage. The agent must infer usage from the name and schema alone.

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

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