Skip to main content
Glama
PWalaGov

Enhanced Directory Context MCP Server

by PWalaGov

delete_file

Remove files from your directory with optional backup creation to prevent data loss during file management operations.

Instructions

Delete a file

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYesFile path relative to working directory
backupNoCreate backup before deleting (.deleted extension)

Implementation Reference

  • The handler function that implements the core logic of the 'delete_file' tool: resolves the file path, checks existence, optionally creates a backup (.deleted), deletes the file using fs.unlink, and returns a success message.
    async handleDeleteFile(args) {
      const { path: filePath, backup = true } = args;
      const fullPath = path.resolve(this.workingDirectory, filePath);
      
      try {
        // Check if file exists
        await fs.access(fullPath);
        
        // Create backup if requested
        if (backup) {
          const backupPath = `${fullPath}.deleted`;
          await fs.copyFile(fullPath, backupPath);
        }
        
        // Delete file
        await fs.unlink(fullPath);
        
        return {
          content: [
            {
              type: 'text',
              text: `File deleted: ${filePath}${backup ? '\nBackup created: ' + filePath + '.deleted' : ''}`,
            },
          ],
        };
      } catch (error) {
        throw new McpError(ErrorCode.InternalError, `Failed to delete file: ${error.message}`);
      }
    }
  • The input schema defining parameters for the 'delete_file' tool: path (required string), backup (optional boolean, default true).
    inputSchema: {
      type: 'object',
      properties: {
        path: {
          type: 'string',
          description: 'File path relative to working directory',
        },
        backup: {
          type: 'boolean',
          description: 'Create backup before deleting (.deleted extension)',
          default: true,
        },
      },
      required: ['path'],
    },
  • server.js:482-483 (registration)
    The dispatch case in the central CallToolRequestSchema handler that routes 'delete_file' tool calls to the handleDeleteFile method.
    case 'delete_file':
      return await this.handleDeleteFile(args);
  • server.js:276-294 (registration)
    The tool descriptor registration in the ListToolsRequestSchema response, including name, description, and input schema.
    {
      name: 'delete_file',
      description: 'Delete a file',
      inputSchema: {
        type: 'object',
        properties: {
          path: {
            type: 'string',
            description: 'File path relative to working directory',
          },
          backup: {
            type: 'boolean',
            description: 'Create backup before deleting (.deleted extension)',
            default: true,
          },
        },
        required: ['path'],
      },
    },
  • Usage of handleDeleteFile as a helper in the batch_file_operations tool, with backup disabled.
    result = await this.handleDeleteFile({ ...params, backup: false });
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. 'Delete a file' implies a destructive mutation, but it doesn't specify if deletion is permanent, reversible, requires permissions, or has side effects. The input schema hints at a backup option, but the description doesn't mention this behavior, leaving critical gaps for a destructive operation.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description 'Delete a file' is extremely concise with zero wasted words, making it front-loaded and easy to parse. However, it may be overly terse for a destructive tool, potentially under-specifying critical details. It earns a high score for efficiency but loses a point for lacking necessary context in its brevity.

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 tool's complexity (destructive operation with 2 parameters) and the absence of annotations and output schema, the description is incomplete. It fails to address key aspects like safety (e.g., backup behavior), error handling, or return values. For a delete tool, this minimal description leaves too many unknowns for safe and 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%, so the input schema fully documents the parameters (path and backup). The description adds no additional meaning beyond what the schema provides, such as explaining parameter interactions or use cases. With high schema coverage, the baseline score of 3 is appropriate, as the description doesn't compensate but also doesn't detract.

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

Purpose3/5

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

The description 'Delete a file' states the basic action (delete) and resource (file), which is clear but minimal. It distinguishes from siblings like 'rename_file' or 'update_file' by specifying deletion, but lacks specificity about scope or constraints. It's not tautological but remains vague about what 'delete' entails beyond the obvious.

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. For example, it doesn't mention if this is for permanent deletion or if there are safer options like moving to trash, nor does it reference sibling tools like 'batch_file_operations' for multiple deletions. Without any context, usage is implied but not explicitly stated.

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/PWalaGov/File-Control-MCP'

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