Skip to main content
Glama

list_templates

Display all available templates in your Obsidian vault to quickly access and apply them for consistent note formatting and structure.

Instructions

List all available templates

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
vaultYesVault name

Implementation Reference

  • Core handler logic for listing templates: scans Templates folder for .md files using glob, parses each with parseMarkdown, extracts metadata, and returns structured Template objects or empty list if folder missing.
    async listTemplates(vaultPath: string): Promise<VaultOperationResult<Template[]>> { try { const templatesPath = path.join(vaultPath, this.config.templatesFolder); // Check if templates folder exists try { await fs.access(templatesPath); } catch { return { success: true, data: [] }; } const { glob } = await import('glob'); const pattern = path.join(templatesPath, '**/*.md'); const files = await glob(pattern); const templates: Template[] = []; for (const file of files) { const content = await fs.readFile(file, 'utf-8'); const relativePath = path.relative(vaultPath, file); const parsed = parseMarkdown(content); const template: Template = { name: path.basename(file, '.md'), path: relativePath, content, tags: parsed.tags, folder: path.dirname(relativePath), }; // Extract template variables from frontmatter if (parsed.frontmatter?.templateVariables) { template.variables = parsed.frontmatter.templateVariables; } templates.push(template); } return { success: true, data: templates }; } catch (error) { return { success: false, error: `Failed to list templates: ${error instanceof Error ? error.message : String(error)}` }; } }
  • MCP tool handler in switch statement: retrieves vault connector, calls TemplateService.listTemplates, stringifies and returns result as text content.
    case 'list_templates': { 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.listTemplates(connector.vaultPath); return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }], }; }
  • src/index.ts:353-362 (registration)
    Tool registration in ListToolsResponse: defines name, description, and input schema requiring 'vault'.
    name: 'list_templates', description: 'List all available templates', inputSchema: { type: 'object', properties: { vault: { type: 'string', description: 'Vault name' }, }, required: ['vault'], }, },

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