Skip to main content
Glama
bazylhorsey
by bazylhorsey

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'],
      },
    },
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states it's a list operation, implying read-only behavior, but doesn't cover aspects like pagination, rate limits, authentication needs, or what 'available' means (e.g., filtered by permissions). This is a significant gap for a tool with no annotation coverage.

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 with zero waste. It's front-loaded and appropriately sized for a simple list operation, making it easy for an agent to parse quickly.

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?

Given no annotations and no output schema, the description is incomplete. It doesn't explain what 'templates' refers to in this context, what the output format might be, or any behavioral constraints. For a tool with one required parameter and multiple sibling tools, more context is needed to be fully helpful.

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?

The input schema has 100% description coverage, with the 'vault' parameter clearly documented. The description adds no additional meaning beyond the schema, such as explaining why a vault is required or how it affects the listing. Baseline 3 is appropriate since the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose3/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description 'List all available templates' clearly states the verb ('List') and resource ('templates'), but it's vague about scope and context. It doesn't specify what kind of templates (e.g., note templates, canvas templates) or differentiate from sibling tools like 'create_from_template' or 'render_template', leaving the purpose somewhat ambiguous.

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 prerequisites (e.g., needing a vault), exclusions, or how it relates to sibling tools such as 'create_from_template' or 'list_canvas_files', leaving the agent to infer usage from context 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/bazylhorsey/obsidian-mcp-server'

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