read_note
Retrieve note content from your Obsidian vault by specifying the file path, enabling AI models to access and reference stored knowledge.
Instructions
Read the content of a note in the Obsidian vault
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | Path to the note within the vault |
Implementation Reference
- src/index.ts:1442-1457 (handler)MCP tool handler for 'read_note' that validates the input path, reads the note content using the private readNote method, and returns it in the MCP content format.private async handleReadNote(args: any) { if (!args?.path) { throw new Error('Path is required'); } const content = await this.readNote(args.path); return { content: [ { type: 'text', text: content, }, ], }; }
- src/index.ts:2201-2218 (helper)Core implementation of note reading logic: attempts to fetch content via Obsidian Local REST API GET /vault/{path}, with fallback to direct filesystem fs.readFileSync if API fails or file not found.private async readNote(notePath: string): Promise<string> { try { // First try using the Obsidian API const response = await this.api.get(`/vault/${encodeURIComponent(notePath)}`); // API returns the content directly, not wrapped in {content: ...} return response.data || ''; } catch (error) { console.warn('API request failed, falling back to file system:', error); // Fallback to file system if API fails const fullPath = path.join(VAULT_PATH, notePath); if (fs.existsSync(fullPath)) { return fs.readFileSync(fullPath, 'utf-8'); } else { return ''; } }
- src/index.ts:1132-1144 (schema)JSON schema definition for the read_note tool input, defining the required 'path' string parameter. This is returned by the ListToolsRequestHandler.name: 'read_note', description: 'Read the content of a note in the Obsidian vault', inputSchema: { type: 'object', properties: { path: { type: 'string', description: 'Path to the note within the vault', }, }, required: ['path'], }, },
- src/index.ts:1391-1391 (registration)Dispatch/registration case in the CallToolRequestSchema handler that routes 'read_note' tool calls to the handleReadNote method.return await this.handleReadNote(request.params.arguments);