Skip to content

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_21ST in 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.
  1. 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.json at 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_21ST when it starts, not from the terminal you're in. Set the variable, then run opencode service restart.
  2. Step 2: Check it's connected

    Terminal
    opencode mcp list

    Start OpenCode in the project; the server's tools are available to the agent straight away.

  3. 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.json from the project root, or ~/.config/opencode/opencode.json for every project.
  • Environment variables use the {env:NAME} syntax inside the config file.
  • Servers that need a sign-in: run opencode mcp auth <name>.