Skip to main content
Glama
yuchi-chang

obsidian-mcp

by yuchi-chang

Bulk rename a tag

obsidian_rename_tag
Destructive

Replace all instances of an existing tag with a new tag across your entire Obsidian vault.

Instructions

Renames a tag across every note in the vault.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
vaultNoVault name to target. Optional — defaults to the most recently focused vault.
oldYesExisting tag name (e.g. '#old').
newYesNew tag name (e.g. '#new').
confirmNoSet to true to skip the interactive confirmation prompt. Use only when the caller has already confirmed with the user.

Implementation Reference

  • Input schema for obsidian_rename_tag: requires 'old' (existing tag) and 'new' (new tag) strings, both with min length 1, plus optional VaultArg and ConfirmArg.
    inputSchema: {
      ...VaultArg,
      old: z.string().min(1).describe("Existing tag name (e.g. '#old')."),
      new: z.string().min(1).describe("New tag name (e.g. '#new')."),
      ...ConfirmArg,
    },
  • Handler calls runText with command 'tags:rename' passing vault, old tag, and new tag.
    handler: async ({ vault, old, new: newTag }) =>
      runText("tags:rename", { vault, params: { old, new: newTag } }),
  • src/tools.ts:589-606 (registration)
    Full tool registration with name 'obsidian_rename_tag', destructivelyHinted, with confirmation prompt config.
    {
      name: "obsidian_rename_tag",
      title: "Bulk rename a tag",
      description: "Renames a tag across every note in the vault.",
      inputSchema: {
        ...VaultArg,
        old: z.string().min(1).describe("Existing tag name (e.g. '#old')."),
        new: z.string().min(1).describe("New tag name (e.g. '#new')."),
        ...ConfirmArg,
      },
      annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: false },
      confirm: {
        action: () => "Rename a tag across the entire vault",
        detail: ({ old, new: newTag }) => `${old} → ${newTag}`,
      },
      handler: async ({ vault, old, new: newTag }) =>
        runText("tags:rename", { vault, params: { old, new: newTag } }),
    },
  • Helper runText executes the Obsidian CLI command and returns trimmed output as text result.
    async function runText(
      command: string,
      opts: Parameters<typeof runObsidian>[1] = {},
    ): Promise<McpToolResult> {
      try {
        const result = await runObsidian(command, opts);
        const text = result.stdout.trim() || result.stderr.trim() || "(no output)";
        return textResult(text);
      } catch (err) {
        return errorResult(err);
      }
    }
  • runObsidian executes the Obsidian CLI binary with built arguments, used by runText to invoke 'tags:rename'.
    export async function runObsidian(
      command: string,
      opts: RunOptions = {},
    ): Promise<RunResult> {
      const bin = process.env.OBSIDIAN_CLI ?? "obsidian";
      const args = buildArgs(command, opts);
      const cmdline = [bin, ...args].map(shellQuote).join(" ");
    
      try {
        const { stdout, stderr } = await exec(cmdline, {
          maxBuffer: 64 * 1024 * 1024,
          windowsHide: true,
        });
        return { stdout, stderr, exitCode: 0, command: cmdline };
      } catch (err: unknown) {
        const e = err as NodeJS.ErrnoException & {
          stdout?: string;
          stderr?: string;
          code?: number | string;
        };
        const result: RunResult = {
          stdout: e.stdout ?? "",
          stderr: e.stderr ?? e.message ?? "",
          exitCode: typeof e.code === "number" ? e.code : 1,
          command: cmdline,
        };
        if (e.code === "ENOENT") {
          throw new ObsidianCliError(
            `Obsidian CLI binary not found ('${bin}'). ` +
              `Make sure Obsidian is running and the CLI is registered ` +
              `(Settings → General → Command line interface → Register CLI). ` +
              `Override with the OBSIDIAN_CLI env var if the binary lives elsewhere.`,
            result,
          );
        }
        throw new ObsidianCliError(
          `obsidian CLI exited with code ${result.exitCode}: ${result.stderr.trim() || result.stdout.trim()}`,
          result,
Behavior3/5

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

The description adds no behavioral context beyond what annotations already provide (destructiveHint=true, readOnlyHint=false). It does not mention the confirmation prompt or potential merging behavior. With annotations covering the safety profile, a score of 3 is appropriate.

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?

The description is a single, front-loaded sentence with no wasted words. It conveys the essential purpose efficiently.

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

Completeness2/5

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

Despite having 4 parameters and being a destructive tool, the description is minimal and lacks details on the confirm parameter behavior, tag formatting, or side effects. Given no output schema, the description should provide more context.

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 100%, with all four parameters having descriptions. The description does not add additional meaning beyond the schema, meeting the baseline score of 3.

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 that the tool renames a tag across every note in the vault, specifying the action (rename) and the resource (tag) with a clear scope (across every note). This distinguishes it from sibling tools like obsidian_files_with_tag or obsidian_list_tags.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives, such as checking existing tags with obsidian_list_tags or previewing changes with obsidian_files_with_tag. No prerequisites, exclusions, or recommendations are mentioned.

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

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