Heuristic:21st dev Magic mcp No Retry On Ai Subscription Required
| Knowledge Sources | |
|---|---|
| Domains | AI_Generation, Error_Handling |
| Last Updated | 2026-10-19 16:40 GMT |
Overview
`ai_subscription_required` from a `generate` call is terminal for the session — stop, do not retry through any alias or the CLI.
Description
When the 21st MCP server returns `ai_subscription_required` from a (cached or live) `generate` call, it means the account lacks hosted AI access for this session. This is a terminal refusal, not a transient error: retrying the same call, retrying through a legacy alias (`21st_magic_component_builder`, `21st_magic_component_refiner`), or retrying via the `@21st-dev/cli` will all hit the same gate and produce the same refusal. The proxy itself latches the underlying auth state per-process, so even a key change mid-session cannot unblock it without a restart.
Recovery is out-of-band: enable AI on the account at 21st.dev, then refresh the tool list (`tools/list`) or reconnect the client so `generate` reappears. Reads of existing drafts (`get_generation`, `get_take`) remain available with AI off — those are not gated and can still be called.
Usage
Apply this heuristic the moment `generate` (or any legacy alias of it) returns `ai_subscription_required`. Stop generation attempts for the rest of the session and tell the user to enable AI and reconnect. Do not loop, fall back to an alias, or shell out to the CLI as a workaround.
The Insight (Rule of Thumb)
- Action: On `ai_subscription_required`, stop calling `generate` (and its aliases) for the session.
- Value: Zero retries. Switch to `search`/`get_component` + your own coding agent for UI, or `get_generation`/`get_take` to read existing drafts.
- Trade-off: You forgo hosted AI for the session, but avoid an infinite retry loop that cannot succeed until the account is changed out-of-band.
- Compatibility: Applies to `generate`, `21st_magic_component_builder`, `21st_magic_component_refiner`, and CLI-driven generation equally.
Reasoning
The gate is account-level (`aiGenerationEnabled`), not request-level. A refusal means the entitlement is absent for this key/account, which no client-side retry can change. The repo's README and skill file both call this out explicitly because agents tend to retry refusals — and the proxy's `authRefused` latch (set on 401) plus the server's own entitlement check make every retry a wasted round-trip. Enabling AI and then refreshing `tools/list`/reconnecting is the only recovery, because the tool list is cached per session.
Code Evidence
`README.md:42-45` states the rule and the recovery:
A cached or legacy generation call can return `ai_subscription_required`. Do
not retry until AI is enabled. Refresh the client tool list or reconnect after
enabling AI. The proxy forwards discovery to the server, so existing proxy
versions receive this behavior without an npm update.
The skill file is even more explicit — `skills/21st-ui/SKILL.md:35,39`:
2. With AI off, use `search` and `get_component`, then implement or adapt the
UI with your own coding agent. Do not call generation tools, legacy
builder/refiner aliases, or the CLI as a workaround.
...
If a cached call returns `ai_subscription_required`, stop generation attempts.
`llms-install.md:50-54` repeats it for agent installers:
Do not retry `ai_subscription_required` through legacy aliases or the CLI.
Refresh tools or reconnect after enabling AI.
The `generate` implementation page marks the refusal terminal — `implementations/21st_dev_Magic_mcp_generate.md:147`:
* `ai_subscription_required` is terminal for this session — stop, don't retry.