Use the shadcn MCP server with shadcncraft

Connect shadcn's MCP server with one prompt, then ask Claude Code, Cursor, VS Code, Codex, or OpenCode to find and install shadcncraft blocks, components, and apps.
PreviousNext

An MCP server is a connection that lets your AI tool reach something outside your project. The shadcn MCP server is shadcn's official one: connect it and your AI tool can find shadcncraft blocks, components, and apps and install the ones you ask for.

The shadcncraft registry works with it out of the box. It needs the same two things the CLI needs: the @shadcncraft registry in components.json and your license key in the environment.

Browsing needs no license, so an agent can list and search shadcncraft blocks, components, and apps on any project. Installing an item from Pro Blocks or Pro Blocks + Apps needs a valid key.

The easy way: ask your AI tool to set it up

You do not need a terminal. Open your project in Claude Code, Cursor, VS Code, or Codex, paste one prompt into the chat, and let the agent do the setup.

Where to find your license key

Your key was generated after checkout. It is in the email you received when you bought Pro Blocks or Pro Blocks + Apps, and in the Polar portal under your purchases. Copy it. You paste it once, and the setup takes it from there.

On a Single or Team license, activate the key once on Activate license with an instance name such as your work email. Enterprise licenses skip activation.

Paste this prompt

Paste it into the chat box of your AI tool, in the project you want to install into:

Setup prompt
Set up shadcn's MCP server for this project and connect the shadcncraft
registry to it.
 
1. If this project has no components.json, stop and tell me what is
   missing before you change anything.
2. Add shadcn's MCP server for the client you are running in:
   npx shadcn@latest mcp init --client claude, cursor, vscode, codex,
   or opencode.
3. Add the @shadcncraft registry to components.json, keeping everything
   already in the file:
   "registries": {
     "@shadcncraft": {
       "url": "https://shadcncraft.com/r/{style}/{name}",
       "headers": {
         "X-License-Key": "${SHADCNCRAFT_LICENSE_KEY}",
         "X-Instance-Name": "${SHADCNCRAFT_INSTANCE_NAME}"
       }
     }
   }
4. Add SHADCNCRAFT_LICENSE_KEY to .env.local at the project root, and
   make sure .env.local is gitignored. If the key is not in the file
   yet, add the line with an empty value and tell me the exact file and
   line to paste my key into. Never ask me for the key in chat and
   never repeat it back to me.
5. On a Single or Team license, also add SHADCNCRAFT_INSTANCE_NAME with
   the instance name I activated. Skip it on Enterprise.
6. Restart or reload the MCP server, then confirm the shadcn server is
   connected and can list @shadcncraft items.
7. Tell me in plain words what I need to click, and finish with three
   example requests I can try.

When the agent asks for your license key, open .env.local and paste it after =. The agent tells you the file and the line, and the key stays out of the chat.

What to type afterwards

Once the agent reports that the shadcn server is connected, ask for what you want in plain words:

Add the shadcncraft pricing-4 block to my homepage.
Find a shadcncraft dashboard block and install it.
Show me the shadcncraft navigation blocks.

If the agent cannot see any shadcncraft items, the server is not connected yet. Reload your tool and try again, or work through troubleshooting.

Manual setup (developers)

The rest of this page is the same setup by hand: the two files the prompt above writes, then the mcp init command for your client.

1. Add the registry to components.json

The MCP server reads registries from components.json and sends the headers you define on every item request. Add the @shadcncraft registry at the top level of the file:

components.json
"registries": {
  "@shadcncraft": {
    "url": "https://shadcncraft.com/r/{style}/{name}",
    "headers": {
      "X-License-Key": "${SHADCNCRAFT_LICENSE_KEY}",
      "X-Instance-Name": "${SHADCNCRAFT_INSTANCE_NAME}"
    }
  }
}

The {style} placeholder makes installs follow the style field in your components.json, so anything the agent installs matches your presets. The installation guide has the full file and the name-only alternative.

2. Add your license key to the environment

The MCP server expands ${...} in the registry headers from the environment it starts in, so the variables have to exist where the agent runs, not in a shell you opened earlier. Put them in .env.local at the project root (.env works too):

.env.local
SHADCNCRAFT_LICENSE_KEY="SHADCNCRAFT_XXXX_XXXX_XXXX"
SHADCNCRAFT_INSTANCE_NAME="your_name@company.com"
  • Pro Blocks and Pro Blocks + Apps, Single and Team: set both variables, and use the exact instance name from activation.
  • Enterprise: set SHADCNCRAFT_LICENSE_KEY only.

The MCP server and the CLI it calls both read these files when they start, so restart your client after changing either one. Keys belong in your environment, not in a prompt: you never paste the key into chat.

3. Configure your client

Run the command from your project root. mcp init writes the config file for that client and adds shadcn to your dev dependencies. The commands below use npm; pnpm dlx shadcn@latest ..., yarn dlx shadcn@latest ..., and bunx shadcn@latest ... work the same way.

Claude Code

$ pnpm dlx shadcn@latest mcp init --client claude

This writes .mcp.json at the project root:

.mcp.json
{
  "mcpServers": {
    "shadcn": {
      "command": "npx",
      "args": ["shadcn@latest", "mcp"]
    }
  }
}

Restart Claude Code, then run /mcp. The shadcn server should show Connected. Claude Code asks you to approve project MCP servers the first time it sees this file.

Cursor

$ pnpm dlx shadcn@latest mcp init --client cursor

This writes .cursor/mcp.json:

.cursor/mcp.json
{
  "mcpServers": {
    "shadcn": {
      "command": "npx",
      "args": ["shadcn@latest", "mcp"]
    }
  }
}

Enable the server in Cursor Settings > MCP. A green dot next to shadcn means it is running.

VS Code

$ pnpm dlx shadcn@latest mcp init --client vscode

This writes .vscode/mcp.json:

.vscode/mcp.json
{
  "servers": {
    "shadcn": {
      "command": "npx",
      "args": ["shadcn@latest", "mcp"]
    }
  }
}

Open .vscode/mcp.json and click Start next to the shadcn server. Then ask GitHub Copilot in agent mode.

Codex

$ pnpm dlx shadcn@latest mcp init --client codex

The shadcn CLI cannot write ~/.codex/config.toml, so it installs the dependency and prints the block to copy. Add it to that file yourself:

~/.codex/config.toml
[mcp_servers.shadcn]
command = "npx"
args = ["shadcn@latest", "mcp"]

Restart Codex to load the server. This file is global, so Codex uses it in every project; the license variables still come from each project's .env.local.

OpenCode

$ pnpm dlx shadcn@latest mcp init --client opencode

This writes opencode.json:

opencode.json
{
  "$schema": "https://opencode.ai/config.json",
  "mcp": {
    "shadcn": {
      "type": "local",
      "command": ["npx", "shadcn@latest", "mcp"],
      "enabled": true
    }
  }
}

Restart OpenCode to load the server.

Other clients

For a client without an init target, add a stdio server that runs npx shadcn@latest mcp from the project root. The shadcn MCP docs publish tested configs for the five clients above, so check your client's own MCP docs for the file it reads.

Prompts to try

Once the server is connected, ask in plain language:

Show me the shadcncraft dashboard blocks.
Find a shadcncraft pricing section and install it.
Add @shadcncraft/pricing-4 to my project.
Search @shadcncraft for navigation blocks and install one that fits a marketing site.

Name the registry when you want it to look only at shadcncraft, or lead with the item name (@shadcncraft/header-1) when you know what you want. Installs use the shadcn CLI under the hood, so the agent may ask before overwriting a file that already exists.

Apps behave the same way, and need Pro Blocks + Apps:

Install @shadcncraft/banking-dashboard-1 into this project.

How Pro items authenticate

The registry serves its index publicly, so the agent can list and search every item, including Pro items, without a key. Item content and installs are gated:

  1. List and search read the registry index at https://shadcncraft.com/r/{style}/registry, which needs no license.
  2. Viewing an item, its files, or its examples fetches the item JSON through the MCP server, with the headers from components.json.
  3. Install runs npx shadcn@latest add @shadcncraft/<item> in your project. The CLI fetches the same URL with the same headers.

So the key is read in two places: the MCP server process and the CLI it starts. If the item is outside your tier, the request fails and the message comes back in the agent's tool result:

  • Free items install with no key.
  • Blocks and components need Pro Blocks or Pro Blocks + Apps.
  • Apps need Pro Blocks + Apps. On Pro Blocks the registry answers 403 upgrade_required and points at upgrade.

Do not paste the key into a prompt. The MCP server and the CLI expand ${SHADCNCRAFT_LICENSE_KEY} from your environment, so the key stays out of the conversation and out of the agent's context.

Troubleshooting

The agent has no shadcn tools, or cannot find any shadcncraft items

The server is not connected yet.

  • Restart the client after mcp init and after editing the config file.
  • Check the config file path for your client. Claude Code and Cursor read a project file, VS Code reads .vscode/mcp.json, Codex reads ~/.codex/config.toml, and OpenCode reads opencode.json.
  • In Claude Code, run /mcp to see the server and its status.
  • If the server is listed but shows no tools, clear the npx cache with npx clear-npx-cache and re-enable the server.
  • In Cursor, the log is under View > Output, in the MCP: project-* entry.

The agent says the item needs a shadcncraft license key

The request reached the registry without a usable X-License-Key. Check that .env.local defines SHADCNCRAFT_LICENSE_KEY and that components.json passes "X-License-Key": "${SHADCNCRAFT_LICENSE_KEY}". Restart the client so the MCP server picks up the new value.

The agent says the license is not activated yet

License key is valid, but no instance is activated yet. A Single or Team key without a matching activation. Activate the license, then set SHADCNCRAFT_INSTANCE_NAME to the exact instance name you used.

The agent says the license key is invalid

Invalid license key. Missing expected prefix. The key is not a current shadcncraft key, such as an old key from before the Polar migration. Copy the current key from the Polar portal or your purchase email.

The agent says you need to upgrade, with a 403

The key is valid but the item is outside your tier. Blocks and components need Pro Blocks; apps need Pro Blocks + Apps. See upgrade, or check the bundle you own in the Polar portal.

Blocks install in a style you did not choose

Installs follow the style field in components.json and the {style} placeholder in the registry URL. Change style and reinstall; no other edits are needed.

The full list of license and registry errors, with causes and fixes, is in registry troubleshooting.

See also

SBIOTJ

Join 16,000+ builders shipping with shadcncraft

Design and assemble full pages faster with production-ready blocks built for real products.
  • Production-ready blocks and components
  • Clean React and Tailwind parity
  • Built for SaaS, marketing, and ecommerce teams
Get the full library
Join Now CTA

Real support from the team behind shadcncraft

Get help within 24 hours from the people who build and maintain the system.
Email
Prefer a direct line? Send us a message and we'll get back to you as soon as possible.
Discord
Get quick support, share feedback, or connect with other builders.
Feedback
Got something to say about anything shadcncraft? We'd love to hear it.