Skip to main content
Glama

backup_and_edit

Destructive

Create backups of files before editing them to prevent data loss. Specify files and edit operations to safely modify content.

Instructions

Create backups of files before editing them

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filesYesList of files to backup and edit
operationYesThe edit operation to perform

Implementation Reference

  • Main execution logic for the 'backup_and_edit' tool. Backs up files using FileSystemManager, delegates editing to EditInstanceManager via executeWithEdit, includes backup info in response, and restores files from backups if editing fails.
    case 'backup_and_edit':
      // Create backups with file system
      const backups = await Promise.all(
        operation.affectedFiles.map(file =>
          this.fileSystemManager.createBackup(file)
        )
      );
      
      try {
        // Use Edit for the edits
        const result = await this.executeWithEdit({
          ...operation,
          type: operation.params.operation.type
        });
        
        return {
          ...result,
          backups
        };
      } catch (error) {
        // If edits fail, restore backups
        await Promise.all(
          operation.affectedFiles.map((file, index) =>
            this.fileSystemManager.restoreBackup(backups[index], file)
          )
        );
        
        throw error;
      }
  • src/index.ts:365-388 (registration)
    Registers the 'backup_and_edit' tool with the MCP server in the registerHybridTools function, defining its name, description, input schema, and operational annotations.
    mcpServer.registerTool({
      name: 'backup_and_edit',
      description: 'Create backups of files before editing them',
      inputSchema: {
        type: 'object',
        properties: {
          files: {
            type: 'array',
            description: 'List of files to backup and edit'
          },
          operation: {
            type: 'object',
            description: 'The edit operation to perform'
          }
        },
        required: ['files', 'operation']
      },
      annotations: {
        readOnlyHint: false,
        destructiveHint: true,
        idempotentHint: false,
        openWorldHint: false
      }
    });
  • Input schema definition for the 'backup_and_edit' tool, specifying required 'files' array and 'operation' object.
      inputSchema: {
        type: 'object',
        properties: {
          files: {
            type: 'array',
            description: 'List of files to backup and edit'
          },
          operation: {
            type: 'object',
            description: 'The edit operation to perform'
          }
        },
        required: ['files', 'operation']
      },
      annotations: {
        readOnlyHint: false,
        destructiveHint: true,
        idempotentHint: false,
        openWorldHint: false
      }
    });
Behavior3/5

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

Annotations already indicate destructiveHint=true and readOnlyHint=false, so the agent knows this is a non-idempotent write operation. The description adds value by specifying that backups are created before editing, which clarifies safety behavior beyond the annotations. However, it lacks details on backup location, edit rollback options, or error handling, limiting its transparency.

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, clear sentence that efficiently conveys the core functionality without any wasted words. It is front-loaded with the main action, making it easy for an agent to quickly grasp the tool's purpose.

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

Completeness3/5

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

Given the destructive nature (annotations show destructiveHint=true) and lack of output schema, the description is minimally adequate. It covers the backup-and-edit process but omits critical details like what the edit operation entails, how backups are stored, or success/failure outcomes, which could hinder an agent's ability to use it effectively in complex scenarios.

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%, so the input schema fully documents the parameters ('files' and 'operation'). The description implies that 'files' are backed up and edited, and 'operation' defines the edit, but adds no extra semantic details beyond what the schema provides, such as file format constraints or operation types, meeting the baseline for high schema coverage.

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 tool's purpose with a specific verb ('Create backups') and resource ('files'), making it easy to understand what the tool does. However, it doesn't explicitly differentiate from sibling tools like 'write_file' or 'interactive_edit_session', which might also involve file modifications, so it doesn't reach the highest score.

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 prerequisites, such as needing existing files to edit, or specify scenarios where this is preferred over direct editing tools like 'write_file' or 'smart_refactor', leaving the agent with minimal context for selection.

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/mixelpixx/edit-mcp'

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