Skip to main content
Glama

delete_file

Delete files and directories from the workspace by specifying their path. Clean up or remove unwanted items during development.

Instructions

Delete a file or directory

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYesPath to delete

Implementation Reference

  • The main handler function for the delete_file tool. It resolves the file path via WorkspaceService, checks if it's a directory (using rmdir) or a file (using unlink), clears the stats cache, and returns a success or error result.
    /**
     * Delete a file or directory
     */
    async deleteFile(filePath: string, options?: { force?: boolean }): Promise<ToolResult> {
      try {
        const fullPath = this.workspaceService.resolvePath(filePath);
        
        const stats = await this.getFileStats(fullPath);
        if (stats.isDirectory) {
          await fs.rmdir(fullPath, { recursive: true });
        } else {
          await fs.unlink(fullPath);
        }
        
        // Clear cache
        this.clearStatsCache(fullPath);
        
        return {
          content: [{
            type: 'text',
            text: `${stats.isDirectory ? 'Directory' : 'File'} successfully deleted: ${fullPath}`,
          }],
        };
      } catch (error: any) {
        return {
          isError: true,
          content: [{
            type: 'text',
            text: error.message || 'Failed to delete file/directory'
          }]
        };
      }
    }
  • The input schema definition for the delete_file tool. It defines the 'path' property as a required string and provides a description.
    {
      name: 'delete_file',
      description: 'Delete a file or directory',
      inputSchema: {
        type: 'object',
        properties: {
          path: { type: 'string', description: 'Path to delete' },
        },
        required: ['path'],
      },
    },
  • src/index.ts:165-166 (registration)
    The dispatch/registration of the 'delete_file' tool command in the main VSCodeAgentServer class. It routes the call to this.fileService.deleteFile(args.path).
    case 'delete_file':
      return await this.fileService.deleteFile(args.path);
  • A jest mock function for deleteFile used in test utilities to create a mock FileService.
    deleteFile: jest.fn(),
Behavior2/5

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

With no annotations, the description carries the full burden of disclosing behavioral traits. It only states 'delete', implying a destructive action, but does not describe reversibility, error handling, or side effects like recursive deletion of directories. More details are needed.

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 is a single sentence that conveys the core functionality without extraneous information. It is appropriately concise for a simple tool, though slightly under-specified in content.

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?

For a basic delete operation with one parameter and no output schema, the description is minimally adequate. It does not specify return behavior or confirmation messages, but the tool's simplicity partially compensates. Still, missing context on success/failure outcomes.

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 input schema has 100% coverage and one parameter described as 'Path to delete'. The tool description adds no additional meaning beyond what the schema provides. Baseline of 3 is appropriate given 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 verb 'delete' and resource 'file or directory', making the tool's purpose immediately understandable. However, it does not differentiate from sibling tools that might perform similar operations, but given the unique name, clarity is sufficient.

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 vs alternatives. There is no mention of prerequisites, fallback options, or conditions under which deletion might fail. Agents receive no context for decision-making.

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/agentics-ai/code-mcp'

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