Skip to content
Install
mcp-registry/21st.dev Magic MCP Server
21st.dev Magic MCP Server logo

21st.dev Magic MCP Server

Author: 21st-dev

Description: 21st.dev “Magic AI Agent” MCP server that generates modern UI components from natural-language prompts inside IDE agents (Cursor, Windsurf, VS Code/Cline, Claude). Works like “v0 in your IDE”: you type `/ui …`, the server generates and writes UI component files into your project following your code style.

Stars: 4.4k

Forks: 301

License: MIT License

Category: Enterprise

Overview

Installation

### Prerequisites (from README)
1. Install Node.js (Latest LTS recommended)
2. Use a supported IDE client: Cursor, Windsurf, VSCode (with Cline extension)
### 1) Generate an API key
1. Go to [https://21st.dev/magic/console](https://21st.dev/magic/console)
2. Generate a new API key
### 2) Install / configure (choose one method)
#### Method 1: CLI installation (recommended)
Run:
npx @21st-dev/cli@latest install <client> --api-key <key>
Supported clients: `cursor`, `windsurf`, `cline`, `claude`
#### Method 2: Manual MCP configuration
Add this to your IDE’s MCP config file:
{ "mcpServers": { "@21st-dev/magic": { "command": "npx", "args": ["-y", "@21st-dev/magic@latest", "API_KEY=\"your-api-key\""] } } }
Config file locations (from README):
- Cursor: `~/.cursor/mcp.json`
- Windsurf: `~/.codeium/windsurf/mcp_config.json`
- Cline: `~/.cline/mcp_config.json`
- Claude: `~/.claude/mcp_config.json`
#### Method 3: VS Code manual setup
In VS Code, open **User Settings (JSON)** and add:
{ "mcp": { "inputs": [ { "type": "promptString", "id": "apiKey", "description": "21st.dev Magic API Key", "password": true } ], "servers": { "@21st-dev/magic": { "command": "npx", "args": ["-y", "@21st-dev/magic@latest"], "env": { "API_KEY": "${input:apiKey}" } } } } }
Optionally, you can instead create `.vscode/mcp.json` in your workspace with:
{ "inputs": [ { "type": "promptString", "id": "apiKey", "description": "21st.dev Magic API Key", "password": true } ], "servers": { "@21st-dev/magic": { "command": "npx", "args": ["-y", "@21st-dev/magic@latest"], "env": { "API_KEY": "${input:apiKey}" } } } }

01

/ui

Generate a polished, modern UI component from a natural-language description and add it to your project (used from the AI agent chat, e.g. “/ui create a modern navigation bar with responsive design”).

FAQs

What types of UI components are available in the 21st.dev Magic curated library, and how often is it updated?

The article does not specify which component types are available or update frequency. Based on mentioned use cases, the library likely includes navigation bars, forms, cards, hero sections, modals, and pricing tables. For current inventory and update schedules, check the Magic console or GitHub repository directly.

How does an MCP server handle multiple client requests simultaneously?

MCP servers handle concurrent requests via transport-layer session isolation. StreamableHTTP uses session IDs mapped to per-client transport instances, routing requests without blocking. STDIO handles single clients; production multi-client setups proxy to multiple STDIO backends. Async handlers enable parallel tool execution across sessions while maintaining stateful, one-to-one JSON-RPC connections per client.

How do I update an existing MCP server configuration?

To update an existing MCP server configuration, edit the JSON config file for your IDE client and restart the client. Locate the file (for example, `~/.cursor/mcp.json` for Cursor), modify the server entry under `mcpServers`, and save. Changes take effect after restarting the IDE or reloading the MCP connection.

What are the main differences between MCP and other integration protocols used in AI?

MCP standardizes model-to-tool connections via JSON-RPC for data and API access, while A2A, ACP, and ANP prioritize agent-to-agent collaboration, orchestration, or decentralized networking. MCP excels at vertical integration with transparent tool schemas, whereas A2A manages horizontal agent coordination treating agents as opaque executors. These protocols complement rather than compete, often layered together in production.

Can you explain how to build a custom MCP server using the MCP Python SDK?

Building a custom MCP server requires the FastMCP class from the mcp package. Install via `pip install "mcp[cli]>=1.25,<2"`, create a server instance, then expose functions using the `@mcp.tool()` decorator with type hints for automatic schema generation. Run with `mcp.run(transport="stdio")` for IDE integration or `stateless_http=True` for web deployment.

What are the best practices for optimizing MCP server performance?

Monitor transport overhead by profiling STDIO latency and serialization time when chaining servers. Set resource limits in client configs to prevent memory spikes during concurrent calls. Cache frequently requested metadata to avoid redundant lookups. Use connection pooling for external APIs. Profile Node.js heap usage and consider Node 20+ for V8 JSON parsing improvements.

License: MIT License
Updated 2/17/2026