Skip to main content
Glama

delete_note

Remove notes from your Obsidian vault by moving them to trash or deleting permanently to manage your knowledge base and maintain organized content.

Instructions

Delete a note (moves to .trash by default)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYes
permanentNo

Implementation Reference

  • MCP tool handler for 'delete_note' that validates input and calls the vault's delete_note method, handling errors and returning formatted responses.
    @mcp.tool(name="delete_note", description="Delete a note (moves to .trash by default)") def delete_note(path: str, permanent: bool = False) -> str: """ Delete a note from the vault. Args: path: Relative path to the note permanent: If true, permanently delete; otherwise move to .trash folder Returns: Success message """ if not path or not path.strip(): return "Error: Path cannot be empty" if len(path) > 1000: return "Error: Path too long" context = _get_context() try: context.vault.delete_note(path, use_trash=not permanent) if permanent: return f"✓ Permanently deleted note: {path}" else: return f"✓ Moved note to trash: {path}" except FileNotFoundError: return f"Error: Note not found: {path}" except VaultSecurityError as e: return f"Error: Security violation: {e}" except Exception as e: logger.exception(f"Error deleting note {path}") return f"Error deleting note: {e}"
  • Core implementation of note deletion in ObsidianVault class, either moving to .trash or permanent delete with path validation.
    def delete_note(self, relative_path: str, use_trash: bool = True) -> None: """ Delete a note from the vault. Args: relative_path: Path to the note use_trash: If True, move to .trash folder instead of permanent delete Raises: VaultSecurityError: If path is invalid FileNotFoundError: If note doesn't exist """ file_path = self._validate_path(relative_path) if not file_path.exists(): raise FileNotFoundError(f"Note not found: {relative_path}") if use_trash: # Move to .trash folder at vault root trash_dir = self.vault_path / ".trash" trash_dir.mkdir(exist_ok=True) # Create unique name if needed trash_path = trash_dir / file_path.name counter = 1 while trash_path.exists(): name_parts = file_path.stem, counter, file_path.suffix trash_path = trash_dir / f"{name_parts[0]}.{name_parts[1]}{name_parts[2]}" counter += 1 # Move file file_path.rename(trash_path) logger.info(f"Moved to trash: {relative_path} -> {trash_path.name}") else: # Permanent delete file_path.unlink() logger.info(f"Deleted note: {relative_path}")
  • MCP tool registration decorator for the delete_note tool.
    @mcp.tool(name="delete_note", description="Delete a note (moves to .trash by default)")

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/getglad/obsidian_mcp'

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