Skip to main content
Glama
bezata

kObsidian MCP

Modify Tags

tags.modify
Idempotent

Modify the frontmatter tags list of a note in an Obsidian vault using add, remove, replace, or merge operations. Idempotent, returns the new tag list. Use with vault-relative paths.

Instructions

Mutate the frontmatter tags list of a single note. Four ops are supported: add unions the incoming tags with the existing list (duplicates dropped); remove drops any incoming tag currently present; replace overwrites the list entirely; merge is an alias for add. Leading # on incoming tags is stripped automatically. This tool only touches the frontmatter block — inline #tag occurrences in the body are left untouched. Idempotent: repeated calls with the same op and tags converge on the same result. Returns {changed, target, summary, op, tagsAfter}.

Operates on the session-active vault (see vault.current — selectable via vault.select) unless an explicit vaultPath argument is passed, which always wins.

Examples:

Example 1 — Add two tags to a note (idempotent):

{
  "path": "Projects/Alpha.md",
  "op": "add",
  "tags": [
    "in-progress",
    "priority/high"
  ]
}

Example 2 — Replace a note's entire tag set:

{
  "path": "Inbox/today.md",
  "op": "replace",
  "tags": [
    "processed"
  ]
}

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYesVault-relative note path to mutate.
opYesThe mutation to apply to the note's frontmatter `tags` field: - `add` — union existing + incoming (duplicates dropped). - `remove` — drop any incoming tag that currently exists. - `replace` — overwrite the tag list entirely with `tags`. - `merge` — alias for `add` (kept for naming clarity; behaves identically).
tagsYesTags to add/remove/replace with. Leading `#` is stripped automatically. Max 50 per call.
vaultPathNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
changedYes
targetYes
summaryYes
opYesThe mutation to apply to the note's frontmatter `tags` field: - `add` — union existing + incoming (duplicates dropped). - `remove` — drop any incoming tag that currently exists. - `replace` — overwrite the tag list entirely with `tags`. - `merge` — alias for `add` (kept for naming clarity; behaves identically).
tagsBeforeNo
tagsAfterYesThe full tag list after the mutation.

Implementation Reference

  • Main handler for 'tags.modify' tool. Parses args, dispatches to addTags/removeTags/updateTags based on the 'op' field, and returns the result with tagsAfter.
    handler: async (context, rawArgs) => {
      const args = tagsModifyArgsSchema.parse(rawArgs) as TagsModifyArgs;
      const mutationArgs = { path: args.path, tags: args.tags, vaultPath: args.vaultPath };
      if (args.op === "add" || args.op === "merge") {
        const result = await addTags(context, mutationArgs);
        return { ...result, op: args.op, tagsAfter: result.allTags };
      }
      if (args.op === "remove") {
        const result = await removeTags(context, mutationArgs);
        return { ...result, op: args.op, tagsAfter: result.remainingTags };
      }
      const result = await updateTags(context, { ...mutationArgs, merge: false });
      return { ...result, op: args.op, tagsAfter: result.newTags };
    },
  • Input schema for tags.modify: path, op (add/remove/replace/merge), tags array, optional vaultPath.
    export const tagsModifyArgsSchema = z
      .object({
        path: notePathSchema.describe("Vault-relative note path to mutate."),
        op: tagModifyOpSchema,
        tags: tagsSchema.describe(
          "Tags to add/remove/replace with. Leading `#` is stripped automatically. Max 50 per call.",
        ),
        vaultPath: z.string().optional(),
      })
      .strict()
      .describe("Arguments for `tags.modify`.");
    export type TagsModifyArgs = z.input<typeof tagsModifyArgsSchema>;
  • Output schema for tags.modify: changed, target, summary, op, tagsBefore (optional), tagsAfter.
    export const tagsModifyOutputSchema = z
      .object({
        changed: z.boolean(),
        target: z.string(),
        summary: z.string(),
        op: tagModifyOpSchema,
        tagsBefore: z.array(z.string()).optional(),
        tagsAfter: z.array(z.string()).describe("The full tag list after the mutation."),
      })
      .passthrough();
  • Enum schema for the operation type: add, remove, replace, merge.
    export const tagModifyOpSchema = z
      .enum(["add", "remove", "replace", "merge"])
      .describe(
        [
          "The mutation to apply to the note's frontmatter `tags` field:",
          "- `add`     — union existing + incoming (duplicates dropped).",
          "- `remove`  — drop any incoming tag that currently exists.",
          "- `replace` — overwrite the tag list entirely with `tags`.",
          "- `merge`   — alias for `add` (kept for naming clarity; behaves identically).",
        ].join(" "),
      );
  • Registers tagTools (including tags.modify) into the tool registry via spread operator.
    export const toolRegistry: ToolDefinition[] = [
      ...vaultTools,
      ...noteTools,
      ...tagTools,
      ...linkTools,
      ...analyticsTools,
      ...taskTools,
      ...dataviewTools,
      ...blocksTools,
      ...marpTools,
      ...kanbanTools,
      ...canvasTools,
      ...templateTools,
      ...apiTools,
      ...wikiTools,
      ...systemTools,
    ];
Behavior4/5

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

Annotations already provide idempotentHint=true and destructiveHint=false. The description adds valuable behavior details: idempotence, automatic stripping of leading '#', scoping to frontmatter only, and session vault behavior, which go beyond annotations.

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 concise (around 150 words) and well-structured: purpose first, then details, then examples. Every sentence adds value, and the examples clarify usage efficiently.

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

Completeness5/5

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

Given the tool's complexity (4 ops, optional vaultPath, idempotence, return fields), the description covers all necessary aspects. It mentions return fields {changed, target, summary, op, tagsAfter}, compensating for the not-shown output schema.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 75% (vaultPath lacks description), but the description compensates by explaining vaultPath's role, the meanings of each op, and constraints like max 50 tags. This adds significant value beyond the schema.

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 uses specific verbs like 'mutate', 'add', 'remove', 'replace', and 'merge', clearly stating it modifies the frontmatter tags list of a single note. It distinguishes itself from sibling tools like tags.analyze, tags.list, and tags.search by being a mutation tool.

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 provides clear context: it operates on the session-active vault unless vaultPath is specified, and it only touches frontmatter. However, it does not explicitly state when not to use this tool or mention alternatives among siblings.

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/bezata/kObsidian'

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