get_note
Retrieve the content of a Markdown note from an Obsidian vault by providing its file path. Enables AI assistants to read note contents directly without requiring Obsidian to be open.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"path": "<path>"
},
"name": "get_note"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes |
Implementation Reference
- src/vault/notes.ts:12-28 (handler)Core logic: reads a markdown note from the vault by its relative path, parses frontmatter using gray-matter, and returns the path, frontmatter data, and content.
export async function readNote(relativePath: string) { const finalPath = ensureMdExtension(relativePath); const fullPath = resolveVaultPath(finalPath); if (!(await pathExists(fullPath))) { throw new Error(`Note not found: ${finalPath}`); } const raw = await fs.readFile(fullPath, "utf-8"); const parsed = matter(raw); return { path: finalPath, frontmatter: parsed.data, content: parsed.content, }; } - src/tools/get-note.ts:8-8 (schema)Schema: expects a single 'path' string parameter (min 1 char) via Zod validation.
{ inputSchema: { path: z.string().min(1) } }, - src/tools/get-note.ts:9-14 (handler)Tool handler: calls readNote with the provided path and returns the note as formatted JSON text.
async ({ path }) => { const note = await readNote(path); return { content: [{ type: "text", text: JSON.stringify(note, null, 2) }], }; }, - src/tools/get-note.ts:5-16 (registration)Registration: registers the 'get_note' tool on the MCP server with its schema and handler.
export function register(server: McpServer): void { server.registerTool( "get_note", { inputSchema: { path: z.string().min(1) } }, async ({ path }) => { const note = await readNote(path); return { content: [{ type: "text", text: JSON.stringify(note, null, 2) }], }; }, ); } - src/server.ts:15-15 (registration)Server-side registration: calls getNote.register(server) to wire up the tool.
getNote.register(server);