magic MCP server always fails auth: installer sets TWENTYFIRST_API_KEY but package expects TWENTY_FIRST_API_KEY
Bug: magic MCP server installs with the wrong API key env var name, always fails with "Not authenticated"
Version: SuperClaude 4.3.0 (pip/pipx install)
What happens
Installing the magic MCP server via superclaude mcp --servers magic (or manually following the same env var name from the registry) results in claude mcp list reporting:
magic: npx -y @21st-dev/magic - ✘ Failed to connect — -32001: MCP error -32001: Not authenticated - your API key is missing or was reset. Get a fresh key at https://21st.dev/mcp and update your MCP config (x-api-key / Bearer).This happens even with a valid, freshly-generated 21st.dev API key.
Root cause
In superclaude/cli/install_mcp.py, the magic entry in MCP_SERVERS declares:
"magic": {
...
"api_key_env": "TWENTYFIRST_API_KEY",
...
},But the actual @21st-dev/magic package (dist/index.js, current published version 0.2.2) only looks for these env vars:
return (fromArgs.API_KEY ??
fromArgs.TWENTY_FIRST_API_KEY ??
fromArgs.API_KEY_21ST ??
process.env.TWENTY_FIRST_API_KEY ??
process.env.API_KEY_21ST ??
process.env.API_KEY);Note TWENTY_FIRST_API_KEY (underscore between TWENTY and FIRST) — not TWENTYFIRST_API_KEY. Since the installer writes the key under a name the package never reads, apiKey resolves to undefined and the server always reports "API key is missing", regardless of how valid the user's key is. This wastes a lot of time debugging what looks like a bad/revoked key.
Fix
In install_mcp.py, change:
"api_key_env": "TWENTYFIRST_API_KEY",to
"api_key_env": "TWENTY_FIRST_API_KEY",Repro / verification
# Fails (current registry value):
claude mcp add --transport stdio --scope user magic -e TWENTYFIRST_API_KEY="$KEY" -- npx -y @21st-dev/magic
claude mcp list # -> ✘ Not authenticated
# Works (correct env var name):
claude mcp remove magic --scope user
claude mcp add --transport stdio --scope user magic -e TWENTY_FIRST_API_KEY="$KEY" -- npx -y @21st-dev/magic
claude mcp list # -> ✔ ConnectedConfirmed working after switching the env var name, with the same API key that previously failed.
Related
Possibly related to the older #336 ("Where do you set MorphLLM and Magic API Keys?"), which also involves confusion around API key configuration for these same two servers, though that issue doesn't identify this specific env-var-name mismatch.
Source: SuperClaude-Org/SuperClaude_Framework