Skip to main content
Glama

get_icon_glyph_by_style

Retrieve the Unicode glyph for Hugeicons by specifying icon name and style, enabling accurate icon integration across platforms.

Instructions

Get the glyph (unicode character) for a specific icon with a particular style

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
icon_nameYesThe name of the icon (e.g., 'home-01', 'notification-02')
styleYesThe icon style

Implementation Reference

  • The main MCP tool handler for get_icon_glyph_by_style. It validates the input arguments, calls the getGlyphByStyle helper function, formats the response, and handles errors.
    private async handleGetIconGlyphByStyle(args: any) { try { const iconName = this.validateIconName(args); const style = this.validateIconStyle(args); const glyph = await getGlyphByStyle(iconName, style); return { content: [ { type: "text", text: JSON.stringify(glyph, null, 2), }, ], }; } catch (error) { throw new McpError( ErrorCode.InternalError, `Failed to get icon glyph by style: ${error instanceof Error ? error.message : "Unknown error"}` ); } }
  • Input schema defining the required icon_name (string) and style (string with enum of supported styles) parameters for the tool.
    inputSchema: { type: "object", properties: { icon_name: { type: "string", description: "The name of the icon (e.g., 'home-01', 'notification-02')", }, style: { type: "string", description: "The icon style", enum: [ "bulk-rounded", "duotone-rounded", "duotone-standard", "solid-rounded", "solid-sharp", "solid-standard", "stroke-rounded", "stroke-sharp", "stroke-standard", "twotone-rounded" ] } }, required: ["icon_name", "style"], },
  • src/index.ts:123-152 (registration)
    Registration of the get_icon_glyph_by_style tool in the ListToolsRequestSchema response, including name, description, and input schema.
    { name: "get_icon_glyph_by_style", description: "Get the glyph (unicode character) for a specific icon with a particular style", inputSchema: { type: "object", properties: { icon_name: { type: "string", description: "The name of the icon (e.g., 'home-01', 'notification-02')", }, style: { type: "string", description: "The icon style", enum: [ "bulk-rounded", "duotone-rounded", "duotone-standard", "solid-rounded", "solid-sharp", "solid-standard", "stroke-rounded", "stroke-sharp", "stroke-standard", "twotone-rounded" ] } }, required: ["icon_name", "style"], }, },
  • Helper function implementing the core logic: fetches the specific glyph (primary and secondary unicode) for an icon and style from the Hugeicons API.
    export async function getGlyphByStyle(iconName: string, style: IconStyle): Promise<{ primary: Glyph; secondary: Glyph | null }> { if (!iconName || !iconName.trim()) { throw new Error('Icon name is required'); } if (!style || !style.trim()) { throw new Error('Style is required'); } try { const response = await axios.get<SingleGlyphResponse>( `${HUGEICONS_API_BASE}/icon/${iconName.trim()}/glyph`, { params: { style: style.trim() }, headers: { 'accept': 'application/json' }, timeout: 10000, // 10 second timeout } ); if (!response.data.success) { throw new Error(response.data.message || 'Failed to fetch glyph'); } return response.data.data; } catch (error: any) { if (error.response?.status === 404) { throw new Error(`Icon '${iconName}' with style '${style}' not found`); } if (error.message) { throw new Error(`Failed to fetch glyph: ${error.message}`); } throw new Error('Failed to fetch glyph'); } }
  • Validation helper for the style parameter, ensuring it matches the supported IconStyle enum.
    private validateIconStyle(args: any): IconStyle { if (!args || typeof args.style !== "string" || !args.style.trim()) { throw new McpError( ErrorCode.InvalidRequest, "Style must be a non-empty string" ); } const validStyles: IconStyle[] = [ 'bulk-rounded', 'duotone-rounded', 'duotone-standard', 'solid-rounded', 'solid-sharp', 'solid-standard', 'stroke-rounded', 'stroke-sharp', 'stroke-standard', 'twotone-rounded' ]; const style = args.style.trim() as IconStyle; if (!validStyles.includes(style)) { throw new McpError( ErrorCode.InvalidRequest, `Invalid style. Supported styles are: ${validStyles.join(', ')}` ); } return style; }

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/hugeicons/mcp-server'

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