Skip to main content
Glama
Preston-Harrison

Filesystem MCP Server

delete_file

Remove files from the filesystem by specifying their path. This tool helps manage storage by deleting unnecessary files within allowed directories.

Instructions

Delete a file from the filesystem.

Args: path (str): File path to delete (absolute or relative to allowed directories)

Returns: str: Success message with deleted file path, or error message if failed

Note: - Path must be within allowed directory roots - Fails if file doesn't exist or cannot be deleted

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • main.py:234-254 (handler)
    The main handler function for the 'delete_file' tool. It is registered via the @mcp.tool decorator. Resolves the path using _resolve to ensure it's within allowed directories, deletes the file using unlink(), and returns a success message or human-readable error.
    @mcp.tool
    def delete_file(path: str) -> str:
        """Delete a file from the filesystem.
    
        Args:
            path (str): File path to delete (absolute or relative to allowed directories)
    
        Returns:
            str: Success message with deleted file path, or error message if failed
    
        Note:
            - Path must be within allowed directory roots
            - Fails if file doesn't exist or cannot be deleted
        """
        try:
            rp = _resolve(path)
            rp.unlink()
            return f"Deleted {rp}"
        except Exception as e:
            return _human_error(e, "deleting file")
Behavior4/5

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

With no annotations provided, the description carries full burden and does well: it clearly states this is a destructive operation ('Delete'), specifies constraints ('Path must be within allowed directory roots'), and describes failure conditions ('Fails if file doesn't exist or cannot be deleted'). It doesn't cover rate limits or authentication needs, but provides solid behavioral context 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.

Conciseness5/5

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

Perfectly structured and front-loaded: purpose statement first, then Args/Returns/Note sections with zero wasted words. Every sentence earns its place by providing essential information without redundancy or fluff.

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

Completeness4/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, 0% schema coverage, but with output schema, the description is quite complete: covers purpose, parameter meaning, constraints, failure modes, and return value explanation. The output schema handles return structure, so description doesn't need to detail that. Could mention permissions or irreversible nature more explicitly, but covers most essentials.

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 0%, so the description must compensate. It provides meaningful context for the single parameter: explains what 'path' represents ('File path to delete'), clarifies format options ('absolute or relative to allowed directories'), and adds constraints not in schema ('within allowed directory roots'). It doesn't specify path syntax examples, but adds substantial value beyond the bare schema.

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?

The description clearly states the specific action ('Delete a file') and resource ('from the filesystem'), distinguishing it from sibling tools like move_file, edit_file, or read_text_file. It uses precise language that leaves no ambiguity about the tool's function.

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

Usage Guidelines3/5

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

The description implies usage through the 'Note' section mentioning path constraints, but doesn't explicitly state when to use this tool versus alternatives like move_file or when not to use it (e.g., for directories vs files). It provides some context but lacks explicit guidance on tool selection among siblings.

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/Preston-Harrison/fs-mcp-py'

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