search_krds_components
Search and filter UI components from Korea's government digital design system using keywords or categories to find specific design elements for government digital services.
Instructions
KRDS 컴포넌트를 검색합니다. 검색어나 카테고리로 필터링할 수 있습니다.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | No | 검색할 키워드 (예: button, input, modal) | |
| category | No | 컴포넌트 카테고리 (예: Form, Navigation, Layout) |
Implementation Reference
- src/tools/component-search.ts:7-34 (handler)Core handler function implementing the logic to search KRDS components by query and/or category.export async function searchComponents( loader: KRDSLoader, query?: string, category?: string ): Promise<KRDSComponent[]> { const allComponents = await loader.loadComponents(); let results = allComponents; // 카테고리 필터 if (category) { results = results.filter(c => c.category.toLowerCase() === category.toLowerCase() ); } // 검색어 필터 if (query) { const lowerQuery = query.toLowerCase(); results = results.filter(c => c.name.toLowerCase().includes(lowerQuery) || c.category.toLowerCase().includes(lowerQuery) || (c.description && c.description.toLowerCase().includes(lowerQuery)) ); } return results; }
- src/index.ts:57-58 (registration)Tool dispatch registration in the main request handler switch statement.case 'search_krds_components': return await this.handleSearchComponents(args);
- src/index.ts:104-120 (schema)Tool registration including name, description, and input schema definition.{ name: 'search_krds_components', description: 'KRDS 컴포넌트를 검색합니다. 검색어나 카테고리로 필터링할 수 있습니다.', inputSchema: { type: 'object', properties: { query: { type: 'string', description: '검색할 키워드 (예: button, input, modal)', }, category: { type: 'string', description: '컴포넌트 카테고리 (예: Form, Navigation, Layout)', }, }, }, },
- src/index.ts:217-233 (handler)Wrapper handler that calls the core searchComponents and formats the response for MCP.private async handleSearchComponents(args: any) { const results = await searchComponents(this.loader, args?.query, args?.category); const text = results.length > 0 ? `찾은 컴포넌트 (${results.length}개):\n\n` + results.map(c => `📦 ${c.name}\n` + ` 카테고리: ${c.category}\n` + ` 설명: ${c.description || '설명 없음'}\n` + ` 파일: ${c.fileName}` ).join('\n\n') : '검색 결과가 없습니다.'; return { content: [{ type: 'text', text }], }; }