Skip to main content
Glama
libra850
by libra850

create_note_from_template

Create Obsidian notes using templates with variable replacement to standardize formatting and content structure.

Instructions

テンプレートを使用してObsidianノートを作成します

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
templateNameYesTEMPLATEフォルダ内のテンプレート名(.md拡張子なし)
variablesYesテンプレート内の変数を置換するためのオブジェクト
outputPathYesノートの保存先パス(vault相対パス)
overwriteNo既存ファイルを上書きするかどうか

Implementation Reference

  • Primary handler function executing the tool: validates output path, processes template with variables using TemplateEngine, builds full path, ensures directory exists, checks for overwrite if specified, writes content to file, returns success message.
    async createNoteFromTemplate(options: CreateNoteOptions): Promise<string> {
      // パスの検証
      if (!FileUtils.validatePath(this.config.vaultPath, options.outputPath)) {
        throw new Error('無効なファイルパスです');
      }
    
      // テンプレートを処理
      const content = await this.templateEngine.processTemplate(
        options.templateName,
        options.variables
      );
    
      // 出力パスを構築
      const fullOutputPath = path.join(this.config.vaultPath, options.outputPath);
      const outputDir = path.dirname(fullOutputPath);
    
      // ディレクトリを作成
      await FileUtils.ensureDir(outputDir);
    
      // ファイルの存在チェック
      if (!options.overwrite && await FileUtils.fileExists(fullOutputPath)) {
        throw new Error(`ファイル '${options.outputPath}' は既に存在します`);
      }
    
      // ファイルを書き込み
      await fs.writeFile(fullOutputPath, content, 'utf-8');
    
      return `ノート '${options.outputPath}' を作成しました`;
    }
  • src/server.ts:54-79 (registration)
    Tool registration definition in the ListTools handler, specifying name, description, and detailed input schema for parameters.
      name: 'create_note_from_template',
      description: 'テンプレートを使用してObsidianノートを作成します',
      inputSchema: {
        type: 'object',
        properties: {
          templateName: {
            type: 'string',
            description: 'TEMPLATEフォルダ内のテンプレート名(.md拡張子なし)',
          },
          variables: {
            type: 'object',
            description: 'テンプレート内の変数を置換するためのオブジェクト',
          },
          outputPath: {
            type: 'string',
            description: 'ノートの保存先パス(vault相対パス)',
          },
          overwrite: {
            type: 'boolean',
            description: '既存ファイルを上書きするかどうか',
            default: false,
          },
        },
        required: ['templateName', 'variables', 'outputPath'],
      },
    },
  • TypeScript interface defining the input parameters for the createNoteFromTemplate handler, matching the tool's inputSchema.
    export interface CreateNoteOptions {
      templateName: string;
      variables: Record<string, any>;
      outputPath: string;
      overwrite?: boolean;
    }
  • Dispatch handler in the MCP server that maps tool call arguments to the ObsidianHandler method and returns the result as MCP content.
    case 'create_note_from_template':
      const result = await this.obsidianHandler.createNoteFromTemplate({
        templateName: args.templateName as string,
        variables: (args.variables as Record<string, any>) || {},
        outputPath: args.outputPath as string,
        overwrite: (args.overwrite as boolean) || false,
      });
      return {
        content: [{ type: 'text', text: result }],
      };
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 mentions 'creates' which implies a write operation, but doesn't disclose critical behavioral traits: what happens if the template doesn't exist, how variable substitution works, whether the operation is atomic, what permissions are needed, or what happens on failure. For a creation tool with zero annotation coverage, this is insufficient.

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 in Japanese that directly states the tool's core function. There's no wasted words or unnecessary elaboration. It's appropriately sized for a tool with good schema documentation.

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?

For a creation tool with 4 parameters, no annotations, and no output schema, the description is inadequate. It doesn't explain what the tool returns (success/failure, created note details), error conditions, or behavioral constraints. The user must rely entirely on the input schema without contextual guidance about the operation's outcomes or limitations.

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 fully documents all 4 parameters. The description adds no additional parameter information beyond what's in the schema (it doesn't explain template location, variable format, path conventions, or overwrite implications). This meets the baseline for high schema coverage but doesn't enhance understanding.

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 tool's purpose: 'creates an Obsidian note using a template' (verb+resource). It specifies the method ('using a template') which distinguishes it from generic note creation tools. However, it doesn't explicitly differentiate from sibling tools like 'create_moc' or 'update_note' that might also involve note creation/modification.

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. It doesn't mention when this template-based approach is preferred over direct note creation, nor does it reference any sibling tools (like 'list_templates' for available templates or 'create_moc' for other note types). The user must infer usage from the tool name alone.

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

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