Skip to main content
Glama

obsidian_update_frontmatter

Modify YAML frontmatter metadata in Obsidian notes to add or update fields like tags and status while keeping note content unchanged.

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

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • Main handler function that orchestrates the frontmatter update by calling the ObsidianClient helper and formatting the 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 model defining the parameters for the tool: filepath (str) and updates (Dict[str, Any]).
    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 decorator registering the tool with name 'obsidian_update_frontmatter' and appropriate annotations.
    @mcp.tool(
        name="obsidian_update_frontmatter",
        annotations={
            "title": "Update Note Frontmatter",
            "readOnlyHint": False,
            "destructiveHint": False,
            "idempotentHint": False,
            "openWorldHint": False
        }
    )
  • Core implementation in ObsidianClient: reads file, parses frontmatter, merges updates, serializes with frontmatter library, and writes back preserving body content.
    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
        }
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

The description adds valuable behavioral context beyond annotations: it specifies that only frontmatter is modified while content is preserved, mentions the tool works with 'Zettelkasten notes,' and provides an example of the update format. Annotations already indicate this is a non-destructive, non-readonly operation, so the description appropriately supplements rather than contradicts them.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is efficiently structured with a clear purpose statement, usage context, parameter explanation, return value, and example - all in well-organized paragraphs with zero redundant information. Every sentence adds value and is appropriately front-loaded.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's moderate complexity (1 parameter with nested structure), lack of schema descriptions, and presence of output schema, the description provides good coverage of purpose, behavior, and parameter usage. The example helps clarify the updates format, though more detail on filepath validation or error cases would make it fully complete.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

With 0% schema description coverage, the description compensates by explaining the 'updates' parameter with examples ('tags', 'status', 'custom properties') and showing dictionary format. However, it doesn't fully document the 'filepath' parameter's requirements or provide comprehensive guidance on the updates dictionary structure beyond basic examples.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the specific action ('Update YAML frontmatter metadata') and resource ('note content'), distinguishing it from siblings like obsidian_manage_tags or obsidian_patch_content by focusing exclusively on frontmatter updates without modifying note body content.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides clear context about when to use this tool ('Add or update metadata fields like tags, status, or custom properties') and implicitly distinguishes it from content-modifying siblings by emphasizing 'without modifying note content.' However, it doesn't explicitly mention when NOT to use it or name specific alternative tools for related operations.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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