Skip to main content
Glama

create_note_from_template

Create Obsidian notes using templates with variable replacement to standardize note structure and save time on repetitive formatting.

Instructions

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

Input Schema

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

Implementation Reference

  • The core handler function that processes the template with provided variables, validates the output path and permissions, ensures the target directory exists, handles overwrite checks, and writes the resulting note content to the Obsidian vault.
    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)
    Registers the create_note_from_template tool in the MCP server's tool list, including its name, description, and detailed input schema for validation.
    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 structure of input options for the createNoteFromTemplate handler, matching the MCP input schema.
    export interface CreateNoteOptions { templateName: string; variables: Record<string, any>; outputPath: string; overwrite?: boolean; }
  • Dispatches incoming tool calls for 'create_note_from_template' to the ObsidianHandler instance, mapping MCP arguments to handler parameters and returning the result.
    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 }], };

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