obsidian-mcp-server
Version:
MCP server for Obsidian vaults — read, write, search, and surgically edit notes, tags, and frontmatter via the Local REST API plugin. STDIO or Streamable HTTP.
102 lines • 4.62 kB
TypeScript
/**
* @fileoverview obsidian_patch_note — surgical edit (`append` / `prepend` /
* `replace`) of a heading, block reference, or frontmatter field. Uses the
* upstream Local REST API v3 PATCH protocol.
* @module mcp-server/tools/definitions/obsidian-patch-note.tool
*/
import { z } from '@cyanheads/mcp-ts-core';
import { JsonRpcErrorCode } from '@cyanheads/mcp-ts-core/errors';
export declare const obsidianPatchNote: import("@cyanheads/mcp-ts-core").ToolDefinition<z.ZodObject<{
target: z.ZodDiscriminatedUnion<[z.ZodObject<{
type: z.ZodLiteral<"path">;
path: z.ZodString;
}, z.core.$strip>, z.ZodObject<{
type: z.ZodLiteral<"active">;
}, z.core.$strip>, z.ZodObject<{
type: z.ZodLiteral<"periodic">;
period: z.ZodEnum<{
daily: "daily";
weekly: "weekly";
monthly: "monthly";
quarterly: "quarterly";
yearly: "yearly";
}>;
date: z.ZodOptional<z.ZodString>;
}, z.core.$strip>], "type">;
section: z.ZodObject<{
type: z.ZodEnum<{
heading: "heading";
block: "block";
frontmatter: "frontmatter";
}>;
target: z.ZodString;
}, z.core.$strip>;
operation: z.ZodEnum<{
replace: "replace";
append: "append";
prepend: "prepend";
}>;
content: z.ZodString;
contentType: z.ZodDefault<z.ZodEnum<{
markdown: "markdown";
json: "json";
}>>;
patchOptions: z.ZodOptional<z.ZodObject<{
createTargetIfMissing: z.ZodDefault<z.ZodBoolean>;
applyIfContentPreexists: z.ZodDefault<z.ZodBoolean>;
trimTargetWhitespace: z.ZodDefault<z.ZodBoolean>;
}, z.core.$strip>>;
}, z.core.$strip>, z.ZodObject<{
path: z.ZodString;
section: z.ZodObject<{
type: z.ZodEnum<{
heading: "heading";
block: "block";
frontmatter: "frontmatter";
}>;
target: z.ZodString;
}, z.core.$strip>;
operation: z.ZodEnum<{
replace: "replace";
append: "append";
prepend: "prepend";
}>;
previousSizeInBytes: z.ZodNumber;
currentSizeInBytes: z.ZodNumber;
}, z.core.$strip>, readonly [{
readonly reason: "path_forbidden";
readonly code: JsonRpcErrorCode.Forbidden;
readonly when: "The target path is outside OBSIDIAN_WRITE_PATHS, or OBSIDIAN_READ_ONLY=true denies all writes.";
readonly recovery: "Use a path inside the configured write scope. The error data echoes the active scope.";
}, {
readonly reason: "note_missing";
readonly code: JsonRpcErrorCode.NotFound;
readonly when: "The vault path does not resolve to an existing note.";
readonly recovery: "Verify the path with obsidian_list_notes or use obsidian_search_notes to locate the note.";
}, {
readonly reason: "no_active_file";
readonly code: JsonRpcErrorCode.NotFound;
readonly when: "Target was `active` but no file is currently open in Obsidian.";
readonly recovery: "Call obsidian_open_in_ui to focus a file, or pass an explicit path target instead.";
}, {
readonly reason: "periodic_not_found";
readonly code: JsonRpcErrorCode.NotFound;
readonly when: "Target was `periodic` but no matching periodic note exists.";
readonly recovery: "Create the periodic note first or pass an explicit path target.";
}, {
readonly reason: "periodic_disabled";
readonly code: JsonRpcErrorCode.ValidationError;
readonly when: "Target was `periodic` but the requested period is not enabled in Obsidian's Periodic Notes plugin settings.";
readonly recovery: "Pass an explicit path target — the requested period is disabled in the operator's Periodic Notes plugin.";
}, {
readonly reason: "section_target_missing";
readonly code: JsonRpcErrorCode.ValidationError;
readonly when: "The named heading/block/frontmatter field does not exist in the note. Use `obsidian_get_note` with `format: \"document-map\"` to discover available targets.";
readonly recovery: "Call obsidian_get_note with format document-map to discover the available targets.";
}, {
readonly reason: "content_preexists";
readonly code: JsonRpcErrorCode.ValidationError;
readonly when: "The supplied content already appears at the target — the patch was rejected to keep retries idempotent (the default).";
readonly recovery: "Pass `patchOptions.applyIfContentPreexists: true` to force-apply over preexisting content, or change the content to something not already present.";
}], undefined>;
//# sourceMappingURL=obsidian-patch-note.tool.d.ts.map