Skip to main content
Glama

create_backup

Create compressed backups of Minecraft worlds while the server is running using save-off/save-on commands to ensure data integrity.

Instructions

Create a compressed backup (tar.gz) of a world. Safe to use while the server is running (uses save-off/save-on).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
world_nameYesWorld folder name to backup (e.g., 'world')

Implementation Reference

  • The actual logic for creating a world backup, including handling RCON save commands.
    async createBackup(
      worldName: string,
      rcon?: RconClient,
      serverRunning = false
    ): Promise<BackupInfo> {
      this.ensureBackupDir();
    
      const worldPath = path.join(this.serverDir, worldName);
      if (!fs.existsSync(worldPath)) {
        throw new Error(`World "${worldName}" not found at ${worldPath}`);
      }
    
      // If server is running, disable saving for consistent backup
      if (serverRunning && rcon) {
        try {
          await rcon.send("save-off");
          await rcon.send("save-all flush");
          // Wait briefly for save to complete
          await new Promise((r) => setTimeout(r, 2000));
        } catch {
          // Continue with backup anyway
        }
      }
    
      const timestamp = new Date()
        .toISOString()
        .replace(/[:.]/g, "-")
        .replace("T", "_")
        .split("Z")[0];
      const backupName = `${worldName}_${timestamp}`;
      const backupPath = path.join(this.backupDir, backupName);
    
      try {
        // Use tar for compression (available on macOS and Linux)
        const tarPath = `${backupPath}.tar.gz`;
        execSync(
          `tar -czf "${tarPath}" -C "${this.serverDir}" "${worldName}"`,
          { timeout: 300000 } // 5 min timeout
        );
    
        const stats = fs.statSync(tarPath);
    
        return {
          name: backupName,
          worldName,
          timestamp: new Date(),
          sizeMB: Math.round((stats.size / (1024 * 1024)) * 100) / 100,
          path: tarPath,
        };
      } finally {
        // Re-enable saving
        if (serverRunning && rcon) {
          try {
            await rcon.send("save-on");
          } catch {
            // Server may have stopped
          }
        }
      }
    }
  • MCP tool registration for 'create_backup' and the tool handler that calls BackupManager.
    server.tool(
      "create_backup",
      "Create a compressed backup (tar.gz) of a world. Safe to use while the server is running (uses save-off/save-on).",
      {
        world_name: z
          .string()
          .describe("World folder name to backup (e.g., 'world')"),
      },
      async ({ world_name }) => {
        try {
          const backup = await backupManager.createBackup(
            world_name,
            manager.rcon,
            manager.isRunning()
          );
          return {
            content: [
              {
                type: "text",
                text: [
                  `Backup created successfully:`,
                  `  Name: ${backup.name}`,
                  `  Size: ${backup.sizeMB} MB`,
                  `  Path: ${backup.path}`,
                  `  Time: ${backup.timestamp.toISOString()}`,
                ].join("\n"),
              },
            ],
          };
        } catch (error) {
          return {
            content: [
              {
                type: "text",
                text: `Backup failed: ${error instanceof Error ? error.message : String(error)}`,
              },
            ],
            isError: true,
          };
        }
      }
    );
Behavior4/5

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

No annotations provided, so description carries full burden. Discloses output format (tar.gz), concurrency safety (safe while running), and implementation mechanism (save-off/save-on). Missing persistence details such as backup location/naming conventions and return value specifics, but covers critical runtime safety behavior thoroughly.

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?

Two sentences with zero waste. First sentence establishes purpose and format (tar.gz), second provides safety assurance and mechanism. Perfectly front-loaded with essential information.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Appropriately complete for a single-parameter backup tool without output schema. Captures essential behavioral context (format, safety, mechanism) that prevents dangerous misuse during server runtime. Minor gap regarding backup storage location or return path, but sufficient for correct invocation.

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 world_name parameter fully documented in schema ('World folder name to backup'). Description adds no parameter-specific semantics, which is acceptable given baseline 3 for high schema coverage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

Specific verb 'Create' + resource 'backup' + format 'tar.gz' + target 'world'. Clearly distinguishes from siblings restore_backup, delete_backup, and list_backups by specifying creation action and compressed format.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Explicitly states 'Safe to use while the server is running', addressing critical concurrency concerns for Minecraft server operations. Mentions implementation mechanism (save-off/save-on) that enables this safety, though does not explicitly contrast with restore_backup alternative.

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/tamo2918/Minecraft-Server-MCP'

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