get_design_rules
Retrieve specific design rules for Modus Web Components, including colors, icons, spacing, typography, and other design system guidelines.
Instructions
Get specific design rules for Modus Web Components (colors, icons, spacing, typography, etc.).
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| category | Yes | The design rule category (e.g., "colors", "icons", "spacing", "typography", "breakpoints", "radius_stroke") |
Implementation Reference
- src/index.ts:551-579 (handler)The core handler function implementing the 'get_design_rules' tool. It normalizes the category input, searches the loaded rules array for a matching rule document by category name or filename, and returns the markdown content as a tool response or an error listing available categories if not found.private async getDesignRules(category: string): Promise<any> { const normalizedCategory = category.toLowerCase(); const rule = this.rules.find( (r) => r.category.toLowerCase() === normalizedCategory || r.filename.toLowerCase().includes(normalizedCategory) ); if (!rule) { const availableCategories = this.rules.map((r) => r.category).join(", "); return { content: [ { type: "text", text: `Design rule category "${category}" not found.\n\nAvailable categories: ${availableCategories}`, }, ], }; } return { content: [ { type: "text", text: rule.content, }, ], }; }
- src/index.ts:223-237 (registration)Registration of the 'get_design_rules' tool in the ListToolsRequestSchema handler, including the tool name, description, and input schema definition.name: "get_design_rules", description: "Get specific design rules for Modus Web Components (colors, icons, spacing, typography, etc.).", inputSchema: { type: "object", properties: { category: { type: "string", description: 'The design rule category (e.g., "colors", "icons", "spacing", "typography", "breakpoints", "radius_stroke")', }, }, required: ["category"], }, },
- src/index.ts:320-321 (registration)Dispatch/registration in the CallToolRequestSchema switch statement that routes calls to the getDesignRules handler method with the category argument.case "get_design_rules": return await this.getDesignRules((args?.category as string) || "");
- src/index.ts:112-133 (helper)Helper method that loads design rules from markdown files in the rules directory into the this.rules array, which is used by the getDesignRules handler.private loadRules(): void { if (!existsSync(this.rulesPath)) { console.error(`Rules directory not found at: ${this.rulesPath}`); console.error("Please run: node download-docs.js"); return; } const files = readdirSync(this.rulesPath).filter((f) => f.endsWith(".md")); for (const file of files) { const content = readFileSync(join(this.rulesPath, file), "utf-8"); const category = file.replace(".md", "").replace("modus_", ""); this.rules.push({ filename: file, category, content, }); } console.error(`Loaded ${this.rules.length} design rules files`); }