Skip to main content
Glama
ToKiDoO

Advanced Obsidian MCP Server

by ToKiDoO

obsidian_delete_file

Delete files or directories from an Obsidian vault to manage vault structure and remove unwanted content.

Instructions

Delete a file or directory from the vault.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filepathYesPath to the file or directory to delete (relative to vault root)
confirmYesConfirmation to delete the file (must be true)

Implementation Reference

  • The run_tool method of DeleteFileToolHandler executes the obsidian_delete_file tool logic: validates arguments and calls api.delete_file to delete the specified file.
    def run_tool(self, args: dict) -> Sequence[TextContent | ImageContent | EmbeddedResource]:
        if "filepath" not in args:
            raise RuntimeError("filepath argument missing in arguments")
        
        if not args.get("confirm", False):
            raise RuntimeError("confirm must be set to true to delete a file")
    
        api.delete_file(args["filepath"])
    
        return [
            TextContent(
                type="text",
                text=f"Successfully deleted {args['filepath']}"
            )
        ]
  • The get_tool_description method defines the Tool schema including name 'obsidian_delete_file', description, and input schema requiring filepath and confirm.
    def get_tool_description(self):
        return Tool(
            name=self.name,
            description="Delete a file or directory from the vault.",
            inputSchema={
                "type": "object",
                "properties": {
                    "filepath": {
                        "type": "string",
                        "description": "Path to the file or directory to delete (relative to vault root)",
                        "format": "path"
                    },
                    "confirm": {
                        "type": "boolean",
                        "description": "Confirmation to delete the file (must be true)",
                        "default": False
                    }
                },
                "required": ["filepath", "confirm"]
            }
        )
  • TOOL_MAPPING dictionary registers 'obsidian_delete_file' (via tools.TOOL_DELETE_FILE) to DeleteFileToolHandler class, used later to instantiate and add tools to the server.
    TOOL_MAPPING = {
        tools.TOOL_LIST_FILES_IN_DIR: tools.ListFilesInDirToolHandler,
        tools.TOOL_SIMPLE_SEARCH: tools.SearchToolHandler,
        tools.TOOL_PATCH_CONTENT: tools.PatchContentToolHandler,
        tools.TOOL_PUT_CONTENT: tools.PutContentToolHandler,
        tools.TOOL_APPEND_CONTENT: tools.AppendContentToolHandler,
        tools.TOOL_DELETE_FILE: tools.DeleteFileToolHandler,
        tools.TOOL_COMPLEX_SEARCH: tools.ComplexSearchToolHandler,
        tools.TOOL_BATCH_GET_FILES: tools.BatchGetFilesToolHandler,
        tools.TOOL_PERIODIC_NOTES: tools.PeriodicNotesToolHandler,
        tools.TOOL_RECENT_PERIODIC_NOTES: tools.RecentPeriodicNotesToolHandler,
        tools.TOOL_RECENT_CHANGES: tools.RecentChangesToolHandler,
        tools.TOOL_UNDERSTAND_VAULT: tools.UnderstandVaultToolHandler,
        tools.TOOL_GET_ACTIVE_NOTE: tools.GetActiveNoteToolHandler,
        tools.TOOL_OPEN_FILES: tools.OpenFilesToolHandler,
        tools.TOOL_LIST_COMMANDS: tools.ListCommandsToolHandler,
        tools.TOOL_EXECUTE_COMMANDS: tools.ExecuteCommandsToolHandler,
    }
  • The Obsidian API client's delete_file method sends a DELETE HTTP request to /vault/{filepath} to delete the file from Obsidian vault.
    def delete_file(self, filepath: str) -> Any:
        """Delete a file or directory from the vault.
        
        Args:
            filepath: Path to the file to delete (relative to vault root)
            
        Returns:
            None on success
        """
        url = f"{self.get_base_url()}/vault/{filepath}"
        
        def call_fn():
            response = requests.delete(url, headers=self._get_headers(), verify=self.verify_ssl, timeout=self.timeout)
            response.raise_for_status()
            return None
            
        return self._safe_call(call_fn)
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. While it states the action ('Delete'), it doesn't mention critical details like whether deletion is permanent, requires specific permissions, affects linked files, or has safety mechanisms (e.g., the 'confirm' parameter implies a safeguard, but this isn't explained). For a destructive operation, this is a significant gap.

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, clear sentence with zero wasted words. It front-loads the core action ('Delete') and efficiently specifies the target ('a file or directory from the vault'), making it easy to parse quickly. Every word earns its place.

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?

Given the tool's destructive nature, lack of annotations, and absence of an output schema, the description is insufficient. It doesn't address behavioral risks (e.g., permanence, error handling), usage context relative to siblings, or expected outcomes. For a deletion tool with no structured safety hints, more completeness is needed to guide safe agent use.

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?

Schema description coverage is 100%, so the input schema already fully documents both parameters ('filepath' and 'confirm'). The description adds no additional meaning beyond what's in the schema, such as clarifying path formats or the rationale for the confirmation requirement. This meets the baseline for high schema coverage but doesn't enhance understanding.

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 ('a file or directory from the vault'), making the purpose unambiguous. However, it doesn't explicitly differentiate from sibling tools like 'obsidian_put_file' (which might handle overwrites) or 'obsidian_patch_file' (which modifies content), leaving room for improvement in sibling distinction.

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. With siblings like 'obsidian_put_file' (for creating/overwriting) and 'obsidian_patch_file' (for partial updates), there's no indication of whether deletion is irreversible or if other tools might handle file removal indirectly. This lack of context could lead to misuse.

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/ToKiDoO/mcp-obsidian-advanced'

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