Skip to main content
Glama

update_note

Modify existing note content in your Obsidian vault by specifying the file path and new text to update your knowledge base.

Instructions

Update an existing note's content

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
contentYes
pathYes

Implementation Reference

  • The MCP tool handler for 'update_note'. Validates input parameters, calls the vault helper method, and returns success/error messages.
    @mcp.tool(name="update_note", description="Update an existing note's content") async def update_note(path: str, content: str) -> str: """ Update an existing note's content (preserves frontmatter). Args: path: Relative path to the note content: New content for the note body Returns: Success message """ if not path or not path.strip(): return "Error: Path cannot be empty" if len(path) > 1000: return "Error: Path too long" if len(content) > 1_000_000: return "Error: Content too large (max 1MB)" context = _get_context() try: await context.vault.update_note(path, content) return f"✓ Updated note: {path}" 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 updating note {path}") return f"Error updating note: {e}"
  • The @mcp.tool decorator registers the update_note function as an MCP tool with the specified name.
    @mcp.tool(name="update_note", description="Update an existing note's content")
  • The core helper method in ObsidianVault class that performs the actual file update, handling path validation, frontmatter preservation or update, and asynchronous file writing.
    async def update_note( self, relative_path: str, content: str, frontmatter: dict[str, Any] | None = None ) -> None: """ Update an existing note's content. Args: relative_path: Path to the note content: New content for the note frontmatter: Optional frontmatter dict (replaces existing if provided) 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 frontmatter not provided, preserve existing if frontmatter is None: note = await self.read_note(relative_path) frontmatter = note.frontmatter # Build full content full_content = "" if frontmatter: full_content = "---\n" full_content += yaml.dump(frontmatter, default_flow_style=False, sort_keys=False) full_content += "---\n" full_content += content # Write file async with aiofiles.open(file_path, "w", encoding="utf-8") as f: await f.write(full_content) logger.info(f"Updated note: {relative_path}")

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