read_obsidian_note
Retrieve the full content of any Obsidian note by specifying its relative path, enabling translation or processing of the note's text.
Instructions
Read content of an existing Obsidian note
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | Path to the note (relative to vault root) |
Implementation Reference
- src/index.ts:91-99 (registration)Tool registration in ListToolsRequestHandler - includes getReadNoteToolDefinition()
tools: [ TranslateTool.getToolDefinition(), NotesTool.getCreateNoteToolDefinition(), NotesTool.getReadNoteToolDefinition(), NotesTool.getUpdateNoteToolDefinition(), SearchTool.getSearchToolDefinition(), SearchTool.getSearchByTagsToolDefinition(), ], }; - src/index.ts:205-225 (handler)Handler that validates path, delegates to notesTool.readNote(), and formats the response with frontmatter and content
private async handleReadNote(args: any) { const { path } = args; if (!path) { throw new McpError(ErrorCode.InvalidParams, 'Path is required'); } const result = await this.notesTool.readNote(path); return { content: [ { type: 'text', text: `๐ ใใผใใฎๅ ๅฎน:\\n\\n` + `๐ ใใน: ${path}\\n` + `๐ ใกใฟใใผใฟ: ${JSON.stringify(result.frontmatter, null, 2)}\\n\\n` + `๐ ใณใณใใณใ:\\n${result.content}` } ] }; } - src/tools/notes.ts:54-69 (schema)Tool schema definition - input requires 'path' (string) to locate the note relative to vault root
static getReadNoteToolDefinition(): Tool { return { name: 'read_obsidian_note', description: 'Read content of an existing Obsidian note', inputSchema: { type: 'object', properties: { path: { type: 'string', description: 'Path to the note (relative to vault root)' } }, required: ['path'] } }; } - src/tools/notes.ts:176-191 (handler)Core business logic: reads file via FileSystemHelper, parses frontmatter with gray-matter, returns content and frontmatter
async readNote(path: string): Promise<{ content: string; frontmatter: any }> { try { const rawContent = await this.fileSystem.readFile(path); const { data: frontmatter, content } = matter(rawContent); return { content, frontmatter }; } catch (error) { if (error instanceof Error) { throw error; } throw new Error(`${ErrorCode.FILE_NOT_FOUND}: Failed to read note '${path}'`); } } - src/utils/file-system.ts:42-49 (helper)Utility that resolves relative path to absolute vault path and reads file content with fs.readFile
async readFile(filePath: string): Promise<string> { try { const absolutePath = this.getAbsolutePath(filePath); return await fs.readFile(absolutePath, 'utf-8'); } catch (error) { throw new Error(`${ErrorCode.FILE_NOT_FOUND}: Cannot read file '${filePath}': ${error}`); } }