obsidian-mcp-server 3.2.9 → 3.2.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. package/AGENTS.md +19 -12
  2. package/CLAUDE.md +19 -12
  3. package/Dockerfile +11 -7
  4. package/README.md +6 -3
  5. package/changelog/3.2.x/3.2.10.md +47 -0
  6. package/changelog/3.2.x/3.2.11.md +29 -0
  7. package/changelog/template.md +5 -3
  8. package/dist/index.js +1 -1
  9. package/dist/index.js.map +1 -1
  10. package/dist/mcp-server/resources/definitions/index.d.ts +25 -20
  11. package/dist/mcp-server/resources/definitions/index.d.ts.map +1 -1
  12. package/dist/mcp-server/resources/definitions/obsidian-vault-note.resource.d.ts +5 -0
  13. package/dist/mcp-server/resources/definitions/obsidian-vault-note.resource.d.ts.map +1 -1
  14. package/dist/mcp-server/resources/definitions/obsidian-vault-note.resource.js +6 -0
  15. package/dist/mcp-server/resources/definitions/obsidian-vault-note.resource.js.map +1 -1
  16. package/dist/mcp-server/tools/definitions/_shared/schemas.d.ts +3 -3
  17. package/dist/mcp-server/tools/definitions/_shared/schemas.js +1 -1
  18. package/dist/mcp-server/tools/definitions/_shared/schemas.js.map +1 -1
  19. package/dist/mcp-server/tools/definitions/index.d.ts +333 -219
  20. package/dist/mcp-server/tools/definitions/index.d.ts.map +1 -1
  21. package/dist/mcp-server/tools/definitions/index.js +11 -4
  22. package/dist/mcp-server/tools/definitions/index.js.map +1 -1
  23. package/dist/mcp-server/tools/definitions/obsidian-append-to-note.tool.d.ts +19 -3
  24. package/dist/mcp-server/tools/definitions/obsidian-append-to-note.tool.d.ts.map +1 -1
  25. package/dist/mcp-server/tools/definitions/obsidian-append-to-note.tool.js +26 -3
  26. package/dist/mcp-server/tools/definitions/obsidian-append-to-note.tool.js.map +1 -1
  27. package/dist/mcp-server/tools/definitions/obsidian-delete-note.tool.d.ts +11 -1
  28. package/dist/mcp-server/tools/definitions/obsidian-delete-note.tool.d.ts.map +1 -1
  29. package/dist/mcp-server/tools/definitions/obsidian-delete-note.tool.js +12 -0
  30. package/dist/mcp-server/tools/definitions/obsidian-delete-note.tool.js.map +1 -1
  31. package/dist/mcp-server/tools/definitions/obsidian-get-note.tool.d.ts +16 -6
  32. package/dist/mcp-server/tools/definitions/obsidian-get-note.tool.d.ts.map +1 -1
  33. package/dist/mcp-server/tools/definitions/obsidian-get-note.tool.js +13 -1
  34. package/dist/mcp-server/tools/definitions/obsidian-get-note.tool.js.map +1 -1
  35. package/dist/mcp-server/tools/definitions/obsidian-list-notes.tool.d.ts +1 -1
  36. package/dist/mcp-server/tools/definitions/obsidian-manage-frontmatter.tool.d.ts +12 -2
  37. package/dist/mcp-server/tools/definitions/obsidian-manage-frontmatter.tool.d.ts.map +1 -1
  38. package/dist/mcp-server/tools/definitions/obsidian-manage-frontmatter.tool.js +12 -0
  39. package/dist/mcp-server/tools/definitions/obsidian-manage-frontmatter.tool.js.map +1 -1
  40. package/dist/mcp-server/tools/definitions/obsidian-manage-tags.tool.d.ts +13 -3
  41. package/dist/mcp-server/tools/definitions/obsidian-manage-tags.tool.d.ts.map +1 -1
  42. package/dist/mcp-server/tools/definitions/obsidian-manage-tags.tool.js +12 -0
  43. package/dist/mcp-server/tools/definitions/obsidian-manage-tags.tool.js.map +1 -1
  44. package/dist/mcp-server/tools/definitions/obsidian-open-in-ui.tool.d.ts +18 -2
  45. package/dist/mcp-server/tools/definitions/obsidian-open-in-ui.tool.d.ts.map +1 -1
  46. package/dist/mcp-server/tools/definitions/obsidian-open-in-ui.tool.js +49 -26
  47. package/dist/mcp-server/tools/definitions/obsidian-open-in-ui.tool.js.map +1 -1
  48. package/dist/mcp-server/tools/definitions/obsidian-patch-note.tool.d.ts +21 -6
  49. package/dist/mcp-server/tools/definitions/obsidian-patch-note.tool.d.ts.map +1 -1
  50. package/dist/mcp-server/tools/definitions/obsidian-patch-note.tool.js +22 -4
  51. package/dist/mcp-server/tools/definitions/obsidian-patch-note.tool.js.map +1 -1
  52. package/dist/mcp-server/tools/definitions/obsidian-replace-in-note.tool.d.ts +11 -1
  53. package/dist/mcp-server/tools/definitions/obsidian-replace-in-note.tool.d.ts.map +1 -1
  54. package/dist/mcp-server/tools/definitions/obsidian-replace-in-note.tool.js +12 -0
  55. package/dist/mcp-server/tools/definitions/obsidian-replace-in-note.tool.js.map +1 -1
  56. package/dist/mcp-server/tools/definitions/obsidian-search-notes.tool.d.ts +58 -58
  57. package/dist/mcp-server/tools/definitions/obsidian-search-notes.tool.d.ts.map +1 -1
  58. package/dist/mcp-server/tools/definitions/obsidian-write-note.tool.d.ts +19 -3
  59. package/dist/mcp-server/tools/definitions/obsidian-write-note.tool.d.ts.map +1 -1
  60. package/dist/mcp-server/tools/definitions/obsidian-write-note.tool.js +26 -3
  61. package/dist/mcp-server/tools/definitions/obsidian-write-note.tool.js.map +1 -1
  62. package/dist/services/obsidian/obsidian-service.d.ts +19 -1
  63. package/dist/services/obsidian/obsidian-service.d.ts.map +1 -1
  64. package/dist/services/obsidian/obsidian-service.js +138 -6
  65. package/dist/services/obsidian/obsidian-service.js.map +1 -1
  66. package/dist/services/obsidian/path-policy.d.ts.map +1 -1
  67. package/manifest.json +1 -1
  68. package/package.json +14 -13
  69. package/server.json +3 -3
@@ -19,9 +19,9 @@ export declare function buildSearchNotesTool({ omnisearchReachable }: {
19
19
  omnisearchReachable: boolean;
20
20
  }): import("@cyanheads/mcp-ts-core").ToolDefinition<z.ZodObject<{
21
21
  mode: z.ZodEnum<{
22
- text: "text";
23
22
  jsonlogic: "jsonlogic";
24
23
  omnisearch: "omnisearch";
24
+ text: "text";
25
25
  }>;
26
26
  query: z.ZodOptional<z.ZodString>;
27
27
  logic: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
@@ -54,22 +54,6 @@ export declare function buildSearchNotesTool({ omnisearchReachable }: {
54
54
  }, z.core.$strip>>;
55
55
  totalCount: z.ZodNumber;
56
56
  nextCursor: z.ZodOptional<z.ZodString>;
57
- }, z.core.$strip>, z.ZodObject<{
58
- mode: z.ZodLiteral<"omnisearch">;
59
- hits: z.ZodArray<z.ZodObject<{
60
- filename: z.ZodString;
61
- basename: z.ZodString;
62
- score: z.ZodNumber;
63
- foundWords: z.ZodArray<z.ZodString>;
64
- matches: z.ZodArray<z.ZodObject<{
65
- match: z.ZodString;
66
- offset: z.ZodNumber;
67
- }, z.core.$strip>>;
68
- excerpt: z.ZodString;
69
- }, z.core.$strip>>;
70
- totalCount: z.ZodNumber;
71
- nextCursor: z.ZodOptional<z.ZodString>;
72
- truncated: z.ZodBoolean;
73
57
  }, z.core.$strip>] | [z.ZodObject<{
74
58
  mode: z.ZodLiteral<"text">;
75
59
  hits: z.ZodArray<z.ZodObject<{
@@ -94,28 +78,44 @@ export declare function buildSearchNotesTool({ omnisearchReachable }: {
94
78
  }, z.core.$strip>>;
95
79
  totalCount: z.ZodNumber;
96
80
  nextCursor: z.ZodOptional<z.ZodString>;
81
+ }, z.core.$strip>, z.ZodObject<{
82
+ mode: z.ZodLiteral<"omnisearch">;
83
+ hits: z.ZodArray<z.ZodObject<{
84
+ filename: z.ZodString;
85
+ basename: z.ZodString;
86
+ score: z.ZodNumber;
87
+ foundWords: z.ZodArray<z.ZodString>;
88
+ matches: z.ZodArray<z.ZodObject<{
89
+ match: z.ZodString;
90
+ offset: z.ZodNumber;
91
+ }, z.core.$strip>>;
92
+ excerpt: z.ZodString;
93
+ }, z.core.$strip>>;
94
+ totalCount: z.ZodNumber;
95
+ nextCursor: z.ZodOptional<z.ZodString>;
96
+ truncated: z.ZodBoolean;
97
97
  }, z.core.$strip>], "mode">;
98
98
  }, z.core.$strip>, readonly [{
99
- readonly reason: "path_prefix_invalid_mode";
99
+ readonly reason: 'path_prefix_invalid_mode';
100
100
  readonly code: JsonRpcErrorCode.ValidationError;
101
- readonly when: "`pathPrefix` was provided in a non-text mode (only `text` supports prefix filtering).";
102
- readonly recovery: "Drop pathPrefix or switch mode to text for prefix filtering.";
101
+ readonly when: '`pathPrefix` was provided in a non-text mode (only `text` supports prefix filtering).';
102
+ readonly recovery: 'Drop pathPrefix or switch mode to text for prefix filtering.';
103
103
  }, {
104
- readonly reason: "query_required";
104
+ readonly reason: 'query_required';
105
105
  readonly code: JsonRpcErrorCode.ValidationError;
106
- readonly when: "`query` is missing for `text` or `omnisearch` mode (required for both).";
107
- readonly recovery: "Pass `query` — substring for text mode, or BM25 query syntax (quoted phrases, `-exclusion`, `path:` / `ext:` filters) for omnisearch.";
106
+ readonly when: '`query` is missing for `text` or `omnisearch` mode (required for both).';
107
+ readonly recovery: 'Pass `query` — substring for text mode, or BM25 query syntax (quoted phrases, `-exclusion`, `path:` / `ext:` filters) for omnisearch.';
108
108
  }, {
109
- readonly reason: "logic_required";
109
+ readonly reason: 'logic_required';
110
110
  readonly code: JsonRpcErrorCode.ValidationError;
111
- readonly when: "`logic` is missing for `jsonlogic` mode.";
112
- readonly recovery: "Pass a JSONLogic tree as `logic`, e.g. `{\"glob\": [{\"var\": \"path\"}, \"Projects/*.md\"]}`.";
111
+ readonly when: '`logic` is missing for `jsonlogic` mode.';
112
+ readonly recovery: 'Pass a JSONLogic tree as `logic`, e.g. `{"glob": [{"var": "path"}, "Projects/*.md"]}`.';
113
113
  }, {
114
- readonly reason: "omnisearch_unreachable";
114
+ readonly reason: 'omnisearch_unreachable';
115
115
  readonly code: JsonRpcErrorCode.ServiceUnavailable;
116
- readonly when: "Omnisearch was reachable at startup but is now unreachable (Obsidian quit, plugin disabled, or mobile session).";
116
+ readonly when: 'Omnisearch was reachable at startup but is now unreachable (Obsidian quit, plugin disabled, or mobile session).';
117
117
  readonly retryable: true;
118
- readonly recovery: "Restart Obsidian with the Omnisearch plugin enabled, then restart this MCP server so it re-probes the plugin URL.";
118
+ readonly recovery: 'Restart Obsidian with the Omnisearch plugin enabled, then restart this MCP server so it re-probes the plugin URL.';
119
119
  }], {
120
120
  readonly effectiveQuery: z.ZodOptional<z.ZodString>;
121
121
  readonly notice: z.ZodOptional<z.ZodString>;
@@ -133,9 +133,9 @@ export declare function buildSearchNotesTool({ omnisearchReachable }: {
133
133
  */
134
134
  export declare const obsidianSearchNotes: import("@cyanheads/mcp-ts-core").ToolDefinition<z.ZodObject<{
135
135
  mode: z.ZodEnum<{
136
- text: "text";
137
136
  jsonlogic: "jsonlogic";
138
137
  omnisearch: "omnisearch";
138
+ text: "text";
139
139
  }>;
140
140
  query: z.ZodOptional<z.ZodString>;
141
141
  logic: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
@@ -168,22 +168,6 @@ export declare const obsidianSearchNotes: import("@cyanheads/mcp-ts-core").ToolD
168
168
  }, z.core.$strip>>;
169
169
  totalCount: z.ZodNumber;
170
170
  nextCursor: z.ZodOptional<z.ZodString>;
171
- }, z.core.$strip>, z.ZodObject<{
172
- mode: z.ZodLiteral<"omnisearch">;
173
- hits: z.ZodArray<z.ZodObject<{
174
- filename: z.ZodString;
175
- basename: z.ZodString;
176
- score: z.ZodNumber;
177
- foundWords: z.ZodArray<z.ZodString>;
178
- matches: z.ZodArray<z.ZodObject<{
179
- match: z.ZodString;
180
- offset: z.ZodNumber;
181
- }, z.core.$strip>>;
182
- excerpt: z.ZodString;
183
- }, z.core.$strip>>;
184
- totalCount: z.ZodNumber;
185
- nextCursor: z.ZodOptional<z.ZodString>;
186
- truncated: z.ZodBoolean;
187
171
  }, z.core.$strip>] | [z.ZodObject<{
188
172
  mode: z.ZodLiteral<"text">;
189
173
  hits: z.ZodArray<z.ZodObject<{
@@ -208,28 +192,44 @@ export declare const obsidianSearchNotes: import("@cyanheads/mcp-ts-core").ToolD
208
192
  }, z.core.$strip>>;
209
193
  totalCount: z.ZodNumber;
210
194
  nextCursor: z.ZodOptional<z.ZodString>;
195
+ }, z.core.$strip>, z.ZodObject<{
196
+ mode: z.ZodLiteral<"omnisearch">;
197
+ hits: z.ZodArray<z.ZodObject<{
198
+ filename: z.ZodString;
199
+ basename: z.ZodString;
200
+ score: z.ZodNumber;
201
+ foundWords: z.ZodArray<z.ZodString>;
202
+ matches: z.ZodArray<z.ZodObject<{
203
+ match: z.ZodString;
204
+ offset: z.ZodNumber;
205
+ }, z.core.$strip>>;
206
+ excerpt: z.ZodString;
207
+ }, z.core.$strip>>;
208
+ totalCount: z.ZodNumber;
209
+ nextCursor: z.ZodOptional<z.ZodString>;
210
+ truncated: z.ZodBoolean;
211
211
  }, z.core.$strip>], "mode">;
212
212
  }, z.core.$strip>, readonly [{
213
- readonly reason: "path_prefix_invalid_mode";
213
+ readonly reason: 'path_prefix_invalid_mode';
214
214
  readonly code: JsonRpcErrorCode.ValidationError;
215
- readonly when: "`pathPrefix` was provided in a non-text mode (only `text` supports prefix filtering).";
216
- readonly recovery: "Drop pathPrefix or switch mode to text for prefix filtering.";
215
+ readonly when: '`pathPrefix` was provided in a non-text mode (only `text` supports prefix filtering).';
216
+ readonly recovery: 'Drop pathPrefix or switch mode to text for prefix filtering.';
217
217
  }, {
218
- readonly reason: "query_required";
218
+ readonly reason: 'query_required';
219
219
  readonly code: JsonRpcErrorCode.ValidationError;
220
- readonly when: "`query` is missing for `text` or `omnisearch` mode (required for both).";
221
- readonly recovery: "Pass `query` — substring for text mode, or BM25 query syntax (quoted phrases, `-exclusion`, `path:` / `ext:` filters) for omnisearch.";
220
+ readonly when: '`query` is missing for `text` or `omnisearch` mode (required for both).';
221
+ readonly recovery: 'Pass `query` — substring for text mode, or BM25 query syntax (quoted phrases, `-exclusion`, `path:` / `ext:` filters) for omnisearch.';
222
222
  }, {
223
- readonly reason: "logic_required";
223
+ readonly reason: 'logic_required';
224
224
  readonly code: JsonRpcErrorCode.ValidationError;
225
- readonly when: "`logic` is missing for `jsonlogic` mode.";
226
- readonly recovery: "Pass a JSONLogic tree as `logic`, e.g. `{\"glob\": [{\"var\": \"path\"}, \"Projects/*.md\"]}`.";
225
+ readonly when: '`logic` is missing for `jsonlogic` mode.';
226
+ readonly recovery: 'Pass a JSONLogic tree as `logic`, e.g. `{"glob": [{"var": "path"}, "Projects/*.md"]}`.';
227
227
  }, {
228
- readonly reason: "omnisearch_unreachable";
228
+ readonly reason: 'omnisearch_unreachable';
229
229
  readonly code: JsonRpcErrorCode.ServiceUnavailable;
230
- readonly when: "Omnisearch was reachable at startup but is now unreachable (Obsidian quit, plugin disabled, or mobile session).";
230
+ readonly when: 'Omnisearch was reachable at startup but is now unreachable (Obsidian quit, plugin disabled, or mobile session).';
231
231
  readonly retryable: true;
232
- readonly recovery: "Restart Obsidian with the Omnisearch plugin enabled, then restart this MCP server so it re-probes the plugin URL.";
232
+ readonly recovery: 'Restart Obsidian with the Omnisearch plugin enabled, then restart this MCP server so it re-probes the plugin URL.';
233
233
  }], {
234
234
  readonly effectiveQuery: z.ZodOptional<z.ZodString>;
235
235
  readonly notice: z.ZodOptional<z.ZodString>;
@@ -1 +1 @@
1
- {"version":3,"file":"obsidian-search-notes.tool.d.ts","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/obsidian-search-notes.tool.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAsB,CAAC,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAsFjE;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,EAAE,mBAAmB,EAAE,EAAE;IAAE,mBAAmB,EAAE,OAAO,CAAA;CAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8S7F;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAAuD,CAAC"}
1
+ {"version":3,"file":"obsidian-search-notes.tool.d.ts","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/obsidian-search-notes.tool.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAsB,CAAC,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAsFjE;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,EAAE,mBAAmB,EAAE,EAAE;IAAE,mBAAmB,EAAE,OAAO,CAAA;CAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBAgIhF,0BAA0B;;mBAE5B,uFAAuF;uBACnF,8DAA8D;;qBAGhE,gBAAgB;;mBAElB,yEAAyE;uBAE7E,uIAAuI;;qBAGjI,gBAAgB;;mBAElB,0CAA0C;uBAE9C,wFAAwF;;qBAGlF,wBAAwB;;mBAE1B,iHAAiH;;uBAGrH,mHAAmH;;;;GAqJ1H;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBA3LlB,0BAA0B;;mBAE5B,uFAAuF;uBACnF,8DAA8D;;qBAGhE,gBAAgB;;mBAElB,yEAAyE;uBAE7E,uIAAuI;;qBAGjI,gBAAgB;;mBAElB,0CAA0C;uBAE9C,wFAAwF;;qBAGlF,wBAAwB;;mBAE1B,iHAAiH;;uBAGrH,mHAAmH;;;;EAkKpC,CAAC"}
@@ -15,9 +15,9 @@ export declare const obsidianWriteNote: import("@cyanheads/mcp-ts-core").ToolDef
15
15
  type: z.ZodLiteral<"periodic">;
16
16
  period: z.ZodEnum<{
17
17
  daily: "daily";
18
- weekly: "weekly";
19
18
  monthly: "monthly";
20
19
  quarterly: "quarterly";
20
+ weekly: "weekly";
21
21
  yearly: "yearly";
22
22
  }>;
23
23
  date: z.ZodOptional<z.ZodString>;
@@ -25,20 +25,21 @@ export declare const obsidianWriteNote: import("@cyanheads/mcp-ts-core").ToolDef
25
25
  content: z.ZodString;
26
26
  section: z.ZodOptional<z.ZodObject<{
27
27
  type: z.ZodEnum<{
28
- heading: "heading";
29
28
  block: "block";
30
29
  frontmatter: "frontmatter";
30
+ heading: "heading";
31
31
  }>;
32
32
  target: z.ZodString;
33
33
  }, z.core.$strip>>;
34
34
  contentType: z.ZodDefault<z.ZodEnum<{
35
- markdown: "markdown";
36
35
  json: "json";
36
+ markdown: "markdown";
37
37
  }>>;
38
38
  overwrite: z.ZodDefault<z.ZodBoolean>;
39
39
  }, z.core.$strip>, z.ZodObject<{
40
40
  path: z.ZodString;
41
41
  sectionTargeted: z.ZodBoolean;
42
+ sectionTarget: z.ZodOptional<z.ZodString>;
42
43
  created: z.ZodBoolean;
43
44
  previousSizeInBytes: z.ZodNumber;
44
45
  currentSizeInBytes: z.ZodNumber;
@@ -77,5 +78,20 @@ export declare const obsidianWriteNote: import("@cyanheads/mcp-ts-core").ToolDef
77
78
  readonly code: JsonRpcErrorCode.ValidationError;
78
79
  readonly when: "`section` was provided but the named heading/block/frontmatter field does not exist in the note.";
79
80
  readonly recovery: "Call obsidian_get_note with format document-map to discover available targets.";
81
+ }, {
82
+ readonly reason: "ambiguous_section";
83
+ readonly code: JsonRpcErrorCode.Conflict;
84
+ readonly when: "A bare heading leaf name matches more than one heading in the note, so the replacement target is undetermined.";
85
+ readonly recovery: "Retry with one of the full Parent::Child heading paths listed in `candidates` on the error data.";
86
+ }, {
87
+ readonly reason: "path_is_directory";
88
+ readonly code: JsonRpcErrorCode.ValidationError;
89
+ readonly when: "The supplied path names a folder rather than a note file.";
90
+ readonly recovery: "Call obsidian_list_notes with this path to list the folder, then retry with the full path of one of the files it returns.";
91
+ }, {
92
+ readonly reason: "path_traversal";
93
+ readonly code: JsonRpcErrorCode.ValidationError;
94
+ readonly when: "The path contains a `.` or `..` segment, which is rejected to prevent vault escape.";
95
+ readonly recovery: "Supply a vault-relative path with no `.` or `..` segments, e.g. \"Projects/Note.md\". Use obsidian_list_notes to browse the vault.";
80
96
  }], undefined>;
81
97
  //# sourceMappingURL=obsidian-write-note.tool.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"obsidian-write-note.tool.d.ts","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/obsidian-write-note.tool.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAQ,CAAC,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAIjE,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAgK5B,CAAC"}
1
+ {"version":3,"file":"obsidian-write-note.tool.d.ts","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/obsidian-write-note.tool.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAQ,CAAC,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAIjE,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cA4L5B,CAAC"}
@@ -8,7 +8,7 @@ import { JsonRpcErrorCode } from '@cyanheads/mcp-ts-core/errors';
8
8
  import { getObsidianService } from '../../../services/obsidian/obsidian-service.js';
9
9
  import { ContentTypeSchema, SectionSchema, TargetSchema } from './_shared/schemas.js';
10
10
  export const obsidianWriteNote = tool('obsidian_write_note', {
11
- description: 'Create or overwrite a note. With `section`, replaces just that heading/block/frontmatter section in place; nested headings need `Parent::Child` syntax — use `obsidian_get_note` with `format: "document-map"` to discover available targets. Whole-file writes fail with `file_exists` against an existing note unless `overwrite: true` — for in-place edits, prefer `obsidian_patch_note` (sections), `obsidian_append_to_note` (append), or `obsidian_replace_in_note` (find-and-replace). For heading sections, `content` is the new body; the heading line is preserved automatically.',
11
+ description: 'Create or overwrite a note. With `section`, replaces just that heading/block/frontmatter section in place — use `obsidian_get_note` with `format: "document-map"` to discover available targets. A nested heading may be named either by its full `Parent::Child` path or by a bare leaf name that matches exactly one heading; a leaf shared by several headings is rejected with `ambiguous_section`. Whole-file writes fail with `file_exists` against an existing note unless `overwrite: true` — for in-place edits, prefer `obsidian_patch_note` (sections), `obsidian_append_to_note` (append), or `obsidian_replace_in_note` (find-and-replace). For heading sections, `content` is the new body; the heading line is preserved automatically.',
12
12
  annotations: { idempotentHint: true, destructiveHint: true },
13
13
  input: z.object({
14
14
  target: TargetSchema.describe('Where the note lives.'),
@@ -27,6 +27,10 @@ export const obsidianWriteNote = tool('obsidian_write_note', {
27
27
  sectionTargeted: z
28
28
  .boolean()
29
29
  .describe('True when only a section was replaced; false for full-file writes.'),
30
+ sectionTarget: z
31
+ .string()
32
+ .optional()
33
+ .describe('Section locator the replacement was applied to. Present when `section` was supplied. For headings this is the resolved locator — a bare leaf name is reported back as its full `Parent::Child` path.'),
30
34
  created: z
31
35
  .boolean()
32
36
  .describe('True when the write created a new file. False when it replaced an existing one or targeted a section.'),
@@ -81,6 +85,24 @@ export const obsidianWriteNote = tool('obsidian_write_note', {
81
85
  when: '`section` was provided but the named heading/block/frontmatter field does not exist in the note.',
82
86
  recovery: 'Call obsidian_get_note with format document-map to discover available targets.',
83
87
  },
88
+ {
89
+ reason: 'ambiguous_section',
90
+ code: JsonRpcErrorCode.Conflict,
91
+ when: 'A bare heading leaf name matches more than one heading in the note, so the replacement target is undetermined.',
92
+ recovery: 'Retry with one of the full Parent::Child heading paths listed in `candidates` on the error data.',
93
+ },
94
+ {
95
+ reason: 'path_is_directory',
96
+ code: JsonRpcErrorCode.ValidationError,
97
+ when: 'The supplied path names a folder rather than a note file.',
98
+ recovery: 'Call obsidian_list_notes with this path to list the folder, then retry with the full path of one of the files it returns.',
99
+ },
100
+ {
101
+ reason: 'path_traversal',
102
+ code: JsonRpcErrorCode.ValidationError,
103
+ when: 'The path contains a `.` or `..` segment, which is rejected to prevent vault escape.',
104
+ recovery: 'Supply a vault-relative path with no `.` or `..` segments, e.g. "Projects/Note.md". Use obsidian_list_notes to browse the vault.',
105
+ },
84
106
  ],
85
107
  async handler(input, ctx) {
86
108
  const svc = getObsidianService();
@@ -96,7 +118,7 @@ export const obsidianWriteNote = tool('obsidian_write_note', {
96
118
  const body = input.section.type === 'heading'
97
119
  ? stripLeadingHeading(input.content, input.section.target)
98
120
  : input.content;
99
- await svc.patchNote(ctx, pathTarget, body, {
121
+ const sectionTarget = await svc.patchNote(ctx, pathTarget, body, {
100
122
  operation: 'replace',
101
123
  targetType: input.section.type,
102
124
  target: input.section.target,
@@ -108,6 +130,7 @@ export const obsidianWriteNote = tool('obsidian_write_note', {
108
130
  return {
109
131
  path,
110
132
  sectionTargeted: true,
133
+ sectionTarget,
111
134
  created: false,
112
135
  previousSizeInBytes,
113
136
  currentSizeInBytes,
@@ -138,7 +161,7 @@ export const obsidianWriteNote = tool('obsidian_write_note', {
138
161
  text: [
139
162
  `**${result.created ? 'Created' : 'Wrote'} ${result.path}**`,
140
163
  `*Size:* ${result.previousSizeInBytes} → ${result.currentSizeInBytes} bytes`,
141
- `*Section targeted:* ${result.sectionTargeted}`,
164
+ `*Section targeted:* ${result.sectionTargeted}${result.sectionTarget ? ` → ${result.sectionTarget}` : ''}`,
142
165
  `*Created:* ${result.created}`,
143
166
  ].join('\n'),
144
167
  },
@@ -1 +1 @@
1
- {"version":3,"file":"obsidian-write-note.tool.js","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/obsidian-write-note.tool.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAA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I,EAAE,KAAK,IAAI;QAAE,OAAO,OAAO,CAAC;IAChD,KAAK,CAAC,KAAK,EAAE,CAAC;IACd,IAAI,KAAK,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE;QAAE,KAAK,CAAC,KAAK,EAAE,CAAC;IAC3C,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC"}
1
+ {"version":3,"file":"obsidian-write-note.tool.js","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/obsidian-write-note.tool.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,yCAAyC,CAAC;AAC7E,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEtF,MAAM,CAAC,MAAM,iBAAiB,GAAG,IAAI,CAAC,qBAAqB,EAAE;IAC3D,WAAW,EACT,wtBAAwtB;IAC1tB,WAAW,EAAE,EAAE,cAAc,EAAE,IAAI,EAAE,eAAe,EAAE,IAAI,EAAE;IAC5D,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC;QACd,MAAM,EAAE,YAAY,CAAC,QAAQ,CAAC,uBAAuB,CAAC;QACtD,OAAO,EAAE,CAAC;aACP,MAAM,EAAE;aACR,QAAQ,CACP,0JAA0J,CAC3J;QACH,OAAO,EAAE,aAAa,CAAC,QAAQ,EAAE,CAAC,QAAQ,CACxC,uGAAuG,CACxG;QACD,WAAW,EAAE,iBAAiB;QAC9B,SAAS,EAAE,CAAC;aACT,OAAO,EAAE;aACT,OAAO,CAAC,KAAK,CAAC;aACd,QAAQ,CACP,iVAAiV,CAClV;KACJ,CAAC;IACF,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC;QACf,IAAI,EA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AAK,CAAC,KAAK,EAAE,CAAC;IAC3C,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC"}
@@ -52,7 +52,14 @@ export declare class ObsidianService {
52
52
  getDocumentMap(ctx: Context, target: NoteTarget): Promise<DocumentMap>;
53
53
  writeNote(ctx: Context, target: NoteTarget, content: string, contentType?: 'markdown' | 'json'): Promise<void>;
54
54
  appendToNote(ctx: Context, target: NoteTarget, content: string, contentType?: 'markdown' | 'json'): Promise<void>;
55
- patchNote(ctx: Context, target: NoteTarget, content: string, headers: PatchHeaders): Promise<void>;
55
+ /**
56
+ * Apply a header-targeted PATCH. Returns the section locator the edit was
57
+ * actually applied to — identical to `headers.target` unless a bare heading
58
+ * leaf was expanded to its full `Parent::Child` path (see
59
+ * `#resolveHeadingTarget`), which callers echo back so an agent can see where
60
+ * the write landed.
61
+ */
62
+ patchNote(ctx: Context, target: NoteTarget, content: string, headers: PatchHeaders): Promise<string>;
56
63
  deleteNote(ctx: Context, target: NoteTarget): Promise<void>;
57
64
  /**
58
65
  * Byte size of a note at `target`, derived from the HEAD `Content-Length`
@@ -101,8 +108,19 @@ export declare class ObsidianService {
101
108
  */
102
109
  searchOmnisearch(ctx: Context, query: string): Promise<OmnisearchHit[]>;
103
110
  executeCommand(ctx: Context, commandId: string): Promise<void>;
111
+ /**
112
+ * Open a file in the Obsidian UI.
113
+ *
114
+ * Obsidian materializes the file when the path does not exist, so the call
115
+ * is only a read when the caller has established that the file is already
116
+ * there. `createIfMissing` marks the create-capable variant and gates it as
117
+ * a write, which is what makes `OBSIDIAN_READ_ONLY` and
118
+ * `OBSIDIAN_WRITE_PATHS` constrain it — the creation happens inside Obsidian
119
+ * and never passes through any other write check.
120
+ */
104
121
  openInUi(ctx: Context, path: string, opts?: {
105
122
  newLeaf?: boolean;
123
+ createIfMissing?: boolean;
106
124
  }): Promise<void>;
107
125
  }
108
126
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"obsidian-service.d.ts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