Connect 21st.dev to OpenCode
Community marketplace of React components, templates, shadcn themes and shaders, with a hosted MCP server for agents. Browsing is free; copying more than a few components a day needs a membership.
MCP serverOfficialChecked 2026-11-16
Before you start
- OpenCode installed (see its MCP documentation (opens in a new tab)).
- 21st.dev is available on macOS, Windows, Linux and the web.
- Get an API key at 21st.dev/mcp and set it as
API_KEY_21STin your environment. Keys from the old Magic console no longer work. AI generation tools only appear when your account has AI access. Each component page also shows its own shadcn CLI command.
Step 1: Add 21st.dev to OpenCode
Add it from the terminal
Run this in your project folder. It saves the server to the project's
opencode.json.Terminal opencode mcp add 21st-dev --url https://21st.dev/api/mcp --header 'x-api-key={env:API_KEY_21ST}'Or edit the config file
Add this to
opencode.jsonat the project root.opencode.json { "$schema": "https://opencode.ai/config.json", "mcp": { "21st-dev": { "type": "remote", "url": "https://21st.dev/api/mcp", "enabled": true, "oauth": false, "headers": { "x-api-key": "{env:API_KEY_21ST}" } } } }Good to know- OpenCode's background service reads
API_KEY_21STwhen it starts, not from the terminal you're in. Set the variable, then runopencode service restart.
- OpenCode's background service reads
Step 2: Check it's connected
Terminal opencode mcp listStart OpenCode in the project; the server's tools are available to the agent straight away.
Step 3: Try a first request
Ask OpenCode something that only works with 21st.dev connected:
Say to OpenCode Search 21st.dev for a pricing section that fits this page and show me how to adapt it.
If it doesn't work
- OpenCode reads
opencode.jsonfrom the project root, or~/.config/opencode/opencode.jsonfor every project. - Environment variables use the
{env:NAME}syntax inside the config file. - Servers that need a sign-in: run
opencode mcp auth <name>.





