Skip to main content
Glama

list_templates

Browse available project templates to start new projects quickly. Filter by category to find relevant templates for your needs.

Instructions

List available project templates

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
categoryNoFilter by category

Implementation Reference

  • Implementation of the logic for listing templates.
    async function listTemplatesImpl(input: ListTemplatesInput): Promise<ToolResult> {
      try {
        const templates: Array<{
          name: string;
          path: string;
          description: string;
          category?: string;
          variables?: Array<{ name: string; description: string }>;
        }> = [];
    
        for (const basePath of getTemplatePaths()) {
          try {
            const entries = await fs.readdir(basePath, { withFileTypes: true });
    
            for (const entry of entries) {
              if (!entry.isDirectory()) continue;
    
              const templatePath = path.join(basePath, entry.name);
              const metadataPath = path.join(templatePath, 'template.json');
    
              let metadata: TemplateMetadata = {
                name: entry.name,
                description: 'Template directory',
              };
    
              try {
                const metadataContent = await fs.readFile(metadataPath, 'utf-8');
                metadata = JSON.parse(metadataContent) as TemplateMetadata;
              } catch {
                // No metadata file, use defaults
              }
    
              // Filter by category if specified
              if (input.category && metadata.category !== input.category) {
                continue;
              }
    
              templates.push({
                name: metadata.name,
                path: templatePath,
                description: metadata.description,
                category: metadata.category,
                variables: metadata.variables?.map((v) => ({
                  name: v.name,
                  description: v.description,
                })),
              });
            }
          } catch {
            // Template path doesn't exist, skip
          }
        }
    
        return {
          content: [
            {
              type: 'text',
              text: JSON.stringify(
                {
                  template_paths: getTemplatePaths(),
                  count: templates.length,
                  templates,
                },
                null,
                2
              ),
            },
          ],
        };
      } catch (error) {
        const err = error as Error;
    
        return {
          isError: true,
          content: [
            {
              type: 'text',
              text: JSON.stringify({
                code: 'UNKNOWN_ERROR',
                message: `Error listing templates: ${err.message}`,
              }),
            },
          ],
        };
      }
    }
  • Registration of the 'list_templates' tool with the MCP server.
    // list_templates tool
    server.tool(
      'list_templates',
      'List available project templates',
      {
        category: z.string().optional().describe('Filter by category'),
      },
      async (args) => {
        const input = ListTemplatesInputSchema.parse(args);
        return await listTemplatesImpl(input);
      }
    );
  • Input schema definition for the list_templates tool.
    export const ListTemplatesInputSchema = z.object({
      category: z.string().optional().describe('Filter by category'),
    });
    
    export type ListTemplatesInput = z.infer<typeof ListTemplatesInputSchema>;
Behavior2/5

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

No annotations are provided, so the description carries full burden for behavioral disclosure. It states it's a listing operation, implying read-only behavior, but doesn't specify whether it returns all templates or paginated results, what format the output takes, or any rate limits or authentication requirements. For a tool with zero annotation coverage, this leaves significant gaps in understanding how it behaves.

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 wasted words. It's front-loaded with the core purpose ('List available project templates'), making it immediately clear. Every word earns its place, and there's no unnecessary elaboration.

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 the lack of annotations and output schema, the description is incomplete for a listing tool. It doesn't explain what 'available' means (e.g., user-specific vs. system-wide), the return format, or any behavioral traits like pagination. For a tool with no structured output documentation, the description should provide more context about what to expect from the operation.

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 one parameter ('category') documented as 'Filter by category'. The description doesn't add any meaning beyond this—it doesn't explain what categories exist, how filtering works, or provide examples. With high schema coverage, the baseline is 3, and the description doesn't compensate with additional context.

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

Purpose4/5

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

The description 'List available project templates' clearly states the verb ('List') and resource ('project templates'), making the purpose immediately understandable. However, it doesn't differentiate from sibling tools like 'scaffold_project' or 'glob_search' that might also involve templates, leaving room for ambiguity about when to use this specific listing tool.

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. With siblings like 'scaffold_project' (which might use templates) and 'glob_search' (which could search for templates), there's no indication of when listing is preferred over searching or other operations. No prerequisites or exclusions are mentioned.

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/mcp-tool-shop-org/mcp-file-forge'

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