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)

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