search_icons
Find icons by name or tags to enhance your designs. Enter search terms separated by commas to locate multiple icons simultaneously.
Instructions
Search for icons by name or tags. Use commas to search for multiple icons (e.g. 'home, notification, settings')
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | Search query to find relevant icons. Separate multiple searches with commas |
Implementation Reference
- src/index.ts:307-329 (handler)MCP handler for the search_icons tool: validates input query and calls searchIcons utility to perform the search, returning JSON results.private async handleSearchIcons(args: any) { try { const query = this.validateSearchQuery(args); const results = await searchIcons(query); return { content: [ { type: "text", text: JSON.stringify(results, null, 2), }, ], }; } catch (error) { if (error && typeof error === 'object' && 'isAxiosError' in error) { throw new McpError( ErrorCode.InternalError, `Failed to search icons: ${(error as any).message}` ); } throw error; } }
- src/index.ts:81-93 (registration)Registers the search_icons tool in the ListTools response, including name, description, and input schema.name: "search_icons", description: "Search for icons by name or tags. Use commas to search for multiple icons (e.g. 'home, notification, settings')", inputSchema: { type: "object", properties: { query: { type: "string", description: "Search query to find relevant icons. Separate multiple searches with commas", } }, required: ["query"], }, },
- src/index.ts:83-92 (schema)Input schema definition for the search_icons tool, specifying a required 'query' string parameter.inputSchema: { type: "object", properties: { query: { type: "string", description: "Search query to find relevant icons. Separate multiple searches with commas", } }, required: ["query"], },
- src/utils/search.ts:7-37 (helper)Core utility function implementing the icon search logic: queries Hugeicons search API, maps results to IconInfo format, handles errors gracefully.export async function searchIcons(searchQuery: string): Promise<IconInfo[]> { if (!searchQuery || !searchQuery.trim()) { return []; } try { const response = await axios.get<SearchApiResponse>( `https://search.hugeicons.com/search`, { params: { q: searchQuery.trim() }, timeout: 10000, // 10 second timeout } ); // Convert API results to our IconInfo format return response.data.results.map(result => ({ id: result.id, name: result.name, tags: result.tags, // Keep as array to match IconInfo interface category: result.category, featured: result.featured, version: result.version, })); } catch (error) { console.error('Failed to search icons:', error); // If API fails, return empty results rather than throwing // This ensures the MCP server doesn't crash if the search API is down return []; } }
- src/index.ts:414-422 (helper)Input validation helper for search_icons query parameter.private validateSearchQuery(args: any): string { if (!args || typeof args.query !== "string" || !args.query.trim()) { throw new McpError( ErrorCode.InvalidRequest, "Search query must be a non-empty string" ); } return args.query.trim(); }