append_to_note
Append text content to an existing Markdown note in your Obsidian vault. Specify the note path and content to add, enabling efficient note augmentation without opening Obsidian.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | ||
| content | Yes |
Implementation Reference
- src/tools/append-to-note.ts:5-21 (registration)Registers the 'append_to_note' tool on the MCP server with a Zod schema for 'path' (string, min 1) and 'content' (string, min 1) inputs. The handler calls appendToNote() from vault and returns the result as JSON.
export function register(server: McpServer): void { server.registerTool( "append_to_note", { inputSchema: { path: z.string().min(1), content: z.string().min(1), }, }, async ({ path, content }) => { const result = await appendToNote(path, content); return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }], }; }, ); } - src/tools/append-to-note.ts:6-12 (schema)Input schema definition for the 'append_to_note' tool: 'path' (string, min 1) and 'content' (string, min 1), using Zod validation.
server.registerTool( "append_to_note", { inputSchema: { path: z.string().min(1), content: z.string().min(1), }, - src/tools/append-to-note.ts:14-19 (handler)Handler function that receives validated 'path' and 'content', calls the vault-level appendToNote() function, and returns the result serialized as JSON text.
async ({ path, content }) => { const result = await appendToNote(path, content); return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }], }; }, - src/vault/notes.ts:138-153 (helper)Core appendToNote implementation: resolves the path with .md extension, checks existence, appends content (with leading newline if needed) using fs.appendFile, and returns {path, appended: true}.
export async function appendToNote(relativePath: string, content: string) { const finalPath = ensureMdExtension(relativePath); const fullPath = resolveVaultPath(finalPath); if (!(await pathExists(fullPath))) { throw new Error(`Note not found: ${finalPath}`); } const prefix = content.startsWith("\n") ? "" : "\n"; await fs.appendFile(fullPath, `${prefix}${content}`, "utf-8"); return { path: finalPath, appended: true, }; } - src/server.ts:5-5 (registration)Imports the append-to-note tool module in the server.
import * as appendToNote from "./tools/append-to-note.js";