Principle:21st dev Magic mcp AI Access Verification
| Knowledge Sources | |
|---|---|
| Domains | Authentication, AI_Generation |
| Last Updated | 2026-10-19 16:40 GMT |
Overview
A gating pattern that checks the account's AI entitlement (via usage metadata and tool discovery) before attempting any hosted AI generation, treating missing or unknown status as "no".
Description
AI access verification is the act of confirming that the authenticated account is entitled to hosted AI generation before calling a generation tool. It addresses the limitation of assuming entitlement: builder/component access does not enable hosted AI, and a missing or unknown status is not permission to generate. A good verification checks two signals — an explicit entitlement flag (`get_usage.aiGenerationEnabled`) and the presence of the generation tool in discovery (`tools/list` includes `generate`). Only when both are positive is generation permitted. A refusal (`ai_subscription_required`) from a cached/legacy call is terminal for the session and must not be retried.
Usage
Use this principle before any hosted AI generation call. It is the precondition of the generation workflow. With AI off, fall back to catalog search + retrieval and adapt code with your own coding agent; do not call generation tools, legacy builder/refiner aliases, or the CLI as a workaround.
Theoretical Basis
The core operation is a two-signal gate:
# Abstract algorithm description (NOT real implementation)
usage = get_usage() # account entitlements
tools = tools_list() # discovery
ai_on = usage.aiGenerationEnabled and ("generate" in tools)
if not ai_on:
fallback_to_catalog_search() # do NOT generate
else:
generate(...) # permitted
The gate is conjunctive and conservative: either signal failing means "no".
Practical Guide
- Check `get_usage.aiGenerationEnabled` and that `generate` is listed in `tools/list`.
- Missing or unknown status is not permission to generate.
- A cached call returning `ai_subscription_required` is terminal — stop, don't retry.
- After enabling AI, refresh the tool list or reconnect before generating.
- `get_usage` reports access, not remaining credit balance.
Related Pages
Implemented By
Notes
- A successful `tools/list` also confirms auth works (precondition: Principle:21st_dev_Magic_mcp_API_Key_Management).
- Gate for Principle:21st_dev_Magic_mcp_AI_UI_Generation.