Skip to main content
Glama

patchNote

Insert or modify content in Obsidian notes relative to headings, block references, or frontmatter fields. Choose append, prepend, or replace operations for precise updates.

Instructions

Inserts content into an existing note relative to a heading, block reference, or frontmatter field.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
contentYesContent to be inserted or used for replacement
contentTypeNo
operationYesOperation to perform (append, prepend, or replace)
pathYes
targetYesTarget identifier - For heading: Use a heading path string. For nested headings, use '::' as a delimiter (e.g., '## Heading 1 ### Subheading 1' must be 'Heading 1::Subheading 1'). The path should match the exact heading text. For headings with special characters, use URL encoding. - For block: Use the block ID (e.g., '2d9b4a'). - For frontmatter: Use the frontmatter field name (e.g., 'tags', 'date', 'title').
targetDelimiterNo
targetTypeYesType of target to patch (heading, block, or frontmatter)
trimTargetWhitespaceNo

Implementation Reference

  • The createPatchNoteTool function returns the ToolHandler that implements the patchNote tool logic by calling the ObsidianAPI.patchNote method.
    export function createPatchNoteTool(api: ObsidianAPI): ToolHandler { return async (params: { path: string; operation: "append" | "prepend" | "replace"; targetType: "heading" | "block" | "frontmatter"; target: string; content: string; targetDelimiter?: string; trimTargetWhitespace?: boolean; contentType?: string; }): Promise<ToolResponse> => { try { const { path, content, ...patchOptions } = params; await api.patchNote(path, content, patchOptions as PatchNoteOptions); return formatSuccessResponse({ success: true, message: "Note patched successfully" }); } catch (error) { return formatErrorResponse(`Error patching note: ${(error as Error).message}`); } }; }
  • Zod schema defining the input parameters for the patchNote tool.
    export const PatchNoteSchema = { path: z.string().min(1, "Note path is required"), operation: z.enum(["append", "prepend", "replace"], { description: "Operation to perform (append, prepend, or replace)", }), targetType: z.enum(["heading", "block", "frontmatter"], { description: "Type of target to patch (heading, block, or frontmatter)", }), target: z .string() .min(1, "Target is required") .describe(`Target identifier - For heading: Use a heading path string. For nested headings, use '::' as a delimiter (e.g., '## Heading 1 ### Subheading 1' must be 'Heading 1::Subheading 1'). The path should match the exact heading text. For headings with special characters, use URL encoding. - For block: Use the block ID (e.g., '2d9b4a'). - For frontmatter: Use the frontmatter field name (e.g., 'tags', 'date', 'title').`), content: z .string() .min(1, "Content is required") .describe("Content to be inserted or used for replacement"), targetDelimiter: z.string().optional(), trimTargetWhitespace: z.boolean().optional(), contentType: z.string().optional(), };
  • src/server.ts:72-76 (registration)
    Registration of the patchNote tool with the MCP server using its definition and handler factory.
    patchNoteDefinition.name, patchNoteDefinition.description, patchNoteDefinition.schema, createPatchNoteTool(this.api) );
  • TypeScript interface defining the options for patching a note, used in the tool handler.
    export interface PatchNoteOptions { operation: "append" | "prepend" | "replace"; // Patch operation to perform; required targetType: "heading" | "block" | "frontmatter"; // Type of target to patch; required target: string; // Target to patch (URL-Encoded if needed); required targetDelimiter?: string; // Delimiter to use for nested targets (i.e. Headings); optional (default "::") trimTargetWhitespace?: boolean; // Trim whitespace from Target before applying patch?; optional (default "false") contentType?: string; // Content-Type header used for request body; optional (default "text/markdown") }
  • ToolDefinition object for patchNote, including name, description, and schema reference.
    export const patchNoteDefinition: ToolDefinition = { name: "patchNote", description: "Inserts content into an existing note relative to a heading, block reference, or frontmatter field.", schema: PatchNoteSchema };

Other Tools

Related 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/takuya0206/obsidian-mcp'

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