list_templates
Retrieve available templates from the TEMPLATE folder to create structured notes in Obsidian vaults.
Instructions
TEMPLATEフォルダ内の利用可能なテンプレート一覧を取得します
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/template-engine.ts:9-27 (handler)Core tool handler logic: scans the templates directory for .md files, reads each, parses variables and description, returns TemplateInfo array.async getAvailableTemplates(): Promise<TemplateInfo[]> { try { const files = await fs.readdir(this.templatesDir); const templates: TemplateInfo[] = []; for (const file of files) { if (file.endsWith('.md')) { const templatePath = path.join(this.templatesDir, file); const content = await fs.readFile(templatePath, 'utf-8'); const templateInfo = this.parseTemplate(file, templatePath, content); templates.push(templateInfo); } } return templates; } catch (error) { throw new Error(`テンプレートディレクトリの読み込みに失敗しました: ${error instanceof Error ? error.message : String(error)}`); } }
- src/obsidian-handler.ts:70-72 (handler)ObsidianHandler method implementing list_templates tool by delegating to TemplateEngine.async listTemplates() { return await this.templateEngine.getAvailableTemplates(); }
- src/server.ts:270-279 (handler)MCP server dispatch handler for list_templates tool call: invokes ObsidianHandler and formats response as JSON text content.case 'list_templates': const templates = await this.obsidianHandler.listTemplates(); return { content: [ { type: 'text', text: JSON.stringify(templates, null, 2), }, ], };
- src/server.ts:80-87 (registration)Tool registration in ListToolsResponse: defines name, description, and input schema (no params).{ name: 'list_templates', description: 'TEMPLATEフォルダ内の利用可能なテンプレート一覧を取得します', inputSchema: { type: 'object', properties: {}, }, },
- src/template-engine.ts:49-78 (helper)Supporting helper: parses individual template file to detect {{variable}} placeholders and extract YAML description.private parseTemplate(fileName: string, filePath: string, content: string): TemplateInfo { const variables: TemplateVariable[] = []; const variableRegex = /\{\{(\w+)\}\}/g; let match; while ((match = variableRegex.exec(content)) !== null) { const varName = match[1]; if (!variables.find(v => v.name === varName)) { variables.push({ name: varName, required: true }); } } // YAMLフロントマターから説明を抽出 const frontMatterMatch = content.match(/^---\n([\s\S]*?)\n---/); let description = ''; if (frontMatterMatch) { const yamlContent = frontMatterMatch[1]; const descMatch = yamlContent.match(/description:\s*(.+)/); if (descMatch) { description = descMatch[1].trim(); } } return { name: fileName.replace('.md', ''), path: filePath, variables, description }; }
- src/server.ts:83-86 (schema)Input schema definition: empty object properties (tool takes no input parameters).inputSchema: { type: 'object', properties: {}, },