Skip to main content
Glama

obsidian_get_frontmatter

Read-onlyIdempotent

Extract YAML frontmatter metadata like tags and creation dates from Obsidian notes without loading full content for classification and organization.

Instructions

Extract YAML frontmatter metadata from a note.

Read metadata like tags, creation date, and other properties from Zettelkasten
notes without loading the full content.

Args:
    params (GetFrontmatterInput): Contains:
        - filepath (str): Path to file

Returns:
    str: JSON object containing frontmatter fields
    
Example:
    Get tags and metadata from a note to understand its classification.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
paramsYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The handler function decorated with @mcp.tool that registers and implements the obsidian_get_frontmatter tool. It extracts frontmatter using the ObsidianClient and returns formatted JSON.
    @mcp.tool(
        name="obsidian_get_frontmatter",
        annotations={
            "title": "Get Note Frontmatter",
            "readOnlyHint": True,
            "destructiveHint": False,
            "idempotentHint": True,
            "openWorldHint": False
        }
    )
    async def get_frontmatter(params: GetFrontmatterInput) -> str:
        """Extract YAML frontmatter metadata from a note.
        
        Read metadata like tags, creation date, and other properties from Zettelkasten
        notes without loading the full content.
        
        Args:
            params (GetFrontmatterInput): Contains:
                - filepath (str): Path to file
        
        Returns:
            str: JSON object containing frontmatter fields
            
        Example:
            Get tags and metadata from a note to understand its classification.
        """
        try:
            frontmatter = await obsidian_client.get_file_frontmatter(params.filepath)
            
            return json.dumps({
                "success": True,
                "filepath": params.filepath,
                "frontmatter": frontmatter
            }, indent=2)
            
        except ObsidianAPIError as e:
            return json.dumps({
                "error": str(e),
                "filepath": params.filepath,
                "success": False
            }, indent=2)
  • Pydantic input schema for the tool, defining the required filepath parameter.
    class GetFrontmatterInput(BaseModel):
        """Input for getting frontmatter."""
        model_config = ConfigDict(str_strip_whitespace=True, extra='forbid')
        
        filepath: str = Field(
            description="Path to the file",
            min_length=1,
            max_length=500
        )
  • Helper method in ObsidianClient that reads the file content and parses the YAML frontmatter using the frontmatter library.
    async def get_file_frontmatter(self, filepath: str) -> Dict[str, Any]:
        """Extract frontmatter from a file."""
        content = await self.read_file(filepath)
        metadata, _ = self.parse_frontmatter(content)
        return metadata
  • Utility method that uses the 'frontmatter' library to parse YAML frontmatter from markdown content, returning metadata and body.
    def parse_frontmatter(self, content: str) -> tuple[Dict[str, Any], str]:
        """
        Parse frontmatter from content.
        
        Returns:
            Tuple of (frontmatter_dict, body_content)
        """
        try:
            post = frontmatter.loads(content)
            return post.metadata, post.content
        except Exception:
            # No frontmatter found
            return {}, content
Behavior4/5

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

Annotations already provide readOnlyHint=true, destructiveHint=false, and idempotentHint=true, covering safety and idempotency. The description adds valuable context by specifying it extracts 'YAML frontmatter' (format), mentions 'Zettelkasten notes' (context), and clarifies it doesn't load full content (performance/scope). No contradictions with annotations.

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

Conciseness4/5

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

The description is well-structured with clear sections (purpose, Args, Returns, Example) and front-loaded key information. It's concise but includes a slightly verbose example sentence that could be tighter.

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

Completeness5/5

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

Given the tool's low complexity (1 parameter), rich annotations (covering safety and idempotency), and the presence of an output schema (implied by Returns section), the description is complete. It explains purpose, usage context, parameter role, and output format adequately without needing to detail return values.

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?

Schema description coverage is 0%, but the description compensates by explaining the single parameter 'filepath' in the Args section and providing an example use case. However, it doesn't add significant meaning beyond what's implied by the parameter name and basic schema constraints (e.g., path format or vault context).

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 ('Extract YAML frontmatter metadata'), the resource ('from a note'), and distinguishes it from siblings by mentioning it reads metadata 'without loading the full content' (unlike obsidian_get_file_contents). It provides concrete examples of metadata types like tags and creation date.

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 explicitly states when to use it: to 'Read metadata... without loading the full content,' which differentiates it from content-reading tools like obsidian_get_file_contents. However, it doesn't explicitly mention when NOT to use it or name specific alternatives beyond the implied contrast.

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