Skip to main content
Glama
qpd-v

MCP-Delete

by qpd-v

delete_file

Remove a file from the specified path using the MCP-Delete server. Supports both relative and absolute paths to ensure accurate and safe file deletion.

Instructions

Delete a file at the specified path (supports both relative and absolute paths)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYesPath to the file to delete (relative to working directory or absolute)

Implementation Reference

  • Handler for the delete_file tool. Resolves the input path to possible locations, checks if the file exists, deletes it using fs.promises.unlink, and returns success or throws appropriate MCP errors.
    case "delete_file": {
      const inputPath = String(request.params.arguments?.path);
      if (!inputPath) {
        throw new McpError(
          ErrorCode.InvalidParams,
          "File path is required"
        );
      }
      
      // Try multiple potential paths
      const pathsToTry = [
        inputPath, // Original path
        isAbsolute(inputPath) ? inputPath : resolve(process.cwd(), inputPath), // Relative to process.cwd()
        isAbsolute(inputPath) ? inputPath : resolve('c:/mcpnfo', inputPath), // Relative to mcpnfo
      ];
    
      // Try each path
      let fileFound = false;
      let foundPath = '';
      for (const path of pathsToTry) {
        if (existsSync(path)) {
          fileFound = true;
          foundPath = path;
          break;
        }
      }
    
      if (!fileFound) {
        throw new McpError(
          ErrorCode.InvalidParams,
          `File not found: ${inputPath}\nTried paths:\n${pathsToTry.join('\n')}`
        );
      }
    
      try {
        await unlink(foundPath);
        return {
          content: [{
            type: "text",
            text: `Successfully deleted file: ${inputPath}`
          }]
        };
      } catch (err) {
        const error = err as Error;
        throw new McpError(
          ErrorCode.InternalError,
          `Failed to delete file ${inputPath}: ${error.message}\nTried paths:\n${pathsToTry.join('\n')}`
        );
      }
    }
  • src/index.ts:37-50 (registration)
    Registers the "delete_file" tool in the ListTools response, including its name, description, and input schema.
    {
      name: "delete_file",
      description: "Delete a file at the specified path (supports both relative and absolute paths)",
      inputSchema: {
        type: "object",
        properties: {
          path: {
            type: "string",
            description: "Path to the file to delete (relative to working directory or absolute)"
          }
        },
        required: ["path"]
      }
    }
  • Input schema definition for the delete_file tool, specifying a required 'path' string property.
    inputSchema: {
      type: "object",
      properties: {
        path: {
          type: "string",
          description: "Path to the file to delete (relative to working directory or absolute)"
        }
      },
      required: ["path"]
    }
Behavior2/5

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

With no annotations provided, the description carries full burden but only states the basic action. It doesn't disclose critical behavioral traits like whether deletion is permanent, irreversible, requires specific permissions, has confirmation prompts, or affects linked resources. 'Delete' implies destructive, but details are missing.

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 with zero waste—it states the action, resource, and a key parameter detail. It's appropriately sized and front-loaded with the core purpose.

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?

For a destructive tool with no annotations and no output schema, the description is incomplete. It lacks information on behavioral consequences (e.g., permanence, error handling), usage context, and expected outcomes. Given the complexity of file deletion, more guidance is needed.

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?

The schema description coverage is 100%, so the parameter 'path' is fully documented in the schema. The description adds minimal value by reiterating path support (relative/absolute), which is already in the schema description. Baseline 3 is appropriate as the schema does the heavy lifting.

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 ('Delete') and the resource ('a file at the specified path'), making the purpose unambiguous. It doesn't need to differentiate from siblings since none exist, but it could be more specific about what 'delete' entails (e.g., permanent removal vs. moving to trash).

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 (e.g., move_file, archive_file) or any prerequisites (e.g., permissions needed). It mentions path types (relative/absolute) but this is parameter guidance, not usage context.

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/qpd-v/mcp-delete'

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