Skip to main content
Glama

get_rule

Retrieve detailed information about a specific UI component rule by its ID to check compliance with the components.build specification.

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

  • The handler function for the 'get_rule' MCP tool. It takes ruleId from args, fetches the rule using getRule helper, formats it into a detailed markdown response with name, ID, category, severity, weight, description, bad/good examples, or returns error with available rules list if not found.
    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 }], }; }
  • The tool definition including name 'get_rule', description, and inputSchema requiring '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 in the executeTool switch dispatcher, calling the handleGetRule function.
    case 'get_rule': return handleGetRule(args);
  • Helper function getRule that retrieves a specific Rule object by its ID from the RULES array, used by the tool 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