Skip to main content
Glama

get_icon_detail_by_prefix_and_name

Retrieve detailed SVG icon information by specifying a prefix and name, enabling precise or batch icon matching for FE/UI/Designers via PickAPIcon MCP.

Instructions

get icon detail by prefix and svg name

Input Schema

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

Implementation Reference

  • The handler function executes the tool logic, supporting both single icon by exact name or batch by list, fetching via getIconByPrefixAndName and returning JSON stringified SVG 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-based input schema defining optional parameters: svg_list (array of strings), svg_name (string), and prefix (string).
    { 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-159 (registration)
    Registers the 'get_icon_detail_by_prefix_and_name' tool using server.tool() with name, description, input schema, and handler function.
    server.tool( "get_icon_detail_by_prefix_and_name", "get icon detail by prefix and svg name", { 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"), }, 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), }, ], }; } );
  • Supporting utility function that fetches the SVG icon content from the Iconify API by prefix and name, returning the text content or null on error.
    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; } }

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