Skip to main content
Glama

obsidian_delete_file

DestructiveIdempotent

Delete files or directories from your Obsidian vault to remove outdated or duplicate notes. Requires explicit confirmation for this destructive operation.

Instructions

Delete a file or directory from the vault.

DESTRUCTIVE OPERATION. Requires explicit confirmation. Use carefully when
removing outdated or duplicate notes from your Zettelkasten.

Args:
    params (DeleteFileInput): Contains:
        - filepath (str): Path to file/directory to delete
        - confirm (bool): Must be True to proceed with deletion

Returns:
    str: Success or error message
    
Example:
    Delete a duplicate note after merging content into another note.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
paramsYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • Pydantic input model defining the parameters for the obsidian_delete_file tool: filepath (str) and confirm (bool, required for safety).
    class DeleteFileInput(BaseModel):
        """Input for deleting files."""
        model_config = ConfigDict(str_strip_whitespace=True, extra='forbid')
        
        filepath: str = Field(
            description="Path to the file or directory to delete",
            min_length=1,
            max_length=500
        )
        confirm: bool = Field(
            description="Must be set to true to confirm deletion",
            default=False
        )
  • MCP decorator registering the delete_file function as the 'obsidian_delete_file' tool with destructive operation annotations.
    @mcp.tool(
        name="obsidian_delete_file",
        annotations={
            "title": "Delete File or Directory",
            "readOnlyHint": False,
            "destructiveHint": True,
            "idempotentHint": True,
            "openWorldHint": False
        }
    )
  • The primary handler function for the obsidian_delete_file tool. Validates the confirmation parameter and invokes the ObsidianClient.delete method to perform the deletion via the Obsidian REST API.
    async def delete_file(params: DeleteFileInput) -> str:
        """Delete a file or directory from the vault.
        
        DESTRUCTIVE OPERATION. Requires explicit confirmation. Use carefully when
        removing outdated or duplicate notes from your Zettelkasten.
        
        Args:
            params (DeleteFileInput): Contains:
                - filepath (str): Path to file/directory to delete
                - confirm (bool): Must be True to proceed with deletion
        
        Returns:
            str: Success or error message
            
        Example:
            Delete a duplicate note after merging content into another note.
        """
        if not params.confirm:
            return json.dumps({
                "error": "Deletion requires explicit confirmation. Set 'confirm' to true.",
                "filepath": params.filepath,
                "success": False
            }, indent=2)
        
        try:
            await obsidian_client.delete(f"/vault/{params.filepath}")
            
            return json.dumps({
                "success": True,
                "message": f"Successfully deleted: {params.filepath}",
                "filepath": params.filepath
            }, indent=2)
            
        except ObsidianAPIError as e:
            return json.dumps({
                "error": str(e),
                "filepath": params.filepath,
                "success": False
            }, indent=2)
  • Helper method in ObsidianClient that executes the actual HTTP DELETE request to the Obsidian Local REST API endpoint for deleting vault files or directories.
    async def delete(self, endpoint: str) -> Dict[str, Any]:
        """Execute DELETE request to Obsidian API."""
        url = f"{self.base_url}{endpoint}"
        try:
            response = await self.client.delete(url)
            if response.status_code in (200, 204):
                return {"success": True, "message": "Resource deleted successfully"}
            else:
                self._handle_error(response, f"DELETE {endpoint}")
        except httpx.RequestError as e:
            raise ObsidianAPIError(
                f"Connection error for DELETE {endpoint}: {str(e)}. "
                "Ensure Obsidian is running with the Local REST API plugin enabled."
            )
Behavior4/5

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

The description adds valuable behavioral context beyond annotations: it explicitly warns 'DESTRUCTIVE OPERATION' and notes 'Requires explicit confirmation,' which aligns with the destructiveHint=true annotation. However, it doesn't mention idempotentHint=true (deleting a non-existent file might succeed or fail), leaving some behavioral traits uncovered. No contradiction with annotations exists.

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 well-structured with clear sections (purpose, warning, usage, Args, Returns, Example) and front-loads key information. It's appropriately sized for a destructive tool, though the example sentence could be slightly more concise. Every sentence adds value without redundancy.

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?

Given the tool's complexity (destructive operation with confirmation) and the presence of an output schema (Returns: str), the description is largely complete. It covers purpose, guidelines, parameters, and behavioral warnings, but could benefit from mentioning idempotency or error cases for a fully comprehensive view.

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?

With 0% schema description coverage, the description compensates by explaining both parameters in the Args section: 'filepath (str): Path to file/directory to delete' and 'confirm (bool): Must be True to proceed with deletion.' This adds clear meaning beyond the bare schema, though it doesn't detail constraints like maxLength for filepath.

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 or directory') and resource ('from the vault'), distinguishing it from sibling tools like obsidian_append_content or obsidian_update_frontmatter which modify content rather than remove files. The verb 'Delete' is precise and unambiguous.

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?

The description provides explicit guidance on when to use this tool ('removing outdated or duplicate notes from your Zettelkasten') and includes a cautionary note ('Use carefully'). It also offers an example scenario ('Delete a duplicate note after merging content into another note'), which helps differentiate it from alternatives like obsidian_patch_content for modifications.

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/Shepherd-Creative/obsidian-mcp'

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