Skip to main content
Glama

read_note

Retrieve the complete content of a specific note from your Obsidian vault by providing its file path. Use this tool to access and review note details for reference or further processing.

Instructions

Read the full content of a note from the vault

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYes

Implementation Reference

  • The MCP tool handler for 'read_note': validates the path, reads the note via vault.read_note, formats output with path, frontmatter (YAML), and body content, handles various errors.
    @mcp.tool(name="read_note", description="Read the full content of a note from the vault") async def read_note(path: str) -> str: """ Read a note from the vault. Args: path: Relative path to the note (e.g., "Projects/MCP.md") Returns: Note content as markdown text with frontmatter """ # Validate input if not path or not path.strip(): return "Error: Path cannot be empty" if len(path) > 1000: return "Error: Path too long" context = _get_context() try: note = await context.vault.read_note(path) # Format response with metadata result = f"# {note.path}\n\n" if note.frontmatter: result += "## Frontmatter\n```yaml\n" result += yaml.dump(note.frontmatter, default_flow_style=False) result += "```\n\n" result += "## Content\n" result += note.body return result except FileNotFoundError: return f"Error: Note not found: {path}" except VaultSecurityError as e: return f"Error: Security violation: {e}" except Exception as e: logger.exception(f"Error reading note {path}") return f"Error reading note: {e}"
  • Core helper method in ObsidianVault that performs path validation/security checks, asynchronously reads the note file content, parses YAML frontmatter, and constructs/returns a Note dataclass instance.
    async def read_note(self, relative_path: str) -> Note: """ Read a note from the vault. Args: relative_path: Path relative to vault root Returns: Note object with content and metadata Raises: VaultSecurityError: If path is invalid FileNotFoundError: If note doesn't exist """ file_path = self._validate_path(relative_path) if not file_path.exists(): raise FileNotFoundError(f"Note not found: {relative_path}") if not file_path.is_file(): raise ValueError(f"Path is not a file: {relative_path}") async with aiofiles.open(file_path, encoding="utf-8") as f: content = await f.read() frontmatter, content = self._parse_frontmatter(content) return Note(path=relative_path, content=content, frontmatter=frontmatter)
  • MCP tool registration decorator specifying the tool name 'read_note' and its description.
    @mcp.tool(name="read_note", description="Read the full content of a note from the vault")

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/getglad/obsidian_mcp'

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