Skip to main content
Glama

get_icon_detail_by_prefix_and_name

Retrieve SVG icon details from the Iconify API by specifying a prefix and icon name. Use this tool to fetch exact icon data for single icons or batch process multiple icons with fuzzy matching.

Instructions

get icon detail by prefix and svg name

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
svg_listNoicon svg name list, match batch of icons fuzzily
svg_nameNoicon svg name, match single icon exactly
prefixNoicon prefix, default env.PREFIX

Implementation Reference

  • MCP tool handler that handles single svg_name or batch svg_list by calling getIconByPrefixAndName and returning JSON stringified content.
    async ({ svg_list, svg_name = "", prefix = process.env.PREFIX as string, }) => { if (svg_name) { const icon = await getIconByPrefixAndName(prefix, svg_name); if (!icon) { return { content: [ { type: "text", text: "Failed to Get Icon", }, ], }; } return { content: [ { type: "text", text: JSON.stringify(icon), }, ], }; } const icons = await Promise.all( (svg_list || []).map((svg_name) => getIconByPrefixAndName(prefix, svg_name) ) ); if (!icons) { return { content: [ { type: "text", text: "Failed to Get Icon", }, ], }; } return { content: [ { type: "text", text: JSON.stringify(icons), }, ], }; }
  • Zod input schema defining parameters for the tool: svg_list (array), svg_name (string), prefix (string optional).
    { svg_list: z .array(z.string()) .optional() .describe("icon svg name list, match batch of icons fuzzily"), svg_name: z .string() .optional() .describe("icon svg name, match single icon exactly"), prefix: z.string().optional().describe("icon prefix, default env.PREFIX"), },
  • src/index.ts:90-92 (registration)
    Registration of the MCP tool 'get_icon_detail_by_prefix_and_name' with description.
    server.tool( "get_icon_detail_by_prefix_and_name", "get icon detail by prefix and svg name",
  • Helper function that fetches the SVG icon content from Iconify API by prefix and name, returns text or null on error.
    /** get icon by prefix and svg name */ export async function getIconByPrefixAndName<T>( prefix: string, svgName: string ): Promise<T | null> { try { const res = await fetch( `https://api.iconify.design/${prefix}/${svgName}.svg`, { method: "GET", } ); if (!res.ok) { throw new Error(`HTTP error! status: ${res.status}`); } return (await res.text()) 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