Skip to main content
Glama

get_icons_by_desc_and_prefix

Retrieve SVG icons using descriptions and prefixes from the Iconify API. Designed for FE/UI designers to simplify icon searches without manual website browsing.

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 handler function for the MCP tool 'get_icons_by_desc_and_prefix'. It calls the helper to search icons and returns a JSON string of matching icon names (stripped of 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; }) ), }, ], }; }
  • Zod schema defining the input parameters: required 'desc' (string) and optional 'prefix' (string).
    { 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 call via server.tool(), including name, description, input schema, and inline 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; }) ), }, ], }; } );
  • Helper function that performs the HTTP fetch to Iconify API search endpoint with prefix and description query, returns parsed JSON or null on error.
    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; } }

Other Tools

Related Tools

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