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.
81 lines • 3.92 kB
TypeScript
/**
* @fileoverview obsidian_write_note — create or overwrite a note (whole file)
* or replace a single section in place via PATCH-with-replace. Idempotent.
* @module mcp-server/tools/definitions/obsidian-write-note.tool
*/
import { z } from '@cyanheads/mcp-ts-core';
import { JsonRpcErrorCode } from '@cyanheads/mcp-ts-core/errors';
export declare const obsidianWriteNote: 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">;
content: z.ZodString;
section: z.ZodOptional<z.ZodObject<{
type: z.ZodEnum<{
heading: "heading";
block: "block";
frontmatter: "frontmatter";
}>;
target: z.ZodString;
}, z.core.$strip>>;
contentType: z.ZodDefault<z.ZodEnum<{
markdown: "markdown";
json: "json";
}>>;
overwrite: z.ZodDefault<z.ZodBoolean>;
}, z.core.$strip>, z.ZodObject<{
path: z.ZodString;
sectionTargeted: z.ZodBoolean;
created: z.ZodBoolean;
previousSizeInBytes: z.ZodNumber;
currentSizeInBytes: z.ZodNumber;
}, z.core.$strip>, readonly [{
readonly reason: "file_exists";
readonly code: JsonRpcErrorCode.Conflict;
readonly when: "Whole-file write was attempted against an existing note and `overwrite` was not set to `true`.";
readonly recovery: "Retry with overwrite true or use obsidian_patch_note for in-place edits.";
}, {
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: "Section replace targets a path that does not resolve to an existing note (PATCH requires the file to exist).";
readonly recovery: "Verify the path with obsidian_list_notes, or omit `section` to fall back to whole-file write (which creates the note when it is absent).";
}, {
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: "`section` was provided but the named heading/block/frontmatter field does not exist in the note.";
readonly recovery: "Call obsidian_get_note with format document-map to discover available targets.";
}], undefined>;
//# sourceMappingURL=obsidian-write-note.tool.d.ts.map