obsidian_delete_note
Move an Obsidian note to the .trash/mcp folder or permanently delete it. Requires explicit confirmation to prevent accidental loss.
Instructions
Move a note to .trash/mcp or permanently delete it. Requires OBSIDIAN_ENABLE_DELETE=1 and confirmation.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| vault | No | Optional configured vault name. Defaults to the server default vault. | |
| path | Yes | Vault-relative path. Absolute paths and traversal are rejected. | |
| confirmation | Yes | ||
| permanent | No |
Implementation Reference
- src/tools.ts:611-621 (registration)Registration of the 'obsidian_delete_note' tool with schema and handler delegating to vaults.trash()
"obsidian_delete_note", "Move a note to .trash/mcp or permanently delete it. Requires OBSIDIAN_ENABLE_DELETE=1 and confirmation.", { vault: vaultArg, path: pathArg, confirmation: z.string(), permanent: z.boolean().optional().default(false), }, async (args) => vaults.trash(vaults.notePath(args.path), args.vault, args), { destructiveHint: true }, ); - src/vault.ts:167-192 (handler)Core handler vaults.trash() that resolves path, validates confirmation, and either permanently deletes or moves to .trash/mcp/
async trash( notePath: string, vaultName?: string | null, options: { permanent?: boolean; confirmation?: string } = {}, ): Promise<{ deleted: boolean; path: string; trashPath?: string; permanent: boolean }> { this.assertWritable(); if (!this.config.enableDelete) { throw new Error("Delete is disabled. Set OBSIDIAN_ENABLE_DELETE=1 to enable this tool."); } const resolved = this.resolvePath(notePath, vaultName); if (options.confirmation !== resolved.relative && options.confirmation !== "DELETE") { throw new Error(`Confirmation must equal "${resolved.relative}" or "DELETE"`); } if (options.permanent) { await fs.unlink(resolved.absolute); this.onInvalidate?.(resolved.vault.name); return { deleted: true, path: resolved.relative, permanent: true }; } const stamp = new Date().toISOString().replace(/[:.]/g, "-"); const trashRel = `.trash/mcp/${stamp}-${path.basename(resolved.relative)}`; const trashAbs = path.join(resolved.vault.root, trashRel); await fs.mkdir(path.dirname(trashAbs), { recursive: true }); await fs.rename(resolved.absolute, trashAbs); this.onInvalidate?.(resolved.vault.name); return { deleted: true, path: resolved.relative, trashPath: trashRel, permanent: false }; } - src/tools.ts:613-618 (schema)Input schema for obsidian_delete_note: vault (optional), path (required), confirmation, and permanent
{ vault: vaultArg, path: pathArg, confirmation: z.string(), permanent: z.boolean().optional().default(false), }, - src/config.ts:12-12 (helper)enableDelete config flag gates delete tool access
enableDelete: boolean; - src/config.ts:103-103 (helper)enableDelete set from OBSIDIAN_ENABLE_DELETE env var
enableDelete: truthy(env.OBSIDIAN_ENABLE_DELETE),