Skip to main content
Glama

get_rule

Retrieve detailed specifications for UI component rules to validate compliance with the components.build framework.

Instructions

Get details about a specific rule by ID

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
ruleIdYesThe rule ID (e.g., "extends-html-props", "has-data-slot")

Implementation Reference

  • Main handler for the 'get_rule' MCP tool. Extracts ruleId from args, fetches the rule using getRule helper, handles not found case, and formats detailed markdown output including ID, category, severity, weight, description, bad/good examples.
    function handleGetRule(args: Record<string, unknown>): ToolResult {
      const ruleId = args.ruleId as string;
      const rule = getRule(ruleId);
    
      if (!rule) {
        return {
          content: [
            {
              type: 'text',
              text: `Rule not found: ${ruleId}\n\nAvailable rules:\n${getAllRules()
                .map((r) => `- ${r.id}`)
                .join('\n')}`,
            },
          ],
          isError: true,
        };
      }
    
      const text = `# ${rule.name}
    
    **ID:** \`${rule.id}\`
    **Category:** ${rule.category}
    **Severity:** ${rule.severity}
    **Weight:** ${rule.weight}
    
    ## Description
    ${rule.description}
    
    ## Bad Example
    \`\`\`tsx
    ${rule.example.bad}
    \`\`\`
    
    ## Good Example
    \`\`\`tsx
    ${rule.example.good}
    \`\`\`
    `;
    
      return {
        content: [{ type: 'text', text }],
      };
    }
  • Input schema definition for the 'get_rule' tool, specifying required 'ruleId' string parameter.
    {
      name: 'get_rule',
      description: 'Get details about a specific rule by ID',
      inputSchema: {
        type: 'object',
        properties: {
          ruleId: {
            type: 'string',
            description: 'The rule ID (e.g., "extends-html-props", "has-data-slot")',
          },
        },
        required: ['ruleId'],
      },
    },
  • Registration of the 'get_rule' tool handler in the main executeTool switch statement.
    case 'get_rule':
      return handleGetRule(args);
  • Helper function that retrieves a specific Rule object by its ID from the RULES array. Called by the get_rule handler.
    export function getRule(id: string): Rule | undefined {
      return RULES.find(r => r.id === id);
    }

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