Skip to main content
Glama

obsidian_update_frontmatter

Update YAML frontmatter metadata in Obsidian notes without changing content. Add or modify tags, status, and custom properties while preserving all existing note content.

Instructions

Update YAML frontmatter metadata without modifying note content.

Add or update metadata fields like tags, status, or custom properties in Zettelkasten notes while preserving all content. Args: params (UpdateFrontmatterInput): Contains: - filepath (str): Path to file - updates (Dict): Frontmatter fields to add/update Returns: str: Success message with updated frontmatter Example: Add tags to existing note: updates={'tags': ['zettelkasten', 'systems-thinking']}

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
paramsYes

Implementation Reference

  • MCP tool handler: validates input using UpdateFrontmatterInput and calls ObsidianClient.update_file_frontmatter, returns JSON response.
    async def update_frontmatter(params: UpdateFrontmatterInput) -> str: """Update YAML frontmatter metadata without modifying note content. Add or update metadata fields like tags, status, or custom properties in Zettelkasten notes while preserving all content. Args: params (UpdateFrontmatterInput): Contains: - filepath (str): Path to file - updates (Dict): Frontmatter fields to add/update Returns: str: Success message with updated frontmatter Example: Add tags to existing note: updates={'tags': ['zettelkasten', 'systems-thinking']} """ try: result = await obsidian_client.update_file_frontmatter( params.filepath, params.updates ) return json.dumps({ "success": True, "message": "Frontmatter updated successfully", "filepath": params.filepath, "frontmatter": result["frontmatter"] }, indent=2) except ObsidianAPIError as e: return json.dumps({ "error": str(e), "filepath": params.filepath, "success": False }, indent=2)
  • Pydantic input schema defining filepath (str) and updates (Dict[str, Any]) for the tool.
    class UpdateFrontmatterInput(BaseModel): """Input for updating frontmatter.""" model_config = ConfigDict(str_strip_whitespace=True, extra='forbid') filepath: str = Field( description="Path to the file", min_length=1, max_length=500 ) updates: Dict[str, Any] = Field( description="Frontmatter fields to update or add (e.g., {'tags': ['new-tag'], 'status': 'published'})" )
  • MCP tool registration decorator specifying the tool name and operational hints.
    @mcp.tool( name="obsidian_update_frontmatter", annotations={ "title": "Update Note Frontmatter", "readOnlyHint": False, "destructiveHint": False, "idempotentHint": False, "openWorldHint": False } )
  • Core helper method in ObsidianClient: reads file, parses frontmatter with frontmatter lib, merges updates, serializes YAML+body, writes back to vault.
    async def update_file_frontmatter( self, filepath: str, updates: Dict[str, Any] ) -> Dict[str, Any]: """ Update frontmatter in a file without modifying body content. Args: filepath: Path to the file updates: Dictionary of frontmatter fields to update Returns: Dictionary with success status and updated frontmatter """ content = await self.read_file(filepath) current_fm, body = self.parse_frontmatter(content) # Merge updates into current frontmatter current_fm.update(updates) # Serialize and write back new_content = self.serialize_with_frontmatter(current_fm, body) await self.write_file(filepath, new_content) return { "success": True, "frontmatter": current_fm }

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/Shepherd-Creative/obsidian-mcp'

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