Shadcn.io is not affiliated with official shadcn/ui
get_icon
Fetch a single icon by library + name. Returns the React component source plus a ready-to-run shadcn add install command.
get_icon resolves one icon to a full RegistryItem plus an install command with your token embedded. It's the retrieval counterpart to search_icons.
When to use
- The agent has a specific
(library, name)pair (fromsearch_iconsor from the user). - You want the React component source, not just the SVG.
- You want an install command that lands the icon at
components/icons/{library}-{name}.tsx.
How it works
-
Calls
getIconRegistry(library, name)fromservices/registry.ts. -
getIconRegistryqueriesservices/icons-db.ts#getIcon, which fetches the row from Postgres with fieldsbody,width,height,strokeWidth. -
The SVG body is cleaned:
<g>wrappers stripped.fill="",stroke="",stroke-width,stroke-linecap,stroke-linejoinattributes stripped (so the generated component can drive them via props).
-
A React component is generated inline with props for
size,color,strokeWidth, andclassName:export function ArrowRightIcon({ size = 24, color = "currentColor", strokeWidth = 2, className, ...props }: React.SVGProps<SVGSVGElement> & { size?: number; color?: string; strokeWidth?: number }) { return <svg xmlns="http://www.w3.org/2000/svg" width={size} height={size} ...>{cleanedBody}</svg> } -
The tool wraps the result in a
RegistryItemshape with name{library}-{name}, then appends aninstallfield built from the user's token.
Source: lib/mcp/tools.ts#get_icon + services/registry.ts#getIconRegistry + services/icons-db.ts#getIcon.
Arguments
| Name | Type | Required | Notes |
|---|---|---|---|
library | string | ✓ | Library id from search_icons.results[].libraryId |
name | string | ✓ | Icon name from search_icons.results[].name |
Response
{
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
"name": "lucide-arrow-right",
"type": "registry:ui",
"title": "ArrowRight Icon",
"author": "lucide",
"description": "ArrowRight icon from lucide",
"homepage": "https://www.shadcn.io/icons/lucide",
"files": [
{
"type": "registry:ui",
"path": "lucide-arrow-right.tsx",
"content": "import * as React from \"react\";\n\nexport function ArrowRightIcon({ ... }) { return <svg ...>...</svg>; }\n",
"target": "components/icons/lucide-arrow-right.tsx"
}
],
"dependencies": [],
"registryDependencies": [],
"install": "npx shadcn@latest add \"https://www.shadcn.io/r/lucide-arrow-right.json?token=<your-token>\""
}For an unknown icon (wrong library or wrong name):
{
"content": [{ "type": "text", "text": "Icon not found: lucide-arrow-nope" }],
"isError": true
}Example prompts
use shadcnio to add a Lucide arrow-right icon to my button componentuse shadcnio to fetch the github brand icon from simple-icons and install ituse shadcnio and show me the source of heroicons magnifying-glassManual invocation
curl -s -X POST "https://www.shadcn.io/api/mcp?token=YOUR_TOKEN" \
-H "content-type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "get_icon",
"arguments": { "library": "lucide", "name": "arrow-right" }
}
}' | jq '.result.content[0].text | fromjson | .install' -rTips + gotchas
- The generated component drives size/color/strokeWidth via props — that's why the raw SVG attributes are stripped. If you want the original attributes, fetch the row from the icons DB directly (not via MCP).
- Icon slug format for install —
{library}-{name}is thenameon theRegistryItemand the slug in the install URL. Don't construct it yourself; use the one in the response. - All icons are free (not Pro-gated). Even non-Pro users could fetch icons — except MCP itself is Pro-gated, so in practice only Pro users reach this tool. The
/r/{library}-{name}.jsonendpoint serves icons to any valid-token holder. - No dependencies, no registryDependencies — the generated component is self-contained (just React). Drop-in compatible.
- Install target —
components/icons/{library}-{name}.tsx. Different libraries land side-by-side in the same folder.
Was this page helpful?
Sign in to leave feedback.