Skip to main content
Glama
jagoff

obsidian-mcp-complete

by jagoff

obsidian_delete_folder

Destructive

Delete a folder from an Obsidian vault with dry-run preview and confirmation required for permanent removal, or move it to trash.

Instructions

Delete a folder recursively or move it to .trash/mcp. Dry-run by default and confirmation is required for real deletes.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
vaultNoOptional configured vault name. Defaults to the server default vault.
folderYes
dryRunNo
permanentNo
confirmationNo

Implementation Reference

  • src/tools.ts:623-635 (registration)
    Tool registration for 'obsidian_delete_folder'. Defines the schema (folder, dryRun, permanent, confirmation) and delegates to the deleteFolder() handler from ops.ts.
    tool(
      "obsidian_delete_folder",
      "Delete a folder recursively or move it to .trash/mcp. Dry-run by default and confirmation is required for real deletes.",
      {
        vault: vaultArg,
        folder: z.string(),
        dryRun: z.boolean().optional().default(true),
        permanent: z.boolean().optional().default(false),
        confirmation: z.string().optional(),
      },
      async (args) => deleteFolder(vaults, args.vault, args.folder, args),
      { destructiveHint: true },
    );
  • Zod schema for the obsidian_delete_folder tool: vault (optional), folder (required), dryRun (optional, default true), permanent (optional, default false), confirmation (optional).
    {
      vault: vaultArg,
      folder: z.string(),
      dryRun: z.boolean().optional().default(true),
      permanent: z.boolean().optional().default(false),
      confirmation: z.string().optional(),
    },
  • The core deleteFolder() handler. Validates folder exists, checks directory, enforces confirmation for real deletes, counts entries, then either dry-runs, permanently deletes (fs.rm recursive), or moves to .trash/mcp with timestamp.
    export async function deleteFolder(
      vaults: VaultManager,
      vault: string | undefined,
      folder: string,
      options: { dryRun?: boolean; permanent?: boolean; confirmation?: string } = {},
    ): Promise<{ folder: string; entries: number; dryRun: boolean; deleted: boolean; trashPath?: string }> {
      vaults.assertWritable();
      const resolved = vaults.resolvePath(folder, vault);
      if (!fssync.existsSync(resolved.absolute)) throw new Error(`Folder does not exist: ${resolved.relative}`);
      const stat = await fs.stat(resolved.absolute);
      if (!stat.isDirectory()) throw new Error(`Path is not a directory: ${resolved.relative}`);
      if (!options.dryRun && options.confirmation !== resolved.relative && options.confirmation !== "DELETE") {
        throw new Error(`Confirmation must equal "${resolved.relative}" or "DELETE"`);
      }
      const entries = await countEntries(resolved.absolute);
      if (options.dryRun) return { folder: resolved.relative, entries, dryRun: true, deleted: false };
      if (options.permanent) {
        await fs.rm(resolved.absolute, { recursive: true, force: false });
        return { folder: resolved.relative, entries, dryRun: false, deleted: true };
      }
      const stamp = new Date().toISOString().replace(/[:.]/g, "-");
      const trashRel = `.trash/mcp/${stamp}-${path.basename(resolved.relative)}`;
      const trash = vaults.resolvePath(trashRel, resolved.vault.name);
      await fs.mkdir(path.dirname(trash.absolute), { recursive: true });
      await fs.rename(resolved.absolute, trash.absolute);
      return { folder: resolved.relative, entries, dryRun: false, deleted: true, trashPath: trash.relative };
    }
  • Helper function countEntries() used by deleteFolder to recursively count files/folders in the target directory for the dry-run summary.
    async function countEntries(dir: string): Promise<number> {
      let count = 0;
      for (const entry of await fs.readdir(dir, { withFileTypes: true })) {
        count += 1;
        if (entry.isDirectory()) count += await countEntries(path.join(dir, entry.name));
      }
      return count;
    }
  • src/tools.ts:28-28 (registration)
    Import of deleteFolder from './ops.js' in the tools.ts registration file.
    import { batchRename, deleteFolder, pruneEmptyDirs, regexReplaceAcrossVault, updateLinksAcrossVault } from "./ops.js";
Behavior5/5

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

Beyond destructiveHint annotation, description details dry-run default and confirmation requirement. It also explains alternative of moving to .trash/mcp, adding valuable behavioral context.

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?

Two concise sentences front-load the primary action, with no wasted words. Every sentence adds value.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

No output schema, and description doesn't cover return values, vault defaults, or the exact interplay between parameters. Adequate for basic understanding but leaves gaps for a 5-parameter tool.

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 coverage is only 20%, and description adds meaning only for dryRun and confirmation, not explaining permanent parameter or interactive flow. Adequate but not comprehensive.

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 action (delete or move to trash) and resource (folder), distinguishing it from siblings like obsidian_delete_note which targets single notes.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description mentions dry-run by default and confirmation requirement, guiding safe usage. It doesn't explicitly state when not to use, but context is clear.

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

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