Skip to main content
Glama
bazylhorsey
by bazylhorsey

create_from_template

Generate new notes in Obsidian using predefined templates with custom variables and frontmatter for consistent document creation.

Instructions

Create a new note from a template

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
frontmatterNoAdditional frontmatter
targetPathYesPath for new note
templatePathYesPath to template file
variablesNoTemplate variables
vaultYesVault name

Implementation Reference

  • MCP tool handler for 'create_from_template' that retrieves the vault connector and delegates execution to TemplateService.createFromTemplate, returning the result as MCP content.
    case 'create_from_template': {
      const connector = this.connectors.get(args?.vault as string);
      if (!connector || !connector.vaultPath) {
        throw new Error(`Vault "${args?.vault}" not found or not a local vault`);
      }
    
      const result = await this.templateService.createFromTemplate(
        connector.vaultPath,
        args?.templatePath as string,
        args?.targetPath as string,
        {
          variables: args?.variables as Record<string, any> | undefined,
          frontmatter: args?.frontmatter as Record<string, any> | undefined,
        }
      );
    
      return {
        content: [{ type: 'text', text: JSON.stringify(result, null, 2) }],
      };
    }
  • src/index.ts:379-392 (registration)
    Registration of the 'create_from_template' tool in the MCP server's tools list, including name, description, and input schema.
      name: 'create_from_template',
      description: 'Create a new note from a template',
      inputSchema: {
        type: 'object',
        properties: {
          vault: { type: 'string', description: 'Vault name' },
          templatePath: { type: 'string', description: 'Path to template file' },
          targetPath: { type: 'string', description: 'Path for new note' },
          variables: { type: 'object', description: 'Template variables' },
          frontmatter: { type: 'object', description: 'Additional frontmatter' },
        },
        required: ['vault', 'templatePath', 'targetPath'],
      },
    },
  • Main helper function in TemplateService that renders a template using renderTemplate and writes the rendered content to the specified target path in the vault.
    async createFromTemplate(
      vaultPath: string,
      templatePath: string,
      targetPath: string,
      options?: TemplateRenderOptions
    ): Promise<VaultOperationResult<string>> {
      try {
        // Render template
        const renderResult = await this.renderTemplate(vaultPath, templatePath, {
          ...options,
          targetPath,
        });
    
        if (!renderResult.success || !renderResult.data) {
          return { success: false, error: renderResult.error };
        }
    
        // Write to target path
        const fullTargetPath = path.join(vaultPath, targetPath);
    
        // Ensure directory exists
        await fs.mkdir(path.dirname(fullTargetPath), { recursive: true });
    
        // Write file
        await fs.writeFile(fullTargetPath, renderResult.data.content, 'utf-8');
    
        return { success: true, data: targetPath };
      } catch (error) {
        return {
          success: false,
          error: `Failed to create from template: ${error instanceof Error ? error.message : String(error)}`
        };
      }
    }
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. 'Create' implies a write operation, but it doesn't disclose behavioral traits like whether this requires specific permissions, what happens if the template or target path doesn't exist, or if the operation is idempotent. The description lacks context on error handling or side effects.

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 that states the core functionality without unnecessary words. It's appropriately sized and front-loaded, making it easy to parse quickly.

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

Completeness2/5

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

Given the complexity (5 parameters including nested objects, no annotations, no output schema), the description is incomplete. It doesn't address behavioral aspects like error conditions, return values, or how it differs from other note-creation tools. For a mutation tool with rich parameters, more context is needed.

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 100%, so the schema already documents all 5 parameters with descriptions. The description adds no additional meaning beyond what's in the schema (e.g., it doesn't explain how template variables interact with frontmatter or path conventions). Baseline 3 is appropriate when the schema does the heavy lifting.

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 action ('create') and resource ('new note from a template'), making the purpose immediately understandable. However, it doesn't differentiate from sibling tools like 'create_note' or 'create_daily_note', which also create notes but with different approaches or constraints.

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. With sibling tools like 'create_note' (general note creation) and 'create_daily_note' (periodic note creation), there's no indication of when template-based creation is preferred or what prerequisites might be needed (e.g., existing templates).

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/bazylhorsey/obsidian-mcp-server'

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