Skip to content

Commit 57f047e

Browse files
committed
✨ read_multiple_notes
1 parent bb81be7 commit 57f047e

File tree

1 file changed

+73
-2
lines changed

1 file changed

+73
-2
lines changed

src/vaultasmcp-Tools.ts

Lines changed: 73 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,55 @@ export class MCPTools {
113113
readOnlyHint: true,
114114
},
115115
},
116+
{
117+
name: "read_multiple_notes",
118+
description:
119+
"Read the content of multiple notes in a single request. " +
120+
"Returns an object mapping each path to its content or " +
121+
"error message. More efficient than multiple read_note " +
122+
"calls for batch operations.",
123+
inputSchema: {
124+
type: "object",
125+
properties: {
126+
paths: {
127+
type: "array",
128+
items: { type: "string" },
129+
description:
130+
"Array of note paths to read " +
131+
"(e.g., ['folder/note1.md', 'folder/note2.md'])",
132+
},
133+
},
134+
required: ["paths"],
135+
},
136+
outputSchema: {
137+
type: "object" as const,
138+
properties: {
139+
notes: {
140+
type: "object",
141+
additionalProperties: {
142+
type: "object",
143+
properties: {
144+
content: {
145+
type: "string",
146+
description: "The markdown content",
147+
},
148+
error: {
149+
type: "string",
150+
description:
151+
"Error message if read failed",
152+
},
153+
},
154+
},
155+
description:
156+
"Object mapping paths to content or error",
157+
},
158+
},
159+
required: ["notes"],
160+
},
161+
annotations: {
162+
readOnlyHint: true,
163+
},
164+
},
116165
{
117166
name: "search_notes",
118167
description:
@@ -576,14 +625,16 @@ export class MCPTools {
576625
switch (toolName) {
577626
case "read_note":
578627
return await this.readNote(args.path as string);
628+
case "read_multiple_notes":
629+
return await this.readMultipleNotes(args.paths as string[]);
579630
case "search_notes":
580631
return await this.searchNotes(
581632
args.tag as string | undefined,
582633
args.folder as string | undefined,
583634
args.text as string | undefined,
584635
args.mtime as
585-
| { before?: string; after?: string }
586-
| undefined,
636+
| { before?: string; after?: string }
637+
| undefined,
587638
args.frontmatter as Record<string, string> | undefined,
588639
);
589640
case "get_linked_notes":
@@ -637,6 +688,26 @@ export class MCPTools {
637688
return await this.noteHandler.readNote(path);
638689
}
639690

691+
private async readMultipleNotes(paths: string[]): Promise<{
692+
notes: Record<string, { content?: string; error?: string }>;
693+
}> {
694+
const results: Record<string, { content?: string; error?: string }> =
695+
{};
696+
697+
for (const path of paths) {
698+
try {
699+
const result = await this.noteHandler.readNote(path);
700+
results[path] = { content: result.content };
701+
} catch (e) {
702+
results[path] = {
703+
error: e instanceof Error ? e.message : String(e),
704+
};
705+
}
706+
}
707+
708+
return { notes: results };
709+
}
710+
640711
private async createNote(
641712
path: string,
642713
content?: string,

0 commit comments

Comments
 (0)