Environment:21st dev Magic mcp Node Runtime
| Knowledge Sources | |
|---|---|
| Domains | Infrastructure, Runtime |
| Last Updated | 2026-10-19 16:40 GMT |
Overview
Node.js >= 18.0.0 runtime for the zero-dependency `@21st-dev/magic` stdio↔HTTP MCP proxy.
Description
This environment is the plain Node.js process that hosts the `magic` bin (`dist/index.js`), the sole entry point of `@21st-dev/magic`. The proxy is a single TypeScript source file (`src/index.ts`) compiled to ES-Module JavaScript; it has no runtime dependencies — only the Node.js standard library (`node:readline`, the global `fetch`, `process.stdin/stdout/stderr`). Node 18+ is required because the shim uses the global `fetch` API (stable since Node 18) and `node:readline`'s `createInterface`.
The package's `engines.node` field declares `>=18.0.0`; `@types/node` is pinned to `^22.13.4` for type-checking only and does not need to match the runtime. TypeScript is a dev-only build step (`tsc` + `shx chmod +x`); the published artifact is plain JS in `dist/`.
Usage
Use this environment whenever the `@21st-dev/magic` compatibility proxy is launched — i.e. via `npx -y @21st-dev/magic@latest API_KEY="..."` or as a stdio MCP server configured in an agent's `mcp.json` `command`/`args` entry. Any client that can spawn a Node process and speak JSON-RPC over stdio can host it; no Docker, no GPU, no extra libraries.
System Requirements
| Category | Requirement | Notes |
|---|---|---|
| OS | Linux / macOS / Windows | Any OS that runs Node 18+; the proxy is OS-agnostic |
| Hardware | Any CPU, ~50MB RAM | Single Node process; memory bounded by the stdin buffer |
| Disk | < 5MB | The published package ships only `dist/` (a single JS file) |
| Network | Outbound HTTPS to 21st.dev | The proxy POSTs every JSON-RPC line to https://21st.dev/api/mcp |
Dependencies
System Packages
- `node` >= 18.0.0 (global `fetch`, `node:readline`)
npm Packages (runtime)
- None — `@21st-dev/magic` has zero runtime dependencies (see `package.json` `dependencies`: absent).
npm Packages (build only, not shipped)
- `typescript` ^5.8.2 (compile `src/` → `dist/`)
- `shx` ^0.3.4 (chmod the built bin)
- `@types/node` ^22.13.4 (type-checking only)
Credentials
The proxy resolves one of the following at startup (see Implementation:21st_dev_Magic_mcp_resolveApiKey for precedence). Only the names are required — never commit the values.
- `API_KEY_21ST` — recommended environment variable for plugin configs.
- `TWENTY_FIRST_API_KEY` — alternate env var name.
- `API_KEY` — legacy env var fallback.
- `API_KEY="..."` / `--API_KEY=...` / `/API_KEY:...` / `-API_KEY ...` — argv forms baked into old agent configs.
- `MCP_URL_21ST` — optional override of the default endpoint `https://21st.dev/api/mcp`.
Keys are issued free at https://21st.dev/mcp; old Magic keys were reset and are invalid.
Quick Install
# The proxy is launched directly via npx — no install step needed:
npx -y @21st-dev/magic@latest API_KEY="21st-xxxxx"
# Or, if running from a checkout, build then start:
npm install # dev deps only (typescript, shx, @types/node)
npm run build # tsc && shx chmod +x dist/*.js
node dist/index.js API_KEY="21st-xxxxx"
Code Evidence
Node 18 minimum is enforced by `package.json:41-43`:
"engines": {
"node": ">=18.0.0"
}
The proxy uses the global `fetch` (Node 18+) and `node:readline` — the only import in `src/index.ts:18`:
import { createInterface } from "node:readline";
// ...
res = await fetch(endpoint, { method: "POST", headers, body: line });
Zero runtime deps — `package.json` has no `dependencies` field, only `devDependencies` (`package.json:36-40`):
"devDependencies": {
"@types/node": "^22.13.4",
"shx": "^0.3.4",
"typescript": "^5.8.2"
}
The bin entry points at the compiled JS (`package.json:11-13`):
"bin": { "magic": "dist/index.js" },
"main": "dist/index.js",
Common Errors
| Error Message | Cause | Solution |
|---|---|---|
| `ReferenceError: fetch is not defined` | Node < 18 (global `fetch` absent) | Upgrade to Node >= 18.0.0 |
| `Cannot find module 'dist/index.js'` | Package cloned but not built | Run `npm install && npm run build`, or use `npx -y @21st-dev/magic@latest` |
| `21st MCP endpoint unreachable (...)` | Network blocked or `MCP_URL_21ST` mis-set | Allow outbound HTTPS to 21st.dev, or unset `MCP_URL_21ST` to use the default endpoint |
| `Not authenticated - your API key is missing or was reset` | No key resolved, or endpoint returned 401 (latched) | Issue a fresh key at https://21st.dev/mcp and restart the proxy with it |
Compatibility Notes
- Node 16 / 17: Not supported — global `fetch` is unavailable before Node 18.
- Bun / Deno: Untested. The code is portable ES modules, but `npx` and the `engines` declaration target Node.
- Windows: Supported; the `/API_KEY:value` argv form exists precisely for Windows-style flags.
- Docker: Not required; any base image with Node 18+ works (e.g. `node:20-alpine`).