Shadcn.io is not affiliated with official shadcn/ui
get_install_command
Build a ready-to-run `shadcn add` command for any registry item, with your token pre-embedded in the URL. The zero-config install handoff.
This is the tool that makes the whole MCP setup pay off. The agent calls it, gets back a fully-formed shadcn add command (URL includes your token), emits it in the chat, and runs it in your shell. shadcn add hits /r/{name}.json?token=... directly — no further MCP roundtrip, no token-prompting, no copy-paste.
When to use
- The agent has picked a component and is ready to install.
- The user asks "install X" or "add X to my project".
- You want the agent to end a reasoning chain with an actionable shell command.
How it works
Pure formatter. The tool handler:
- Reads the authenticated user's
registryTokenout ofAsyncLocalStorageviarequireContext(). - URL-encodes the component name and token.
- Builds
https://www.shadcn.io/r/{name}.json?token={token}. - Prefixes the package-runner command for the requested client (
npx,bun,pnpm, oryarn). - Returns the primary command + all four client variants so the agent can pick what's best for the user's project.
There's no registry lookup, no validation that the slug exists — that's deliberate. The agent should have already resolved the slug via get_item. This tool is pure text-assembly.
Source: lib/mcp/tools.ts#get_install_command + lib/mcp/install-command.ts.
The actual shadcn add execution hits /r/{name}.json on the server, which:
- Rate-limits the request (
registrylimiter, 100/min/IP). - Validates the token against the DB (Redis-cached 5 min).
- For premium items, checks effective Pro access (direct or workspace-owner inherited).
- Returns the registry JSON with source inlined.
- Fires a
trackCodeAccessanalytics event (fire-and-forget).
Arguments
| Name | Type | Required | Notes |
|---|---|---|---|
name | string | ✓ | Registry slug |
client | "npx" | "bun" | "pnpm" | "yarn" | — | Default "npx" |
Response
{
"name": "pricing-grouped-comparison-table",
"client": "npx",
"command": "npx shadcn@latest add \"https://www.shadcn.io/r/pricing-grouped-comparison-table.json?token=<your-token>\"",
"allClients": {
"npx": "npx shadcn@latest add \"https://www.shadcn.io/r/pricing-grouped-comparison-table.json?token=<your-token>\"",
"bun": "bunx --bun shadcn@latest add \"https://www.shadcn.io/r/pricing-grouped-comparison-table.json?token=<your-token>\"",
"pnpm": "pnpm dlx shadcn@latest add \"https://www.shadcn.io/r/pricing-grouped-comparison-table.json?token=<your-token>\"",
"yarn": "yarn dlx shadcn@latest add \"https://www.shadcn.io/r/pricing-grouped-comparison-table.json?token=<your-token>\""
}
}allClients is included on every response so the agent can pick based on a package-lock.json / bun.lock / pnpm-lock.yaml / yarn.lock it sees in your repo — no second tool call needed.
Example prompts
use shadcnio and install pricing-grouped-comparison-table into my projectuse shadcnio to install hero-announcement using bunuse shadcnio to install every block I picked in the last step, one by oneManual 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_install_command",
"arguments": {
"name": "pricing-grouped-comparison-table",
"client": "bun"
}
}
}' | jq '.result.content[0].text | fromjson | .command' -rPipe into your shell:
$(curl -s ... | jq -r '.result.content[0].text | fromjson | .command')Tips + gotchas
- The token in the URL IS your secret. Don't paste install commands into public chats, PR descriptions, or issue threads. If you do, rotate it: DB
User.registryTokenis free-form — replace it via Prisma and any cached Redis entry expires in 5 min (or flipisProto force a webhook cache-bust). - No slug validation. If the agent hallucinates a slug, this tool happily returns a command that will 404 at install time. Chain with
get_itemfor validation if you care. - Premium items require Pro at install time, not at MCP time. A non-Pro user (hypothetical — MCP is Pro-only so this shouldn't happen) getting a command for a premium item would see 403 from
/r/*when running it. The URL itself is always returned. - Package-manager choice hints. Claude Code often reads lockfiles to pick the client; you can also tell it explicitly ("use pnpm").
- The returned URL uses the public origin (
https://www.shadcn.io/r/...). For self-hosted dev, you'd need to rewrite the origin manually — this is by design; the tool is meant to be run against the production registry.
Was this page helpful?
Sign in to leave feedback.
get_preview_url
Build the live preview and public page URLs for a registry item. Returns four variants — docs page, isolated iframe preview, dark-palette variant, and macOS-frame screenshot variant.
search_icons
Fuzzy search across 222+ icon libraries (~285k icons) using PostgreSQL trigram similarity. Returns (libraryId, name) pairs.