This guide is specifically designed for AI agents like Cline to install and configure the Magic MCP server.
- Node.js (Latest LTS version)
- A valid TWENTY_FIRST_API_KEY from 21st.dev/magic
The Magic MCP server requires configuration based on the client type. Below are the setup instructions for each supported client:
- Create or modify the configuration file at
~/.codeium/windsurf/mcp_config.json
:
{
"mcpServers": {
"magic": {
"command": "npx",
"args": [
"-y",
"@smithery/cli@latest",
"install",
"@21st-dev/magic-mcp",
"--client",
"windsurf"
],
"env": {
"TWENTY_FIRST_API_KEY": "<API_KEY>"
}
}
}
}
- Replace
<API_KEY>
with the actual TWENTY_FIRST_API_KEY value.
- Create or modify the MCP configuration file:
{
"mcpServers": {
"@21st-dev-magic-mcp": {
"command": "npx",
"args": [
"-y",
"@smithery/cli@latest",
"run",
"@21st-dev/magic-mcp",
"--config",
"\"{\\\"TWENTY_FIRST_API_KEY\\\":\\\"<API_KEY>\\\"}\""
]
}
}
}
- Replace
<API_KEY>
with the actual TWENTY_FIRST_API_KEY value.
To verify the installation:
- The MCP server should appear in the list of available servers
- Test the connection by sending a simple command:
/ui create a basic button
Common issues and solutions:
-
If the server fails to start:
- Verify the API key is valid
- Check Node.js version (should be LTS)
- Ensure all dependencies are installed
-
If components fail to generate:
- Verify network connectivity
- Check API key permissions
- Ensure the command format is correct
Required environment variables:
TWENTY_FIRST_API_KEY
: Your Magic API key from 21st.dev
- The server automatically handles TypeScript and React components
- No additional configuration is needed for basic usage
- The server supports hot reloading for development
If you encounter any issues:
- Check the FAQ section
- Join our Discord community
- Submit an issue on GitHub
This installation guide is maintained by the Magic team. For updates and more information, visit 21st.dev/magic.