Skip to main content
Glama

get_icons_by_desc_and_prefix

Retrieve SVG icons from Iconify API using descriptive keywords and prefix filters, enabling designers and developers to find UI icons programmatically instead of manual website searches.

Instructions

get icons by desc and prefix (LIKE AS ant-design)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
descYesdesc of icon, only English
prefixNoicon prefix, default env.PREFIX

Implementation Reference

  • The inline asynchronous handler function for the MCP tool. It receives desc and optional prefix, calls the searchIconsByPrefixAndDesc helper, handles null response with error message, otherwise maps icon names to SVG names by splitting on ':', stringifies the array as JSON, and returns it wrapped in MCP content format.
    async ({ desc, prefix = process.env.PREFIX as string }) => { const res: { icons: string[] } | null = await searchIconsByPrefixAndDesc( prefix, desc ); if (!res) { return { content: [ { type: "text", text: "Failed to Get Icon Collection", }, ], }; } return { content: [ { type: "text", text: JSON.stringify( res.icons.map((iconName) => { const [_, svgName] = iconName.split(":"); return svgName; }) ), }, ], }; }
  • Zod schema defining the input parameters for the tool: 'desc' as required string (English description), 'prefix' as optional string (defaults to env.PREFIX).
    { desc: z.string().describe("desc of icon, only English"), prefix: z.string().optional().describe("icon prefix, default env.PREFIX"), },
  • src/index.ts:49-87 (registration)
    MCP tool registration via server.tool() call, specifying the tool name, description, input schema, and handler function.
    server.tool( "get_icons_by_desc_and_prefix", "get icons by desc and prefix (LIKE AS ant-design)", { desc: z.string().describe("desc of icon, only English"), prefix: z.string().optional().describe("icon prefix, default env.PREFIX"), }, async ({ desc, prefix = process.env.PREFIX as string }) => { const res: { icons: string[] } | null = await searchIconsByPrefixAndDesc( prefix, desc ); if (!res) { return { content: [ { type: "text", text: "Failed to Get Icon Collection", }, ], }; } return { content: [ { type: "text", text: JSON.stringify( res.icons.map((iconName) => { const [_, svgName] = iconName.split(":"); return svgName; }) ), }, ], }; } );
  • Supporting utility function that queries the Iconify API search endpoint (`https://api.iconify.design/search?query=${desc}&prefix=${prefix}`), returns parsed JSON response typed as T or null on failure.
    /** get icon collection by prefix And desc (LIKE AS ant-design) */ export async function searchIconsByPrefixAndDesc<T>( prefix: string, desc: string ): Promise<T | null> { try { const res = await fetch( `https://api.iconify.design/search?query=${desc}&prefix=${prefix}`, { method: "GET", } ); if (!res.ok) { throw new Error(`HTTP error! status: ${res.status}`); } return (await res.json()) as T; } catch (error) { console.error("Error making request:", error); return null; } }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Leee62/pickapicon-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server