Skip to main content
Glama

get_rules

Retrieve component development rules documentation to understand and follow guidelines for UI components. Filter by category and choose output format.

Instructions

Get component rules documentation. Use this to understand what rules exist and how to follow them. Can filter by category.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
categoryNoFilter rules by category
formatNoOutput format

Implementation Reference

  • The handler function for the 'get_rules' MCP tool. It processes input arguments for category and format, fetches rules using helper functions, formats the output accordingly (markdown, json, or summary), and returns a ToolResult.
    function handleGetRules(args: Record<string, unknown>): ToolResult { const category = args.category as string | undefined; const format = (args.format as string) || 'markdown'; let rules: Rule[]; if (category && category !== 'all') { rules = getRulesByCategory(category as Rule['category']); } else { rules = getAllRules(); } let text: string; if (format === 'json') { text = JSON.stringify(rules, null, 2); } else if (format === 'summary') { text = rules .map((r) => `- **${r.name}** (\`${r.id}\`): ${r.description}`) .join('\n'); } else { text = getRulesMarkdown(); } return { content: [{ type: 'text', text }], }; }
  • The schema definition for the 'get_rules' tool, specifying input parameters category (enum including 'all') and format (markdown/json/summary). Returned by getToolDefinitions() for MCP tool registration.
    { name: 'get_rules', description: 'Get component rules documentation. Use this to understand what rules exist and how to follow them. Can filter by category.', inputSchema: { type: 'object', properties: { category: { type: 'string', description: 'Filter rules by category', enum: ['types', 'styling', 'accessibility', 'composition', 'state', 'naming', 'all'], }, format: { type: 'string', description: 'Output format', enum: ['markdown', 'json', 'summary'], }, }, }, },
  • Registration of the 'get_rules' handler in the executeTool switch statement dispatcher.
    case 'get_rules': return handleGetRules(args);
  • Helper function getRulesMarkdown() generates full Markdown documentation for all rules, grouped by category, including examples. Used as default output for get_rules tool.
    export function getRulesMarkdown(): string { let md = `# Component Rules Reference > Based on components.build specification by Hayden Bleasel and shadcn. --- `; const categories = [...new Set(RULES.map(r => r.category))]; for (const category of categories) { const categoryRules = RULES.filter(r => r.category === category); md += `## ${category.charAt(0).toUpperCase() + category.slice(1)} Rules\n\n`; for (const rule of categoryRules) { md += `### ${rule.name}\n`; md += `**ID:** \`${rule.id}\` | **Severity:** ${rule.severity} | **Weight:** ${rule.weight}\n\n`; md += `${rule.description}\n\n`; md += `**Bad:**\n\`\`\`tsx\n${rule.example.bad}\n\`\`\`\n\n`; md += `**Good:**\n\`\`\`tsx\n${rule.example.good}\n\`\`\`\n\n`; md += `---\n\n`; } } return md; }
  • Helper function getRulesByCategory() filters the RULES array by the given category. Used when category parameter is provided in get_rules tool.
    export function getRulesByCategory(category: Rule['category']): Rule[] { return RULES.filter(r => r.category === category); }

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