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
| Name | Required | Description | Default |
|---|---|---|---|
| ruleId | Yes | The rule ID (e.g., "extends-html-props", "has-data-slot") |
Implementation Reference
- src/tools/index.ts:306-348 (handler)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 }], }; }
- src/tools/index.ts:76-89 (schema)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'], }, },
- src/tools/index.ts:239-240 (registration)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); }