Skip to main content
Glama
jagoff

obsidian-mcp-complete

by jagoff

obsidian_batch_rename

Batch rename or move notes in an Obsidian vault, with automatic link updates. Perform a dry run to preview changes before applying.

Instructions

Batch move/rename notes with optional incoming link updates. Dry-run by default.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
vaultNoOptional configured vault name. Defaults to the server default vault.
movesYes
dryRunNo
overwriteNo
updateLinksNo

Implementation Reference

  • src/tools.ts:597-608 (registration)
    Registration of the 'obsidian_batch_rename' tool with its schema and handler, which delegates to the batchRename function from ops.ts.
    tool(
      "obsidian_batch_rename",
      "Batch move/rename notes with optional incoming link updates. Dry-run by default.",
      {
        vault: vaultArg,
        moves: z.array(z.object({ from: z.string(), to: z.string() })).min(1).max(500),
        dryRun: z.boolean().optional().default(true),
        overwrite: z.boolean().optional().default(false),
        updateLinks: z.boolean().optional().default(true),
      },
      async (args) => batchRename(vaults, args.vault, args.moves, args),
    );
  • Zod schema for obsidian_batch_rename: vault (optional), moves (array of {from, to}, min 1 max 500), dryRun (default true), overwrite (default false), updateLinks (default true).
    {
      vault: vaultArg,
      moves: z.array(z.object({ from: z.string(), to: z.string() })).min(1).max(500),
      dryRun: z.boolean().optional().default(true),
      overwrite: z.boolean().optional().default(false),
      updateLinks: z.boolean().optional().default(true),
    },
  • The actual batchRename handler function. Iterates over moves, calls vaults.move() for each, optionally updates links via updateLinksAcrossVault, and supports dry-run mode.
    export async function batchRename(
      vaults: VaultManager,
      vault: string | undefined,
      moves: Array<{ from: string; to: string }>,
      options: { dryRun?: boolean; overwrite?: boolean; updateLinks?: boolean } = {},
    ): Promise<{ dryRun: boolean; moves: Array<{ from: string; to: string; ok: boolean; error?: string }>; rewrites: Array<{ path: string; changed: number; preview?: string }> }> {
      const results = [];
      const rewrites = [];
      for (const move of moves) {
        try {
          if (!options.dryRun) {
            const result = await vaults.move(vaults.notePath(move.from), vaults.notePath(move.to), vault, { overwrite: options.overwrite });
            results.push({ ...result, ok: true });
            if (options.updateLinks !== false) {
              rewrites.push(...await updateLinksAcrossVault(vaults, vault, result.from, result.to, { dryRun: false }));
            }
          } else {
            vaults.resolvePath(vaults.notePath(move.from), vault);
            vaults.resolvePath(vaults.notePath(move.to), vault);
            results.push({ from: vaults.notePath(move.from), to: vaults.notePath(move.to), ok: true });
            if (options.updateLinks !== false) {
              rewrites.push(...await updateLinksAcrossVault(vaults, vault, vaults.notePath(move.from), vaults.notePath(move.to), { dryRun: true }));
            }
          }
        } catch (error) {
          results.push({ from: move.from, to: move.to, ok: false, error: error instanceof Error ? error.message : String(error) });
        }
      }
      return { dryRun: options.dryRun ?? true, moves: results, rewrites };
    }
  • updateLinksAcrossVault is the helper used by batchRename to rewrite wiki-links and markdown links referencing the old path to the new path across all markdown files.
    export async function updateLinksAcrossVault(
      vaults: VaultManager,
      vault: string | undefined,
      fromPath: string,
      toPath: string,
      options: { dryRun?: boolean } = {},
    ): Promise<Array<{ path: string; changed: number; preview?: string }>> {
      const files = await vaults.markdownFiles(vault);
      const fromNoExt = fromPath.replace(/\.md$/i, "");
      const fromBase = path.posix.basename(fromNoExt);
      const toNoExt = toPath.replace(/\.md$/i, "");
      const rewrites: Array<{ path: string; changed: number; preview?: string }> = [];
      for (const file of files) {
        const read = await vaults.readText(file, vault);
        let changed = 0;
        let next = read.text.replace(/(!?)\[\[([^\]\n]+)\]\]/g, (full, embed: string, inner: string) => {
          const [targetAndSection, display] = inner.split("|", 2);
          const sectionMatch = /([#^].*)$/.exec(targetAndSection);
          const section = sectionMatch?.[1] ?? "";
          const target = targetAndSection.replace(/[#^].*$/, "").trim().replace(/\.md$/i, "");
          if (target !== fromNoExt && target !== fromBase && target !== fromPath) return full;
          changed += 1;
          return `${embed}[[${toNoExt}${section}${display ? `|${display}` : ""}]]`;
        });
        next = next.replace(/\[([^\]\n]+)\]\(([^)\n]+)\)/g, (full, label: string, target: string) => {
          const clean = decodeURIComponent(target).replace(/^\.\//, "");
          if (clean !== fromPath && clean !== fromNoExt && clean !== `${fromNoExt}.md`) return full;
          changed += 1;
          return `[${label}](${encodeURI(toPath)})`;
        });
        if (changed > 0) {
          rewrites.push({ path: read.path, changed, preview: options.dryRun ? previewDiff(read.text, next) : undefined });
          if (!options.dryRun) await vaults.writeText(read.path, next, vault, { overwrite: true });
        }
      }
      return rewrites;
    }
  • Import of batchRename from ops.ts into tools.ts.
    import { batchRename, deleteFolder, pruneEmptyDirs, regexReplaceAcrossVault, updateLinksAcrossVault } from "./ops.js";
Behavior3/5

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

Annotations are all false but description adds that dry-run is default, which is helpful. However, it does not disclose behavior on overwrite conflicts or whether changes are reversible.

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 sentences, front-loaded with action, no fluff.

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; description does not explain return values or error behavior for batch operations. Sufficient for basic use but lacking for complex scenarios.

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 low (20%). Description adds context for moves and link updates but fails to explain vault, overwrite, and dryRun beyond their defaults.

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 'Batch move/rename notes with optional incoming link updates', which distinguishes it from single-move tools like obsidian_move_note and update links tools.

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

Usage Guidelines3/5

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

The description implies usage for batch renaming but does not explicitly state when to use versus alternatives or provide exclusion criteria.

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