read_note
Read a markdown note by providing its relative path. Returns file location, YAML frontmatter, and content.
Instructions
Returns { root, path, frontmatter, content }. Pass a relative path. Use list_directory first if unsure of the path.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/note-tools.ts:17-55 (handler)Main handler function for the read_note tool. Uses file.readNote() to parse a markdown note, returning root, path, frontmatter, and content. Handles errors with helpful messages.
function makeReadNoteTool(container: ServiceContainer): ToolHandler { return { name: "read_note", description: "Returns `{ root, path, frontmatter, content }`. Pass a relative path. Use `list_directory` first if unsure of the path.", inputSchema: ReadNoteSchema, async handler(args): Promise<ToolResponse> { const services = requireServices(container); const { path } = ReadNoteSchema.parse(args); log.info({ path }, "read_note called"); try { const note = await services.file.readNote(path); log.info({ path }, "read_note complete"); return { content: [ { type: "text", text: JSON.stringify({ root: getRoot(container), path: note.path, frontmatter: note.frontmatter, content: note.content, }), }, ], }; } catch (err) { log.error({ err, path }, "read_note failed"); return { content: [{ type: "text", text: JSON.stringify({ root: getRoot(container), error: err instanceof Error ? err.message : String(err), possibleSolutions: ["Check the path with list_directory", "Verify the file exists with list_directory", "Ensure the path is root-relative (not absolute)"], }) }], isError: true, }; } }, }; } - src/tools/note-tools.ts:13-15 (schema)Zod input schema for read_note tool. Defines a single 'path' field (string, min 1 char) as required input.
const ReadNoteSchema = z.object({ path: z.string().min(1, "path is required"), }); - src/tools/note-tools.ts:345-361 (registration)Registration function that registers read_note (along with other note tools) into the tool registry map.
export function registerNoteTools( registry: Map<string, ToolHandler>, container: ServiceContainer, ): void { const tools = [ makeReadNoteTool(container), makeWriteNoteTool(container), makePatchNoteTool(container), makeDeleteNoteTool(container), makeMoveNoteTool(container), makeReadMultipleNotesTool(container), ]; for (const tool of tools) { registry.set(tool.name, tool); } } - src/tools/index.ts:67-86 (registration)Top-level registration that calls registerNoteTools to add read_note to the global registry.
export function registerTools( registry: Map<string, ToolHandler>, container: ServiceContainer, rebuildServices: RebuildServices, options: RegisterToolsOptions = {}, ): void { registerNoteTools(registry, container); registerDirectoryTools(registry, container, rebuildServices); registerFrontmatterTools(registry, container); registerSearchTools(registry, container); registerSchemaTools(registry, container); registerCreateNoteTool(registry, container); registerLinkTools(registry, container); if (options.lite) { for (const name of registry.keys()) { if (!LITE_TOOL_NAMES.has(name)) registry.delete(name); } } } - src/services/file-service.ts:70-83 (helper)The underlying FileService.readNote() implementation that reads the file from disk, parses frontmatter using gray-matter, and returns a ParsedNote object.
async readNote(relativePath: string): Promise<ParsedNote> { const fullPath = this.resolvePath(relativePath); log.info({ path: relativePath }, "readNote"); const raw = await fs.readFile(fullPath, "utf-8"); const parsed = matter(raw); return { path: relativePath, frontmatter: parsed.data as Record<string, unknown>, content: parsed.content, raw, }; }