Skip to main content
Glama

get_template

Retrieve UI component templates for reference when building accessible, framework-agnostic components according to the components.build specification.

Instructions

Get a component template for reference

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
templateYesTemplate name

Implementation Reference

  • Registration of the 'get_template' tool in the getToolDefinitions() array, including name, description, and input schema.
    {
      name: 'get_template',
      description: 'Get a component template for reference',
      inputSchema: {
        type: 'object',
        properties: {
          template: {
            type: 'string',
            description: 'Template name',
            enum: ['button', 'card', 'input', 'basic', 'composable'],
          },
        },
        required: ['template'],
      },
    },
  • The handler function that executes the get_template tool logic: extracts the template name from args, generates the corresponding component template code using imported generators, formats it with description, and returns as ToolResult.
    function handleGetTemplate(args: Record<string, unknown>): ToolResult {
      const template = args.template as string;
    
      let code: string;
      let description: string;
    
      switch (template) {
        case 'button':
          code = generateButtonComponent();
          description = 'A fully accessible button component with variants, sizes, and asChild support.';
          break;
        case 'card':
          code = generateCardComponent();
          description = 'A composable card component with Header, Title, Description, Content, and Footer sub-components.';
          break;
        case 'input':
          code = generateInputComponent();
          description = 'An accessible input component with proper focus states and styling.';
          break;
        case 'composable':
          code = generateComposableComponent({ name: 'Example' });
          description = 'A composable component template with Root, Trigger, and Content pattern using Context.';
          break;
        case 'basic':
        default:
          code = generateBasicComponent({ name: 'Example', hasVariants: true });
          description = 'A basic component template with CVA variants.';
          break;
      }
    
      const text = `# Template: ${template}
    
    ${description}
    
    \`\`\`tsx
    ${code}
    \`\`\`
    `;
    
      return {
        content: [{ type: 'text', text }],
      };
    }
  • Dispatch registration in the executeTool switch statement, routing 'get_template' calls to handleGetTemplate.
    case 'get_template':
      return handleGetTemplate(args);

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/audreyui/components-build-mcp'

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