Skip to main content
Glama

get_icon_usage_examples

Retrieve practical usage examples for Lucide React icons by specifying the icon name, helping developers integrate icons effectively into their projects.

Instructions

Get usage examples for a Lucide React icon

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYesIcon name, e.g. 'home' or 'user'

Implementation Reference

  • Executes the tool logic: finds the icon by normalized name in iconMetadata, generates usage example code if found using IconUsageGenerator, otherwise returns a not-found message.
    async ({ name }) => { const icon = iconMetadata.find( (i) => i.name.toLowerCase() === name.toLowerCase() ); if (!icon) { return createTextResponse( `Icon "${name}" not found. Use search_icons to find available icons.` ); } const example = IconUsageGenerator.generate(icon.name); return { content: [ { type: "text" as const, text: example } ] }; }
  • Input schema: requires a 'name' parameter as string (icon name).
    { name: z.string().describe("Icon name, e.g. 'home' or 'user'") },
  • src/utils.ts:156-184 (registration)
    Registers the get_icon_usage_examples tool on the MCP server, specifying name, description, input schema, and handler function.
    // Tool: get_icon_usage_examples server.tool( "get_icon_usage_examples", "Get usage examples for a Lucide React icon", { name: z.string().describe("Icon name, e.g. 'home' or 'user'") }, async ({ name }) => { const icon = iconMetadata.find( (i) => i.name.toLowerCase() === name.toLowerCase() ); if (!icon) { return createTextResponse( `Icon "${name}" not found. Use search_icons to find available icons.` ); } const example = IconUsageGenerator.generate(icon.name); return { content: [ { type: "text" as const, text: example } ] }; } );
  • Supporting utility that generates formatted React code example for the given icon, including import, basic usage, and styled props usage.
    class IconUsageGenerator { static generate(iconName: string) { const componentName = iconName; const importLine = `import { ${componentName} } from 'lucide-react';`; const basicExample = `<${componentName} />`; const propsExample = `<${componentName} size={24} color="#3b82f6" strokeWidth={1.5} />`; return `${importLine}\n\nfunction Example() {\n return (\n <div>\n {/* Basic usage */}\n ${basicExample}\n \n {/* With props */}\n ${propsExample}\n </div>\n );\n}`; } }

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/SeeYangZhi/lucide-icons-mcp'

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