Skip to main content
Glama

delete_file

Delete files or empty directories safely, singly or in batches, with validation, locking, and LSP notification. Non-empty directories are refused; no recursive delete.

Instructions

Delete files and empty directories. Pass file_path for one, or paths for several in a single call (max 100). Refuses to delete directories unless allow_dir: true is set — and even then only an EMPTY directory is accepted (non-empty directories are always rejected; there is no recursive delete). To remove a whole tree, list its files with find_files and pass them plus their directories in one paths batch with allow_dir: true — every path is validated before anything is removed, and directories go last, deepest first, so they are empty by the time their turn comes. The LSP server is notified with FileDeleted so symbol indexes and diagnostics update immediately. Per-path locking serialises against any concurrent write_file/edit_file targeting the same path. The response reports the line and byte count removed (bytes only for a binary or oversized file), then the diff of what was deleted, gated by [edits].show_write_diff; a path matching [history] sensitive_globs reports the withholding instead of its content.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathsNoSeveral files and/or empty directories to delete in one call (max 100). Same per-path rules as file_path — this batches round-trips, it does NOT delete recursively. Every path is validated before any is removed, and directories are removed after files, deepest first, so naming a tree's files and its directories together works in one call.
dirty_okNoAllow deleting a file that has uncommitted changes in its git repository. Default false — deletion is refused if the file is dirty. Pass true to proceed anyway.
allow_dirNoAllow deleting an empty directory. Default false — deletion is refused for any directory. The directory must be empty; non-empty directories are rejected even with allow_dir: true.
file_pathNoAbsolute path, file:// URI, or workspace-relative path of the file or empty directory to delete. Use paths instead to delete several in one call.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed2 schema fields changedv0.17.0
    • changedInput schema / properties / file_path / description
      Previous value: -"Absolute path, file:// URI, or workspace-relative path of the file or empty directory to delete."New value: +"Absolute path, file:// URI, or workspace-relative path of the file or empty directory to delete. Use paths instead to delete several in one call."
    • addedInput schema / properties / paths
      Added value: +{
      +  "description": "Several files and/or empty directories to delete in one call (max 100). Same per-path rules as file_path — this batches round-trips, it does NOT delete recursively. Every path is validated before any is removed, and directories are removed after files, deepest first, so naming a tree's files and its directories together works in one call.",
      +  "items": {
      +    "type": "string"
      +  },
      +  "type": "array"
      +}
  2. First observedv0.16.6

TDQS

A4.8/5.0
Behavior5/5

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

No annotations, so the description carries the full burden, and it delivers: validation-before-removal ordering, directory-last/deepest-first sequencing, LSP FileDeleted notification, per-path locking against concurrent write_file/edit_file, dirty-file refusal (echoed by schema), diff gating by [edits].show_write_diff, sensitive_globs withholding, and the returned line/byte counts. This is unusually rich operational context.

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?

Front-loaded with purpose and the single-vs-many choice, then constraints, then workflow, then side effects. Dense but every clause earns its place; slight redundancy between the description and the paths schema entry keeps it from a 5.

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

Completeness5/5

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

For a 4-param mutation tool with no annotations and no output schema, the description covers safety (empty-only, validation-first), concurrency (locking), observability (reveals line/byte counts and diff behavior), and the tree-removal workaround. Nothing an agent needs to call this correctly is missing. The absence of an output schema means the brief mention of response fields is appropriate.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the baseline is 3. The description adds sequencing semantics beyond the schema: 'directories go last, deepest first' and 'every path is validated before anything is removed,' plus the max-100 cap and the tree-removal pattern using paths + allow_dir together. It repeats some schema content but embeds it in the operational flow.

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?

States a specific verb (delete) and resource (files and empty directories), and explicitly distinguishes scope from alternatives: 'this batches round-trips, it does NOT delete recursively.' An agent can immediately tell this apart from rename_file, copy_file, or safe_delete_symbol.

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

Usage Guidelines5/5

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

Explicitly says when to use paths vs file_path (one vs several), when allow_dir is required, and gives a full workflow for removing a tree via find_files. Exclusions are explicit: no recursive delete, non-empty directories always rejected. Names the sibling (find_files) for the tree case.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.