Skip to main content
Glama

list_templates

Retrieve available templates from the TEMPLATE folder to create structured notes in Obsidian vaults.

Instructions

TEMPLATEフォルダ内の利用可能なテンプレート一覧を取得します

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • 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)}`); } }
  • ObsidianHandler method implementing list_templates tool by delegating to TemplateEngine.
    async listTemplates() { return await this.templateEngine.getAvailableTemplates(); }
  • 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: {}, }, },
  • 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 }; }
  • Input schema definition: empty object properties (tool takes no input parameters).
    inputSchema: { type: 'object', properties: {}, },

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