Skip to main content
Glama

compareBackups

Analyze and compare two Heptabase backups to identify differences, export results, and optimize data management for enhanced workflow efficiency.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
backupId1Yes
backupId2Yes
exportPathNo
whiteboardIdNo

Implementation Reference

  • The main handler function that executes the compareBackups tool logic. It loads two backups using BackupManager, fetches relevant data (whiteboards, cards, connections) using HeptabaseDataService, computes differences, formats a text summary of changes, and optionally exports JSON to a file.
    export async function compareBackups(
      dataService: HeptabaseDataService,
      backupManager: BackupManager,
      params: z.infer<typeof compareBackupsSchema>
    ) {
      // Get backup metadata
      const backup1 = await backupManager.getBackupMetadata(params.backupId1);
      const backup2 = await backupManager.getBackupMetadata(params.backupId2);
    
      if (!backup1 || !backup2) {
        throw new Error('One or both backups not found');
      }
    
      // Load the first backup
      await backupManager.loadBackup(backup1.backupPath);
      
      let data1: any;
      let data2: any;
    
      if (params.whiteboardId) {
        // Compare specific whiteboard
        data1 = await dataService.getWhiteboard(params.whiteboardId, {
          includeCards: true,
          includeConnections: true
        });
    
        // Load the second backup
        await backupManager.loadBackup(backup2.backupPath);
        
        data2 = await dataService.getWhiteboard(params.whiteboardId, {
          includeCards: true,
          includeConnections: true
        });
      } else {
        // Compare entire backups
        data1 = {
          whiteboards: await dataService.getWhiteboards(),
          cards: await dataService.getCards(),
          connections: await dataService.getConnections()
        };
    
        // Load the second backup
        await backupManager.loadBackup(backup2.backupPath);
        
        data2 = {
          whiteboards: await dataService.getWhiteboards(),
          cards: await dataService.getCards(),
          connections: await dataService.getConnections()
        };
      }
    
      // Calculate differences
      const comparison = {
        timestamp: new Date().toISOString(),
        backup1: {
          id: backup1.backupId,
          date: backup1.createdDate,
          size: backup1.fileSize
        },
        backup2: {
          id: backup2.backupId,
          date: backup2.createdDate,
          size: backup2.fileSize
        },
        changes: {} as any
      };
    
      if (params.whiteboardId) {
        comparison.changes = {
          whiteboard: params.whiteboardId,
          cardsAdded: data2.cards.length - data1.cards.length,
          connectionsAdded: data2.connections.length - data1.connections.length
        };
      } else {
        comparison.changes = {
          whiteboardsAdded: data2.whiteboards.length - data1.whiteboards.length,
          cardsAdded: data2.cards.length - data1.cards.length,
          connectionsAdded: data2.connections.length - data1.connections.length
        };
      }
    
      // Format response
      let text = 'Comparison Results\n\n';
      text += `Backup 1: ${backup1.backupId} (${backup1.createdDate})\n`;
      text += `Backup 2: ${backup2.backupId} (${backup2.createdDate})\n\n`;
    
      if (params.whiteboardId) {
        text += `Whiteboard: ${data1.whiteboard.name}\n`;
        text += `Added: ${comparison.changes.cardsAdded} cards\n`;
        text += `Added: ${comparison.changes.connectionsAdded} connections\n`;
      } else {
        text += `Added: ${comparison.changes.whiteboardsAdded} whiteboards\n`;
        text += `Added: ${comparison.changes.cardsAdded} cards\n`;
        text += `Added: ${comparison.changes.connectionsAdded} connections\n`;
      }
    
      // Export if requested
      if (params.exportPath) {
        await fs.mkdir(path.dirname(params.exportPath), { recursive: true });
        await fs.writeFile(params.exportPath, JSON.stringify(comparison, null, 2), 'utf8');
        text += `\nComparison saved to ${params.exportPath}`;
      }
    
      return {
        content: [{
          type: 'text',
          text
        }]
      };
    }
  • Zod schema defining the input parameters for the compareBackups tool: required backup IDs and optional whiteboard ID and export path.
    export const compareBackupsSchema = z.object({
      backupId1: z.string(),
      backupId2: z.string(),
      whiteboardId: z.string().optional(),
      exportPath: z.string().optional()
    });
  • src/server.ts:714-727 (registration)
    Registers the compareBackups tool with the MCP server by assigning it to this.tools.compareBackups and calling this.server.tool, importing the handler and schema from ./tools/analysis.ts.
    // compareBackups tool
    this.tools.compareBackups = {
      inputSchema: compareBackupsSchema,
      handler: async (params) => {
        if (!this.dataService || !this.backupManager) {
          throw new Error('Services not initialized. Please configure backup path first.');
        }
        return compareBackups(this.dataService, this.backupManager, params);
      }
    };
    
    this.server.tool('compareBackups', compareBackupsSchema.shape, async (params: z.infer<typeof compareBackupsSchema>) => {
      return this.tools.compareBackups.handler(params);
    });
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/heptabase-mcp'

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