Engineering
Build a Custom shadcn Registry and Connect It via MCP
Build a custom shadcn registry modeled on TentUI's @tentui setup: registry.json, namespaces, transitive deps, CLI view checks, llms.txt, and MCP.
To build a custom shadcn registry, define your items against the official
shadcn/schema, compile them into static JSON files under /r/{name}.json with
shadcn build, validate the output, and publish a namespace URL template that
consumers add to components.json. Once those JSON endpoints are live, the
official shadcn MCP server (npx shadcn@latest mcp init) can search, inspect,
and install your components directly from Claude Code, Cursor, and other AI
editors with no custom MCP server code required.
This guide walks through the exact architecture behind TentUI's live @tentui
registry—covering registry:component vs registry:block, transitive
registryDependencies, pre-install verification with shadcn view, and pairing
the registry with llms.txt and MCP so both humans and coding agents get
reliable source code.
When a custom shadcn registry beats an npm package
Publishing an internal or public UI library to npm is the right call for low-level, versioned primitives whose internal DOM rarely changes. For product components, animated interactions, and multi-file page blocks, a shadcn registry gives teams a cleaner boundary: consumers receive editable TypeScript source in their own repo, with zero runtime wrapper package to upgrade in lockstep.
That source-ownership trade-off is explored in Why copy-paste components scale. A custom registry turns copy-paste from ad-hoc gists into a repeatable, schema-validated distribution pipeline.
Define your registry items (registry:component vs registry:block)
In TentUI, the registry manifest starts in TypeScript (src/registry/index.ts)
validated with Registry and registrySchema from shadcn/schema. Splitting
items by purpose keeps large catalogs maintainable:
import type { Registry } from "shadcn/schema";
import { blocks } from "./blocks/_registry";
import { components } from "./components/_registry";
import { examples } from "./examples/_registry";
export const registry = {
name: "tentui",
homepage: "https://tentui.com",
items: [...blocks, ...components, ...examples],
} satisfies Registry;Choosing the right item type matters because it tells both the CLI and
reviewers how much code an install will introduce:
| Registry type | Best fit | Typical files | Example in TentUI |
|---|---|---|---|
registry:component | A focused interactive control plus any local helpers or hooks | 1–3 files (@components/..., @hooks/...) | copy-button, snap-sheet, stateful-button |
registry:block | A complete page section or multi-route layout composing primitives | 1–4+ files (@components/..., app/..., @lib/...) | hero-02, pricing-03, 404-01, legal-page-01 |
registry:hook / registry:lib | Shared utilities or hooks installed inside a component or standalone | 1 file (@hooks/..., @lib/...) | use-copy-to-clipboard.ts, webgl.ts |
registry:example | Internal docs demos; filtered out of public registry.json | 1 demo file | snap-sheet-demo |
A real component item in TentUI declares its npm packages, official shadcn
primitives, and exact file targets. Here is how @tentui/copy-button bundles
its component, animation helper, and clipboard hook as one installable unit:
{
name: "copy-button",
type: "registry:component",
title: "Copy Button",
description: "Copy text to the clipboard with visual, sound, and haptic feedback.",
dependencies: ["@rexa-developer/tiks", "lucide-react", "motion", "web-haptics"],
registryDependencies: ["button"],
files: [
{
path: "components/copy-button/copy-button.tsx",
type: "registry:component",
target: "@components/copy-button.tsx",
},
{
path: "components/icon-swap/icon-swap.tsx",
type: "registry:component",
target: "@components/icon-swap/icon-swap.tsx",
},
{
path: "src/hooks/use-copy-to-clipboard.ts",
type: "registry:hook",
target: "@hooks/use-copy-to-clipboard.ts",
},
],
docs: "https://tentui.com/components/copy-button",
}Notice the target aliases (@components/..., @hooks/..., @lib/...). They
let the CLI respect each consumer's components.json path aliases instead of
hardcoding src/components/.
Wire transitive registryDependencies cleanly
Blocks and composite components often depend on both official shadcn primitives
(like "button" or "card") and other items in your own custom registry.
For official shadcn items, use the plain name ("button", "accordion"). For
items from your own registry, pass the full item URL (or configured namespace)
so the CLI resolves them even when the consumer installed a block via direct URL
without configuring your namespace first.
In TentUI, a tiny helper (getRegistryItemUrl) generates those URLs from one
config constant (https://tentui.com/r/{name}.json):
{
name: "hero-02",
title: "Hero 02",
type: "registry:block",
registryDependencies: [
"button",
getRegistryItemUrl("brand-context-menu"),
getRegistryItemUrl("peeping-button"),
],
files: [
{
path: "blocks/hero-02/hero-02.tsx",
target: "@components/hero-02/index.tsx",
type: "registry:component",
},
{
path: "blocks/hero-02/header.tsx",
target: "@components/hero-02/header.tsx",
type: "registry:component",
},
],
}When someone runs npx shadcn@latest add @tentui/hero-02, the CLI walks that
graph automatically: hero-02 pulls in brand-context-menu, which in turn
pulls in context-menu and copy-button, installing every required file and
npm dependency in one pass.
Build and validate static /r/{name}.json artifacts
A shadcn registry does not need a database or dynamic API route to serve items.
Static JSON files in public/r/ are fast, cacheable at the edge, and immune to
runtime cold starts.
TentUI's build pipeline (package.json) runs two commands in sequence and then
validates the compiled output:
{
"scripts": {
"registry:build": "tsx ./scripts/build-registry.mts && shadcn build",
"registry:validate": "shadcn registry validate ./public/r/registry.json"
}
}Here is what each step does:
scripts/build-registry.mtsvalidates the TypeScript manifest withregistrySchema.safeParse(), filters out internalregistry:exampleitems, normalizes relative paths (src/registry/...), and writes the top-levelregistry.jsonmanifest (along with pre-built docs indexes).shadcn buildreadsregistry.json, inlines each file's source code into its own JSON payload underpublic/r/<name>.json, and writespublic/r/registry.jsonas the index.shadcn registry validate ./public/r/registry.jsonverifies that every generated payload conforms to the registry schema before you deploy.
One subtle hosting pitfall: make sure missing /r/*.json paths return a real
404 JSON or plain-text error, never a 200 OK HTML SPA fallback. As detailed
in Shadcn Missing Components: Find and Install Them Safely,
an HTML fallback triggers the infamous Unexpected token '<' CLI error and hides
broken item names.
Configure custom namespaces in components.json
Once public/r/{name}.json is deployed on your domain, consumers register your
namespace once in components.json:
{
"registries": {
"@tentui": "https://tentui.com/r/{name}.json"
}
}The CLI substitutes {name} for every command under that namespace. Consumers
can also install a single item without touching components.json by passing the
full URL:
pnpm dlx shadcn@latest add https://tentui.com/r/copy-button.json
For full consumer setup steps—including manual fallback and updating copied source—see the TentUI installation guide.
Always support npx shadcn@latest view inspection
Before adding third-party source to a production repo, developers (and security reviewers) should inspect what the registry will write without modifying disk:
pnpm dlx shadcn@latest view @tentui/snap-sheet
view prints the exact JSON payload: description, dependencies,
registryDependencies, file targets, and full source contents. Keeping your
registry descriptions accurate, avoiding hidden dependencies, and using clean
target paths makes view output immediately trustworthy.
You can also verify searchability against your published registry.json index:
pnpm dlx shadcn@latest search @tentui -q "sheet"
If search returns empty results, double-check that public/r/registry.json
is published at the same /r/ root as your individual {name}.json files and
includes concise, keyword-clear title and description fields for every item.
Connect your registry to AI editors with llms.txt and MCP
Modern discovery happens inside editors as often as in browser search. A custom shadcn registry works with the official shadcn MCP server out of the box as soon as two things are in place:
- A configured namespace in
components.jsonpointing to your/r/{name}.jsonendpoint (with a valid/r/registry.jsonindex). - Initialized MCP config in the consumer's project:
pnpm dlx shadcn@latest mcp init
After running mcp init (and choosing Claude Code, Cursor, or another MCP
client in the prompt), the AI assistant can search your @namespace, view item
source, and install components with the right dependencies. TentUI's
MCP setup guide shows the exact consumer workflow.
To make AI assistants even more accurate when they read your documentation directly, pair the registry with machine-readable Markdown endpoints:
/llms.txt— A compact index listing your namespace configuration, every component's one-sentence summary, its exactnpx shadcn@latest add @tentui/<name>command, and a link to its raw.mdxdoc./llms-full.txt— The full component docs and guides concatenated for tools that prefer a single context fetch.- Per-page
.mdxroutes andAccept: text/markdownnegotiation — In TentUI, requesting/components/snap-sheet.mdx(or sendingAccept: text/markdownto/components/snap-sheet) returns clean Markdown instead of HTML navigation chrome.
Together, registry.json (for structured MCP tool calls) and llms.txt (for
documentation and usage context) let coding agents pick the right component,
install it cleanly, and wire its props without hallucinating APIs.
Pre-publish checklist for custom registry authors
Before announcing a custom shadcn registry, run through these checks against your deployed URL:
| Check | Command or verification |
|---|---|
| Schema validation | npx shadcn@latest registry validate ./public/r/registry.json |
| Payload inspection | npx shadcn@latest view https://your-domain.com/r/<item>.json |
| Clean-room install | Run npx shadcn@latest add @your-ns/<item> in a fresh Next.js + Tailwind project |
| Transitive graph | Install a multi-file registry:block and verify nested registryDependencies resolve |
| Missing item status | curl -I https://your-domain.com/r/does-not-exist.json returns 404, not 200 HTML |
| MCP discovery | Run npx shadcn@latest mcp init and prompt your editor to search and add one item |
| License clarity | State clearly whether items are MIT, free and source-available, or commercial |
FAQ
How does a custom shadcn registry work?
A custom shadcn registry is a set of static JSON files following the official shadcn/schema hosted at a URL template such as https://example.com/r/{name}.json, alongside a registry.json index. When a user runs npx shadcn@latest add @namespace/item, the CLI fetches that JSON, installs declared npm and registry dependencies, and writes the source files into the project's configured alias paths.
What is the difference between registry:component and registry:block?
Use registry:component for a focused, reusable UI control and its supporting hook or helper files, and use registry:block for larger multi-part page sections or route layouts (such as a hero, pricing section, or 404 page) that compose multiple primitives and may include framework-specific files.
Do I need to build a custom MCP server for my shadcn registry?
No. The official shadcn CLI ships an MCP server (npx shadcn@latest mcp init) that reads any registry configured in components.json. As long as your registry serves valid /r/registry.json and /r/{name}.json endpoints with clear titles and descriptions, Claude Code, Cursor, and other MCP clients can search and install your items immediately.
How should I declare dependencies between items in my own registry?
List official shadcn primitives by name (such as "button") in registryDependencies, and reference other items from your custom registry by their full item URL (such as https://tentui.com/r/animated-tabs.json). That ensures transitive dependencies resolve even if a consumer installs an item by direct URL without adding your namespace to components.json.
How can consumers inspect a custom registry item before installing it?
Run npx shadcn@latest view @namespace/<item> (or pass the full .json URL). The CLI prints the item's metadata, dependencies, target paths, and complete source code without writing any files to disk.
Why should a custom registry also expose llms.txt?
registry.json gives MCP tools the file payloads and install metadata, while llms.txt gives AI assistants and documentation scrapers a concise map of every component, its install command, and links to raw Markdown docs with usage examples, accessibility notes, and prop guidance.
Components in this guide
All componentsSnap Sheet
A bottom sheet you drag between snap points, with detent haptics, a rubber band, and flick to close.
npx shadcn@latest add @tentui/snap-sheet
Related guides
All posts- React Bottom Sheet with Snap Points for shadcn/ui
Build a React bottom sheet with snap points for shadcn/ui on Base UI Dialog, with velocity flick, rubber-band physics, Vaul migration, and full a11y.
- Best Animated shadcn/ui Components in 2026
A guide to TentUI's animated shadcn/ui components by job, from async buttons and pickers to charts, overlays, text effects, and AI thinking UI.
- How to Add Animations to shadcn Components
Build accessible shadcn animations with source-owned code, shared-layout transitions, async feedback, and reduced-motion support.