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
| 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)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 }], }; }
- src/tools/index.ts:76-89 (schema)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'], }, },
- src/tools/index.ts:239-240 (registration)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); }