Skip to main content
Glama

get_template

Retrieve component templates for UI development to reference design patterns and ensure compliance with specifications.

Instructions

Get a component template for reference

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
templateYesTemplate name

Implementation Reference

  • The main handler function for the 'get_template' tool. It takes the template name from args, selects the appropriate generator function based on a switch statement, generates the component code, formats it as a markdown response with description and code block, and returns a 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 }], }; }
  • Input schema definition for the 'get_template' tool, specifying the required 'template' parameter as a string with allowed enum values.
    inputSchema: { type: 'object', properties: { template: { type: 'string', description: 'Template name', enum: ['button', 'card', 'input', 'basic', 'composable'], }, }, required: ['template'], },
  • 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'], }, },

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