Skip to main content
Glama

Append to Note

append_to_note

Append markdown to an existing note without altering prior content. Adds a leading newline if needed. Use for logs, lists, or sections. Note must exist—create with create_note first.

Instructions

Append text to the end of an existing note without altering prior content. By default, inserts a leading newline if the file does not already end in one, so appended content starts on its own line. Use for log entries, running lists, or adding new sections. Fails if the note does not exist — use create_note to make a new note first.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYesRelative path from vault root to the target note (e.g., 'journal/2026-04-15.md'). Extension optional.
contentYesMarkdown text to append to the end of the note. A leading newline is auto-inserted when the file does not already end in one.

Implementation Reference

  • Core implementation of appendToNote: resolves the vault path safely under lock, reads existing content, adds a newline separator if needed, and atomically writes the combined content back.
    export async function appendToNote(
      vaultPath: string,
      relativePath: string,
      content: string,
    ): Promise<void> {
      const fullPath = await resolveVaultPathSafe(vaultPath, relativePath);
      await withFileLock(fullPath, async () => {
        const existing = await fs.readFile(fullPath, "utf-8");
        const separator = existing.endsWith("\n") ? "" : "\n";
        await atomicWriteFile(fullPath, existing + separator + content);
      });
    }
  • Registration of the 'append_to_note' MCP tool on the server with input schema (path, content). The handler calls appendToNote from vault.ts.
    // 2. append_to_note
    server.registerTool(
      "append_to_note",
      {
        title: "Append to Note",
        description:
          "Append text to the end of an existing note without altering prior content. By default, inserts a leading newline if the file does not already end in one, so appended content starts on its own line. Use for log entries, running lists, or adding new sections. Fails if the note does not exist — use create_note to make a new note first.",
        annotations: {
          readOnlyHint: false,
          destructiveHint: false,
          idempotentHint: false,
          openWorldHint: false,
        },
        inputSchema: {
          path: z
            .string()
            .min(1)
            .describe("Relative path from vault root to the target note (e.g., 'journal/2026-04-15.md'). Extension optional."),
          content: z
            .string()
            .describe("Markdown text to append to the end of the note. A leading newline is auto-inserted when the file does not already end in one."),
        },
      },
      async ({ path: notePath, content }) => {
        try {
          const resolvedPath = ensureMdExtension(notePath);
          await appendToNote(vaultPath, resolvedPath, content);
          return textResult(`Appended content to '${resolvedPath}'.`);
        } catch (err) {
          log.error("append_to_note failed", { tool: "append_to_note", err: err as Error });
          return errorResult(`Error appending to note: ${sanitizeError(err)}`);
        }
      },
    );
  • Input schema for append_to_note: path (required string with .md auto-append) and content (required string to append).
    inputSchema: {
      path: z
        .string()
        .min(1)
        .describe("Relative path from vault root to the target note (e.g., 'journal/2026-04-15.md'). Extension optional."),
      content: z
        .string()
        .describe("Markdown text to append to the end of the note. A leading newline is auto-inserted when the file does not already end in one."),
    },
  • withFileLock: mutual exclusion helper that ensures serialized file access per path.
    export async function withFileLock<T>(fullPath: string, fn: () => Promise<T>): Promise<T> {
      const key = lockKey(fullPath);
      const prev = fileLocks.get(key) ?? Promise.resolve();
      // Swallow the prior holder's rejection (so the chain continues) but still
      // run `fn` exactly once via `.then()` — the previous form passed `fn` as
      // both fulfillment and rejection handler, which obscured intent.
      const next = prev.catch(() => undefined).then(fn);
      fileLocks.set(key, next);
  • atomicWriteFile: writes content to a temp file then atomically renames it, ensuring no partial writes.
    export async function atomicWriteFile(fullPath: string, content: string): Promise<void> {
      const dir = path.dirname(fullPath);
      const base = path.basename(fullPath);
      const tmp = path.join(dir, `.${base}.${process.pid}.${randomBytes(8).toString("hex")}.tmp`);
      try {
        // `wx` on the temp file guards against the astronomically unlikely case
        // of a collision with a leftover tmp from a crashed run.
        await fs.writeFile(tmp, content, { encoding: "utf-8", flag: "wx" });
        await renameWithRetry(tmp, fullPath);
      } catch (err) {
        // Best-effort cleanup: the rename failed (or writeFile did), so the tmp
        // is still on disk. Ignore ENOENT in case writeFile never created it.
        try { await fs.unlink(tmp); } catch { /* ignore */ }
        throw err;
      }
    }
Behavior4/5

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

Annotations already indicate non-readonly, non-destructive, and non-idempotent. The description adds that it inserts a leading newline conditionally and fails on missing note. It does not detail success response or error format, but these are minor omissions.

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 three sentences: purpose, key behavior, and usage guidance. It is concise, front-loaded, and every sentence adds value.

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

Completeness4/5

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

For a simple append tool with annotations covering safety and no output schema, the description is nearly complete. It explains behavior, prerequisites, and use cases. It could mention success confirmation but is sufficient.

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?

The input schema covers both parameters with descriptions, and the description adds practical examples (path example, markdown for content) and explains the auto-newline behavior. This adds 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 explicitly states the tool appends text to an existing note without altering prior content, and it distinguishes itself from siblings like prepend_to_note and create_note by mentioning use cases and prerequisites.

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

Usage Guidelines5/5

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

It clearly specifies when to use the tool (log entries, running lists, new sections) and warns that it fails if the note does not exist, directing users to create_note instead. This provides excellent guidance on alternatives.

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

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