search_icons
Find icons by name or tags using a search query. Separate multiple terms with commas to locate specific or grouped icons efficiently.
Instructions
Search for icons by name or tags. Use commas to search for multiple icons (e.g. 'home, notification, settings')
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | Search query to find relevant icons. Separate multiple searches with commas |
Input Schema (JSON Schema)
{
"properties": {
"query": {
"description": "Search query to find relevant icons. Separate multiple searches with commas",
"type": "string"
}
},
"required": [
"query"
],
"type": "object"
}
Implementation Reference
- src/index.ts:306-328 (handler)Main handler for search_icons tool: validates input query, delegates to searchIcons utility, formats response as JSON text content, handles errors.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/utils/search.ts:7-37 (helper)Core search logic: Calls Hugeicons search API with query, maps response to IconInfo[], gracefully handles errors by returning empty array.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:83-92 (schema)Input schema definition for search_icons tool: requires '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/index.ts:159-160 (registration)Dispatch registration in CallToolRequestSchema handler: routes search_icons calls to handleSearchIcons.case "search_icons": return await this.handleSearchIcons(request.params.arguments);