Skip to main content
Glama

get_rules

Retrieve component rules documentation to understand existing guidelines and compliance requirements, with filtering by category options.

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 handleGetRules function that executes the logic for the 'get_rules' MCP tool. It handles category filtering, format selection (markdown/json/summary), fetches rules using helpers, and constructs the ToolResult response.
    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 inputSchema defining parameters for the 'get_rules' tool: optional 'category' to filter rules and optional 'format' for output type.
    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' tool in the getToolDefinitions() array, including name, description, and inputSchema.
      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/dispatch of 'get_rules' in the executeTool switch statement.
    case 'get_rules':
      return handleGetRules(args);
  • Helper function getRulesMarkdown() used by the handler to generate full Markdown documentation of all rules, grouped by category with examples.
    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;
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries full burden. It states this is a 'Get' operation (implying read-only) and mentions filtering/output format, but doesn't disclose behavioral aspects like whether it returns all rules by default, pagination behavior, error conditions, or authentication requirements. The description provides basic intent but lacks operational details.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately concise (two sentences) and front-loaded with the core purpose. Every sentence adds value: first states the action and goal, second adds filtering capability. No wasted words, though it could be slightly more structured.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a read operation with 2 optional parameters and 100% schema coverage but no output schema, the description provides adequate context about what the tool does and filtering options. However, it doesn't describe the return format or structure (beyond the format parameter), which would be helpful since there's no output schema. The description is minimally complete but could better address output expectations.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already fully documents both parameters with descriptions and enums. The description mentions filtering by category and implies format selection ('Can filter by category'), but adds no additional semantic context beyond what the schema provides. Baseline 3 is appropriate when schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Get component rules documentation' (verb+resource). It specifies the scope ('understand what rules exist and how to follow them') and mentions filtering capability, but doesn't explicitly distinguish it from siblings like 'get_rule' or 'list_rules'.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage context ('understand what rules exist and how to follow them') and mentions filtering, but doesn't provide explicit guidance on when to use this tool versus alternatives like 'get_rule' (singular) or 'list_rules'. No when-not-to-use or prerequisite information is included.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/getlokiui/components-build-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server