search_design_rules
Search design rules by keyword to find guidelines for colors, spacing, icons, and other design system elements.
Instructions
Search across all design rules by keyword or term.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | Search query for design rules (e.g., "primary color", "icon size", "spacing scale") |
Implementation Reference
- src/index.ts:581-639 (handler)The handler function that performs keyword search across all loaded design rules, extracts relevant matches, and formats results with category names and descriptions.private async searchDesignRules(query: string): Promise<any> { const normalizedQuery = query.toLowerCase(); const results: Array<{ category: string; filename: string; relevance: string; }> = []; for (const rule of this.rules) { const content = rule.content.toLowerCase(); const categoryName = rule.category.toLowerCase(); if ( categoryName.includes(normalizedQuery) || content.includes(normalizedQuery) ) { // Extract the first meaningful line as description const lines = rule.content.split("\n"); let description = ""; for (const line of lines) { if (line.trim() && !line.startsWith("#") && !line.startsWith("---")) { description = line.trim(); break; } } results.push({ category: rule.category, filename: rule.filename, relevance: description || "Design rule documentation", }); } } if (results.length === 0) { return { content: [ { type: "text", text: `No design rules found matching "${query}". Try searching for terms like "color", "icon", "spacing", "typography", etc.`, }, ], }; } const resultText = results .map((r) => `**${r.category}**\n${r.relevance}\n`) .join("\n"); return { content: [ { type: "text", text: `Found ${results.length} design rule(s) matching "${query}":\n\n${resultText}`, }, ], }; }
- src/index.ts:241-251 (schema)Defines the input schema for the search_design_rules tool, requiring a 'query' string parameter.inputSchema: { type: "object", properties: { query: { type: "string", description: 'Search query for design rules (e.g., "primary color", "icon size", "spacing scale")', }, }, required: ["query"], },
- src/index.ts:238-252 (registration)Registers the search_design_rules tool in the list returned by ListToolsRequestHandler, including name, description, and schema.{ name: "search_design_rules", description: "Search across all design rules by keyword or term.", inputSchema: { type: "object", properties: { query: { type: "string", description: 'Search query for design rules (e.g., "primary color", "icon size", "spacing scale")', }, }, required: ["query"], }, },
- src/index.ts:323-325 (registration)Switch case in the central CallToolRequestHandler that dispatches search_design_rules calls to the handler method.case "search_design_rules": return await this.searchDesignRules((args?.query as string) || "");
- src/index.ts:112-133 (helper)Loads design rule markdown files into memory (this.rules array), which is used by the search_design_rules 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`); }