/ 目錄 / 演練場 / 21st.dev Magic MCP
● 官方 21st-dev ⚡ 即開即用

21st.dev Magic MCP

作者 21st-dev · 21st-dev/magic-mcp

Generate beautiful React components inline — like v0, but inside your editor.

Magic MCP is 21st.dev's component generator: ask in plain English, get a production-quality React + Tailwind component returned inline. Works in Cursor, Claude Code, Windsurf — anywhere MCP runs.

為什麼要用

核心特性

即時演示

實際使用效果

magic-mcp.replay ▶ 就緒
0/0

安裝

選擇你的客戶端

~/Library/Application Support/Claude/claude_desktop_config.json  · Windows: %APPDATA%\Claude\claude_desktop_config.json
{
  "mcpServers": {
    "magic-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "@21st-dev/magic@latest"
      ]
    }
  }
}

開啟 Claude Desktop → Settings → Developer → Edit Config。儲存後重啟應用。

~/.cursor/mcp.json · .cursor/mcp.json
{
  "mcpServers": {
    "magic-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "@21st-dev/magic@latest"
      ]
    }
  }
}

Cursor 使用與 Claude Desktop 相同的 mcpServers 格式。專案級設定優先於全域。

VS Code → Cline → MCP Servers → Edit
{
  "mcpServers": {
    "magic-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "@21st-dev/magic@latest"
      ]
    }
  }
}

點擊 Cline 側欄中的 MCP Servers 圖示,然後選 "Edit Configuration"。

~/.codeium/windsurf/mcp_config.json
{
  "mcpServers": {
    "magic-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "@21st-dev/magic@latest"
      ]
    }
  }
}

格式與 Claude Desktop 相同。重啟 Windsurf 生效。

~/.continue/config.json
{
  "mcpServers": [
    {
      "name": "magic-mcp",
      "command": "npx",
      "args": [
        "-y",
        "@21st-dev/magic@latest"
      ]
    }
  ]
}

Continue 使用伺服器物件陣列,而非映射。

~/.config/zed/settings.json
{
  "context_servers": {
    "magic-mcp": {
      "command": {
        "path": "npx",
        "args": [
          "-y",
          "@21st-dev/magic@latest"
        ]
      }
    }
  }
}

加入 context_servers。Zed 儲存後熱重載。

claude mcp add magic-mcp -- npx -y @21st-dev/magic@latest

一行命令搞定。用 claude mcp list 驗證,claude mcp remove 移除。

使用場景

實戰用法: 21st.dev Magic MCP

Generate a polished landing-page hero in under a minute

👤 Frontend engineers shipping fast ⏱ ~15 min intermediate

何時使用: You need a hero section right now and don't want to start from a blank file.

前置條件
  • Server/skill installed and authenticated — See repo README
步驟
  1. Search for inspiration
    Search 21st for hero sections that mix gradient + product screenshot.✓ 已複製
    → 5–10 starter components
  2. Generate the final one
    Create a Hero component: dark gradient bg, headline 'Ship faster.' subhead 'AI for serious teams.' a primary CTA + secondary CTA, social proof row.✓ 已複製
    → A complete tsx file using shadcn primitives

結果: A real production-shape component in one prompt.

注意事項
  • Generated components assume shadcn primitives are installed — Generated components assume shadcn primitives are installed — run npx shadcn add button card first.
搭配使用: filesystem · flyonui-mcp

組合

與其他 MCP 搭配,撬動十倍槓桿

magic-mcp + filesystem

Pair with filesystem for complementary capabilities

Use this server together with filesystem to complete a multi-step task.✓ 已複製
magic-mcp + flyonui-mcp

Pair with flyonui-mcp for complementary capabilities

Use this server together with flyonui-mcp to complete a multi-step task.✓ 已複製

工具

此 MCP 暴露的能力

工具輸入參數何時呼叫成本
create_component description, framework Need a new UI component 21st credits
refine_component component_code, instruction Tweak an existing component 21st credits
search_components query Find a pre-made starting point 1 API call

成本與限制

運行它的成本

API 配額
See provider docs for rate limits
每次呼叫 Token 數
Varies by tool
費用
See repo README for pricing details
提示
Cache tool results and avoid repeated identical calls.

安全

權限、密鑰、影響範圍

憑證儲存: Use environment variables; never commit secrets
資料出站: Tool calls go to the provider's API as documented

故障排查

常見錯誤與修復

API key invalid

Get a key at 21st.dev/settings/api and set TWENTY_FIRST_API_KEY.

驗證: search_components returns results
component uses missing shadcn import

Run npx shadcn add <component> for each unresolved import.

驗證: Vite/Next builds cleanly

替代方案

21st.dev Magic MCP 對比其他方案

替代方案何時用它替代權衡
v0.devYou prefer the v0 web UIOutside your editor; different style

更多

資源

📖 閱讀 GitHub 上的官方 README

🐙 查看未解決的 issue

🔍 瀏覽全部 400+ MCP 伺服器和 Skills