Skip to main content
Glama

list_custom_templates

Read-onlyIdempotent

List your custom-uploaded Word templates referenced by UUID. Retrieve template details like available page sizes and orientations.

Instructions

List only the user's custom-uploaded Word templates. Use this when the user asks about their own templates ('show me my templates', 'do I have a letterhead?'). Custom templates are referenced by UUID, not name, when calling convert_document.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
includeDetailsNoInclude template details like available page sizes and orientations (default: false)

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
countNoNumber of custom templates returned
templatesYesUser's custom templates

Implementation Reference

  • The handler function that executes the 'list_custom_templates' tool logic. It parses input, calls apiClient.getCustomTemplates(), and returns a formatted list of custom templates.
    export async function handleListCustomTemplates(
      apiClient: MDMagicApiClient,
      args: any
    ): Promise<CallToolResult> {
      try {
        const input = listCustomTemplatesSchema.parse(args);
        console.error('[list_custom_templates] Fetching custom templates...');
    
        const response = await apiClient.getCustomTemplates();
        const templates = response.templates || [];
    
        if (templates.length === 0) {
          return {
            content: [
              {
                type: "text",
                text: `🎨 **No custom templates available**
    
    You don't have any custom templates yet. Custom templates are user-specific templates that you can upload through the MDMagic dashboard.
    
    💡 **To add custom templates:**
    1. Visit your MDMagic dashboard
    2. Go to Templates section  
    3. Upload your custom Word (.docx) templates`
              }
            ]
          };
        }
    
        let output = `🎨 **Your Custom Templates** (${templates.length} available)\n\n`;
        
        templates.forEach(template => {
          output += `**${template.name}** (\`${template.id}\`)\n`;
          if (template.description) {
            output += `  ${template.description}\n`;
          }
          output += `  📁 Type: ${template.type}\n\n`;
        });
    
        output += '💡 **Usage:** Use the template ID (in backticks) with the `convert_document` tool.';
    
        return {
          content: [
            {
              type: "text",
              text: output
            }
          ]
        };
    
      } catch (error: any) {
        console.error('[list_custom_templates] Error:', error.message);
        throw error;
      }
    }
  • Zod schema for validating list_custom_templates input: accepts optional includeDetails boolean.
    export const listCustomTemplatesSchema = z.object({
      includeDetails: z.boolean().default(false).describe("Include template details")
    });
  • Switch-case registration in the unified handler that routes 'list_custom_templates' to handleListCustomTemplates.
            case 'list_custom_templates':
              return await handleListCustomTemplates(apiClient, request.params.arguments);
              
            case 'show_default_settings':
              return await handleShowDefaultSettings(apiClient, request.params.arguments);
              
            case 'check_credit_balance':
              return await handleCheckCreditBalance(creditCalculator, request.params.arguments);
              
            case 'estimate_conversion_cost':
              return await handleEstimateConversionCost(creditCalculator, request.params.arguments);
    
            case 'validate_markdown':
              return await handleValidateMarkdown(apiClient, request.params.arguments);
    
            case 'get_template_details':
              return await handleGetTemplateDetails(apiClient, request.params.arguments);
    
            case 'recommend_template':
              return await handleRecommendTemplate(apiClient, request.params.arguments);
    
            default:
              throw new Error(`Unknown tool: ${toolName}`);
          }
        } catch (error: any) {
          console.error(`[MCP] Error handling ${toolName}:`, error);
          return {
            content: [
              {
                type: "text",
                text: `❌ Error: ${error.message}`
              }
            ],
            isError: true
          };
        }
      });
    
      console.error('✅ All MCP tools registered successfully with unified handler');
      console.error('📋 Available tools: convert_document, list_all_templates, list_builtin_templates, list_custom_templates, show_default_settings, check_credit_balance, estimate_conversion_cost, validate_markdown, get_template_details, recommend_template');
    }
  • src/index.ts:171-198 (registration)
    Tool definition registration including name, description, annotations, inputSchema, and outputSchema exposed to the MCP protocol.
    {
      name: "list_custom_templates",
      description: "List only the user's custom-uploaded Word templates. Use this when the user asks about their own templates ('show me my templates', 'do I have a letterhead?'). Custom templates are referenced by UUID, not name, when calling convert_document.",
      annotations: {
        title: "List user's custom 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)"
          }
        }
      },
      outputSchema: {
        type: "object" as const,
        properties: {
          count: { type: "integer", description: "Number of custom templates returned" },
          templates: { type: "array", items: TEMPLATE_OBJECT_SCHEMA, description: "User's custom templates" }
        },
        required: ["templates"]
      }
    },
Behavior4/5

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

Annotations already indicate readOnlyHint and idempotentHint; description adds behavioral context that it only lists custom templates and that templates are referenced by UUID. No contradictions with annotations.

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 two sentences, front-loaded with purpose, and includes essential usage guidance without any unnecessary words.

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

Completeness5/5

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

Given the simple tool (1 optional parameter, output schema exists, annotations cover safety), the description is complete: it specifies the scope (custom only), links to a related tool, and the schema and annotations provide full parameter and behavioral details.

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 one parameter (includeDetails) with full description coverage (100%). The tool description does not add extra meaning to this parameter, so baseline score of 3 applies.

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 clearly states the verb 'List' and the specific resource 'user's custom-uploaded Word templates'. It distinguishes itself from sibling tools like list_all_templates and list_builtin_templates by focusing on custom templates and mentioning UUID referencing.

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

Usage Guidelines4/5

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

Description explicitly provides scenarios for use ('when the user asks about their own templates') and gives guidance on using templates with convert_document via UUID. It does not list when not to use, but the context is clear enough for decision-making.

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