Skip to content

shadcn/ui components in OpenCode

Add a shadcnio entry to opencode.json and OpenCode can find shadcn components, blocks and icons and install them in your repo. It needs a shadcn.io Pro plan, whatever model you run.

Kind
Terminal agent
Goes in
opencode.json
Connects
Over HTTP
Team config
Yes

Add it to opencode.json

OpenCode keeps MCP servers under an mcp key, and a hosted one is "type": "remote". Signed in with Pro, the entry beside these steps is filled in with your own URL.

  1. Copy the entry

    It's your MCP URL, token at the end, under mcp.shadcnio. No token yet? Create one on your account page and reload this page.

  2. Merge it into opencode.json

    Use ~/.config/opencode/opencode.json for every project, or opencode.json at the repo's root for this one. Keep your other settings, and put shadcnio beside any servers already under mcp.

  3. Restart OpenCode

    OpenCode connects to its enabled servers as it starts. Quit with /exit, run opencode in the project again, and opencode mcp list should show shadcnio connected.

  4. Ask from the Build agent

    Begin with use shadcnio… so the model goes to the registry. Plan can search but can't edit files, so press Tab to get back to Build before you install.

opencode.json
Sign in to get your config
Sign in with a Pro account, and this holds your MCP URL, ready to paste.

How it reads, with YOUR_TOKEN where your token goes:

{
  "mcp": {
    "shadcnio": {
      "enabled": true,
      "type": "remote",
      "url": "https://www.shadcn.io/api/mcp?token=YOUR_TOKEN"
    }
  }
}

OpenCode merges every config it finds, so a project's shadcnio entry wins over your global one, and opencode debug config prints the result. Regenerating your token on your account turns off the old URL.

Where OpenCode reads its config
FileApplies toGood to know
~/.config/opencode/opencode.jsonYou, in every projectYour URL stays out of every repo
opencode.json at the repo's rootEveryone who works in the repoFound from the current folder up to the Git root; commit it with {env:SHADCNIO_TOKEN}
The file in OPENCODE_CONFIGAny shell that sets the variableLoads after the global file and before the project's
opencode.jsoncEither placeThe same keys, with comments allowed

One opencode.json for the team

Commit opencode.json at the root with the token in its URL written as {env:SHADCNIO_TOKEN}. OpenCode fills that in from each person's environment when it starts, so no token goes into git. Each teammate exports their own; when the variable is missing, the token comes through empty and the server answers 401. With a Team or Organization plan, each person's own token comes with Pro.

opencode.json
{
  "mcp": {
    "shadcnio": {
      "enabled": true,
      "type": "remote",
      "url": "https://www.shadcn.io/api/mcp?token={env:SHADCNIO_TOKEN}"
    }
  }
}

Each teammate sets SHADCNIO_TOKEN to their own token (from their MCP URL), so no token is committed.

Check OpenCode connected

opencode mcp list prints each server with its status: a check and connected when it works, the error when it doesn't. In the TUI, /status shows the same list.

  1. Quit OpenCode and run opencode in the project again, so it reads the new entry.
  2. In the same folder, run opencode mcp list: shadcnio should be marked connected.
  3. Or type /status in the TUI and find shadcnio under MCP Servers, marked Connected.
  4. Ask the prompt below. OpenCode calls whoami and answers with your account and how many calls you have left this minute.
Prompt
use shadcnio to tell me which account this token belongs to

Three tasks in OpenCode

A toast in a SolidStart app, a landing page planned before it's built, an editor for env vars: the prompt, the tools OpenCode calls, and what changes in the repo. Switch the MCP off to compare.

Your agent
  1. shadcn.io MCP connected · 22 tools
  2. You: Show a toast in the SolidStart app when an invite is sent.
  3. Agent step: Read package.jsonReturns: SolidStart, @ark-ui/solid, bun
  4. MCP call: search_components({ query: "toast notification", framework: "solid" })Returns: toast, the closest match
  5. MCP call: get_install_plan({ name: "toast", framework: "solid", packageManager: "bun" })Returns: Each file with its path, and the packages to add
  6. Agent step: Wrote the files and ran bun addReturns: src/components/ui/toast.tsx, a Toaster in app.tsx
  7. Your agent: Sending an invite now shows a toast with the teammate's email, and it goes away on its own.

In your project

Toast

  • A toaster that stacks and dismisses them for you
  • Fired from the invite action once it succeeds

1 prompt → 2 MCP calls

Prompts to paste into OpenCode

Paste one at OpenCode's prompt. Each names the server first, so the model reaches for the registry instead of writing UI from memory.

01
use shadcnio to add a toast when a deploy finishes in src/routes/deploys.tsx
02
use shadcnio to plan a docs landing page for this CLI from blocks, then wait for me
03
use shadcnio to move the account settings into a sheet that opens from the avatar menu
04
use shadcnio to swap the inline SVGs in the header for icons from the Lucide package we have
05
use shadcnio to look up Tooltip's props before you change components/status-badge.tsx
06
use shadcnio to set up this SolidStart app for shadcn components
07
use shadcnio to build a two-step onboarding form with TanStack Form and Zod
08
use shadcnio to restyle the dashboard after Supabase's DESIGN.md, light and dark

Worth knowing in OpenCode

Slash commands, agents, permissions and rules files: the parts of OpenCode that change how it uses the registry.

  • Seven prompts as slash commands

    Type / and the server's prompts are listed as /shadcnio:add, /shadcnio:block, /shadcnio:page and four more, marked :mcp. The words after the command fill in its arguments, and OpenCode sends the task with the calls that do it.

    /shadcnio:icons home, settings, log out
  • A line in AGENTS.md

    OpenCode reads AGENTS.md in the project, or CLAUDE.md when there's none, and /init writes one for you. One line there and you can drop use shadcnio from your prompts.

    Build UI with the shadcnio MCP: search it for a component or block first, then run the install command it returns.
  • Plan with the registry, then build

    Press Tab for Plan. It can't edit your files, but it can call the shadcnio tools, so it can pick a page's blocks with plan_page and write the plan down. Tab back to Build to install them.

  • Ask before shell commands

    By default OpenCode runs tools and shell commands without asking, npx shadcn add included. To check each command first, set bash to ask and allow the installs you trust; the last matching rule wins, so * goes first.

    {
      "permission": {
        "bash": {
          "*": "ask",
          "npx shadcn@latest add *": "allow"
        }
      }
    }
  • Attach a brand's DESIGN.md with @

    Type @ and a brand's slug, like posthog: beside your files, OpenCode lists the server's DESIGN.md for it. Pick it and the whole file goes into your message as context.

  • One-off runs with opencode run

    opencode run takes one prompt and exits, which suits scripts. Each run starts its MCP servers again; with opencode serve already running, --attach points the run at it and skips that wait.

    $ opencode run "use shadcnio to add a skeleton to the deploys table while it loads"

If OpenCode can't reach shadcnio

What opencode mcp list or a toast in the TUI tells you, and the fix. The troubleshooting guide covers every client.

shadcnio isn't in opencode mcp list at all.
OpenCode only reads servers under a top-level mcp key, so an mcpServers block copied from another editor doesn't load. Check you edited the file OpenCode uses: opencode debug config prints what it resolved.
OpenCode says shadcnio needs authentication.
shadcnio doesn't use OAuth: the token rides in the URL. A missing or old one gets a 401, which OpenCode reads as a sign-in request, so copy the entry again instead of running opencode mcp auth. With "oauth": false in the entry, a bad token shows as failed instead.
The shared opencode.json fails for one teammate.
{env:SHADCNIO_TOKEN} turns into an empty string when the variable isn't set, so the request carries no token. Export it in your shell profile, open a new terminal and start opencode again.
Calls to shadcnio fail with a 403.
OpenCode reached the server and the token is right, but the account has no active Pro plan. Renew it and restart: nothing in the entry changes.
opencode mcp list shows shadcnio as disabled.
The entry has "enabled": false. Set it to true, or remove the key, then quit and start OpenCode again.
OpenCode writes UI from memory instead of calling the tools.
Start the prompt with use shadcnio, or add the line from the tips to AGENTS.md. If you're in Plan, it can look things up but won't install: press Tab for Build.

Get the MCP for OpenCode with Pro

The MCP comes with every Pro plan, with every block and premium template, for you or your whole team. Monthly, yearly or lifetime.

4.9/5 out of 5 · 150+ reviewsfrom 150+ founders and developers.

  • Secure checkout via Stripe
  • Code lives in your repo
  • Keep what you've shipped if you cancel
  • License terms

Frequently asked questions

The shadcn MCP in OpenCode: setup, limits, and the rest.

4.9 out of 5 from 150+ developers

Put the registry in OpenCode

One remote entry in opencode.json, and every component, 6,231 blocks and 294k icons are a prompt away in your terminal, on any Pro plan.

Get Pro