Skip to main content
Glama
quinny1187

Obsidian MCP Server

by quinny1187

read_note

Retrieve content from Obsidian notes by specifying vault and file paths to access stored information directly.

Instructions

Read a note from the vault

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
vault_pathYesPath to the Obsidian vault
note_pathYesPath to the note relative to vault root (with or without .md extension)

Implementation Reference

  • The core handler function for the 'read_note' tool. It validates the vault, reads the note file, parses frontmatter with gray-matter, and returns structured data including content, frontmatter, raw content, and file stats.
    export async function handleReadNote(
      vaultManager: VaultManager,
      vaultPath: string,
      notePath: string
    ) {
      await vaultManager.validateVault(vaultPath);
      
      const filePath = vaultManager.getFilePath(vaultPath, notePath);
      
      try {
        const content = await fs.readFile(filePath, 'utf-8');
        const parsed = matter(content);
        const stats = await fs.stat(filePath);
        
        return {
          path: notePath,
          content: parsed.content,
          frontmatter: parsed.data,
          raw: content,
          stats: {
            created: stats.birthtime,
            modified: stats.mtime,
            size: stats.size,
          },
        };
      } catch (error: any) {
        if (error.code === 'ENOENT') {
          throw new Error(`Note not found: ${notePath}`);
        }
        throw error;
      }
    }
  • Tool registration entry including name, description, and input schema definition for 'read_note' used in list_tools response.
    {
      name: 'read_note',
      description: 'Read a note from the vault',
      inputSchema: {
        type: 'object',
        properties: {
          vault_path: {
            type: 'string',
            description: 'Path to the Obsidian vault',
          },
          note_path: {
            type: 'string',
            description: 'Path to the note relative to vault root (with or without .md extension)',
          },
        },
        required: ['vault_path', 'note_path'],
      },
    },
  • src/index.ts:183-188 (registration)
    Dispatch logic in the CallToolRequestSchema handler that routes 'read_note' calls to the handleReadNote function with input validation.
    case 'read_note':
      if (!args || typeof args !== 'object' || !('vault_path' in args) || !('note_path' in args)) {
        throw new McpError(ErrorCode.InvalidParams, 'Missing required parameters');
      }
      result = await handleReadNote(vaultManager, args.vault_path as string, args.note_path as string);
      break;

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/quinny1187/obsidian-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server