Skip to main content
Glama

list_all_templates

Read-onlyIdempotent

List all available templates with name, description, type, and category. Optionally filter by category to narrow down Business, Creative, Professional, or Technical templates.

Instructions

List all 15 built-in MDMagic templates plus any custom templates the user has uploaded.

CALL THIS PROACTIVELY when:

  • The user mentions a template by name (verify it exists before convert_document)

  • The user asks 'what templates are available' or similar

  • A previous convert_document call returned 'template not found'

  • The user describes the look they want without naming a template (so you can suggest a real one)

Returns: name, description, type (built-in vs custom), and category. Categories are: Business (5 templates), Creative (6), Professional (2), Technical (2). Use the optional category filter to narrow recommendations (e.g. 'for legal documents' → category: 'Professional').

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
includeDetailsNoInclude template details like available page sizes and orientations (default: false)
categoryNoOptional filter — return only built-in templates in this category. Custom templates are always included regardless. Categories: Business (executive/financial), Creative (designer/artistic/novelty), Professional (legal), Technical (code/data documentation).

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
builtinCountNoNumber of built-in templates returned
customCountNoNumber of custom templates returned
templatesYesAll matching templates

Implementation Reference

  • The main handler function for the 'list_all_templates' tool. Fetches both built-in and custom templates from the API, optionally filters by category, groups them, and returns a formatted text output listing all available templates with their names, IDs, descriptions, and categories.
    export async function handleListAllTemplates(
      apiClient: MDMagicApiClient,
      args: any
    ): Promise<CallToolResult> {
      try {
        const input = listTemplatesSchema.parse(args);
        console.error(`[list_all_templates] Fetching all templates${input.category ? ` (category=${input.category})` : ''}...`);
    
        // Fetch both built-in and custom templates
        const [builtinResponse, customResponse] = await Promise.all([
          apiClient.getTemplates(),
          apiClient.getCustomTemplates()
        ]);
    
        let builtinTemplates = builtinResponse.templates || [];
        const customTemplates = customResponse.templates || [];
    
        if (input.category) {
          builtinTemplates = builtinTemplates.filter(
            t => (t.category || '').toLowerCase() === input.category!.toLowerCase()
          );
        }
    
        const allTemplates = [...builtinTemplates, ...customTemplates];
    
        if (allTemplates.length === 0) {
          const msg = input.category
            ? `📝 **No templates found in category "${input.category}"**\n\nTry calling \`list_all_templates\` without a category filter to see all available templates.`
            : "📝 **No templates available**\n\nNo templates found in the system.";
          return { content: [{ type: "text", text: msg }] };
        }
    
        let output = `📚 **Available Templates** (${allTemplates.length} total${input.category ? `, category=${input.category}` : ''})\n\n`;
    
        if (builtinTemplates.length > 0) {
          output += `## 🏢 Built-in Templates (${builtinTemplates.length})\n\n`;
          output += renderGroupedBuiltins(builtinTemplates);
        }
    
        if (customTemplates.length > 0) {
          output += `## 🎨 Your Custom Templates (${customTemplates.length})\n\n`;
          customTemplates.forEach(template => {
            output += `- **${template.name}** (\`${template.id}\`)`;
            if (template.description) output += ` — ${template.description}`;
            output += '\n';
          });
          output += '\n';
        }
    
        output += '💡 **Usage:** Pass the template ID (in backticks) as `templateName` to `convert_document`.';
    
        return { content: [{ type: "text", text: output }] };
    
      } catch (error: any) {
        console.error('[list_all_templates] Error:', error.message);
        throw error;
      }
    }
  • Zod validation schema (listTemplatesSchema) used by handleListAllTemplates. Defines two optional inputs: includeDetails (boolean, default false) and category (enum of Business/Creative/Professional/Technical).
    // Template listing schema
    export const listTemplatesSchema = z.object({
      includeDetails: z.boolean().default(false).describe("Include template details like page sizes and orientations"),
      category: z.enum(['Business', 'Creative', 'Professional', 'Technical']).optional().describe("Filter built-in templates by category. Custom templates are always included regardless.")
    });
  • Tool definition (inputSchema + outputSchema) for 'list_all_templates' in the tool definitions array returned by getToolDefinitions(). Describes input parameters (includeDetails, category) and output structure (builtinCount, customCount, templates array).
    {
      name: "list_all_templates",
      description: "List all 15 built-in MDMagic templates plus any custom templates the user has uploaded.\n\nCALL THIS PROACTIVELY when:\n- The user mentions a template by name (verify it exists before convert_document)\n- The user asks 'what templates are available' or similar\n- A previous convert_document call returned 'template not found'\n- The user describes the look they want without naming a template (so you can suggest a real one)\n\nReturns: name, description, type (built-in vs custom), and category. Categories are: Business (5 templates), Creative (6), Professional (2), Technical (2). Use the optional category filter to narrow recommendations (e.g. 'for legal documents' → category: 'Professional').",
      annotations: {
        title: "List all MDMagic templates",
        readOnlyHint: true,
        destructiveHint: false,
        idempotentHint: true,
        openWorldHint: true
      },
      inputSchema: {
        type: "object" as const,
        properties: {
          includeDetails: {
            type: "boolean",
            description: "Include template details like available page sizes and orientations (default: false)"
          },
          category: {
            type: "string",
            enum: CATEGORY_ENUM,
            description: "Optional filter — return only built-in templates in this category. Custom templates are always included regardless. Categories: Business (executive/financial), Creative (designer/artistic/novelty), Professional (legal), Technical (code/data documentation)."
          }
        }
      },
      outputSchema: {
        type: "object" as const,
        properties: {
          builtinCount: { type: "integer", description: "Number of built-in templates returned" },
          customCount: { type: "integer", description: "Number of custom templates returned" },
          templates: { type: "array", items: TEMPLATE_OBJECT_SCHEMA, description: "All matching templates" }
        },
        required: ["templates"]
      }
    },
  • Registration of 'list_all_templates' in the unified handler switch statement. Maps the tool name string to handleListAllTemplates function call.
    case 'list_all_templates':
      return await handleListAllTemplates(apiClient, request.params.arguments);
  • src/tools/index.ts:7-7 (registration)
    Import of handleListAllTemplates from listTemplates module into the registration index.
    import { handleListAllTemplates, handleListBuiltinTemplates, handleListCustomTemplates } from './listTemplates.js';
Behavior4/5

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

Adds value beyond annotations by describing return fields (name, description, type, category) and category counts, plus noting custom templates always included regardless of filter.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Front-loaded with main purpose, uses bullet points for usage scenarios, but could be slightly more concise without losing clarity.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Sufficiently covers what the tool returns and usage patterns, though output schema is not fully utilized for additional structure.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema has 100% coverage but description reinforces usage of category filter for narrowing recommendations and adds context about custom templates.

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

Purpose5/5

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

The description specifies it lists 15 built-in MDMagic templates plus custom templates, distinguishing it from siblings like list_builtin_templates and list_custom_templates.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Provides explicit when-to-call scenarios: verify template existence, answer 'what templates', handle 'template not found' errors, and suggest templates when user describes look without naming one.

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/MDMagic-MCP/mdmagic-mcp-server'

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