append_to_note
Add new content to existing notes in your Obsidian vault, enabling continuous updates and expansion of your knowledge base without creating duplicate files.
Instructions
Append content to an existing note
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| content | Yes | ||
| path | Yes |
Implementation Reference
- src/obsidian_mcp/server.py:646-678 (handler)MCP tool handler function for 'append_to_note'. Validates inputs, calls vault.append_to_note, handles errors and returns formatted response.@mcp.tool(name="append_to_note", description="Append content to an existing note") async def append_to_note(path: str, content: str) -> str: """ Append content to the end of an existing note. Args: path: Relative path to the note content: Content to append 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.append_to_note(path, content) return f"✓ Appended to 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 appending to note {path}") return f"Error appending to note: {e}"
- src/obsidian_mcp/vault.py:551-581 (helper)Core vault method that implements appending content to a note: validates path security, reads existing content, appends with proper newline handling, and writes back.async def append_to_note(self, relative_path: str, content: str) -> None: """ Append content to an existing note. Args: relative_path: Path to the note content: Content to append 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}") # Read existing content async with aiofiles.open(file_path, encoding="utf-8") as f: existing = await f.read() # Append new content (with newline separator if needed) if not existing.endswith("\n"): existing += "\n" existing += content # Write back async with aiofiles.open(file_path, "w", encoding="utf-8") as f: await f.write(existing) logger.info(f"Appended to note: {relative_path}")
- src/obsidian_mcp/server.py:646-646 (registration)@mcp.tool decorator registering the 'append_to_note' tool with FastMCP.@mcp.tool(name="append_to_note", description="Append content to an existing note")