Skip to main content
Glama

create_from_template

Generate new notes in Obsidian using predefined templates to maintain consistent formatting and structure across your vault.

Instructions

Create a new note from a template

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
new_note_pathYes
template_pathYes
titleNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • Core handler function in ObsidianVault class that reads the template note, applies string replacements to content and frontmatter, and creates the new note using create_note method.
    async def create_from_template(
        self,
        template_path: str,
        new_note_path: str,
        replacements: dict[str, str] | None = None,
    ) -> None:
        """
        Create a new note from a template.
    
        Args:
            template_path: Path to the template note
            new_note_path: Path for the new note
            replacements: Dict of placeholder -> value replacements
    
        Raises:
            FileNotFoundError: If template doesn't exist
        """
        # Read template
        template = await self.read_note(template_path)
    
        content = template.content
        frontmatter = template.frontmatter.copy() if template.frontmatter else None
    
        # Apply replacements
        if replacements:
            for placeholder, value in replacements.items():
                content = content.replace(f"{{{{{placeholder}}}}}", value)
    
                # Also replace in frontmatter values
                if frontmatter:
                    for key, fm_value in frontmatter.items():
                        if isinstance(fm_value, str):
                            frontmatter[key] = fm_value.replace(f"{{{{{placeholder}}}}}", value)
    
        # Create new note
        self.create_note(new_note_path, content, frontmatter)
  • MCP tool registration via @mcp.tool decorator and wrapper handler that provides default replacements (date, time, datetime, title) and calls the vault implementation.
    @mcp.tool(name="create_from_template", description="Create a new note from a template")
    async def create_from_template(template_path: str, new_note_path: str, title: str = "") -> str:
        """
        Create a note from a template.
    
        Args:
            template_path: Path to the template note
            new_note_path: Path for the new note
            title: Optional title to replace {{title}} placeholder
    
        Returns:
            Success message
        """
        if not template_path or not new_note_path:
            return "Error: Template path and new note path are required"
    
        context = _get_context()
    
        try:
            # Build replacements
            replacements = {
                "date": datetime.now().strftime("%Y-%m-%d"),
                "time": datetime.now().strftime("%H:%M"),
                "datetime": datetime.now().strftime("%Y-%m-%d %H:%M"),
            }
    
            if title:
                replacements["title"] = title
    
            await context.vault.create_from_template(template_path, new_note_path, replacements)
            return f"✓ Created note from template: {new_note_path}"
    
        except FileNotFoundError:
            return f"Error: Template not found: {template_path}"
        except FileExistsError:
            return f"Error: Note already exists: {new_note_path}"
        except Exception as e:
            logger.exception("Error creating from template")
            return f"Error creating from template: {e}"
Behavior2/5

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

No annotations are provided, so the description carries full burden. It states 'create' implying a write operation, but doesn't disclose behavioral traits like whether it overwrites existing files, requires specific permissions, handles errors (e.g., invalid paths), or what happens on success/failure. This is inadequate for a mutation tool with zero annotation coverage.

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 a single, efficient sentence with zero waste. It's front-loaded with the core action and resource, making it easy to scan and understand quickly.

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

Completeness3/5

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

Given a mutation tool with 3 parameters, 0% schema coverage, no annotations, but an output schema exists, the description is incomplete. It covers the basic purpose but lacks parameter details, behavioral context, and usage guidelines. The output schema helps, but the description should do more to compensate for missing structured data.

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

Parameters2/5

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

Schema description coverage is 0%, so the description must compensate. It mentions 'template' and 'new note' but doesn't explain what the parameters represent (e.g., 'new_note_path' is the destination file path, 'template_path' is the source template file, 'title' is optional content). Without this, users might not understand how to provide valid inputs.

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

Purpose4/5

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

The description clearly states the verb 'create' and the resource 'new note from a template', which is specific and actionable. It distinguishes from generic 'create_note' by specifying template-based creation, though it doesn't explicitly differentiate from all siblings like 'list_templates' or 'read_note'.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives like 'create_note' (for non-template creation) or 'list_templates' (to find templates). There's no mention of prerequisites, such as needing an existing template file, or context for template-based workflows.

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/getglad/obsidian_mcp'

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