--- name: reachiz-credits-guard description: Use before any credit-spending Reachiz MCP call, or when the user asks "how many credits do I have", "top me up", "what will this cost" — balance, quotes and checkout through the Reachiz MCP. --- # Credits: check, quote, top up ## Steps 1. `get_credits` — returns `{ balance, recurringBalance, recurringExpiresAt }`. If the MCP reports credits as null, the key lacks `billing.read` (and `billing.*` needs a tenant-admin key): say so, and skip quoting rather than guessing. 2. Before any tool that spends credits (enrich, verify, searches, signals, play design): `post_quote { name: "", arguments: { params: {...}, body: {...} } }` → `{ credits, unit, exact, gate: { confirmRequired } }`. `credits` is the max possible debit; never reserves or consumes. 3. Tell the user the quote, then run the real tool with `confirm: true` only after approval. 4. Low balance: `get_credits_packs` → `{ data: [{ id, credits, priceCents, popular }] }`. 5. `post_credits_checkout` `body: { packId }` — not confirm-gated (it creates no charge itself) — returns a Stripe Checkout URL. Give the user the link; paying is their action in a browser. ## Ask the user first - Never run a spend tool without reading the `post_quote` number to the user first and getting an explicit yes. Quotes cost nothing; running does. - `post_credits_checkout` needs no `confirm`, but do not fire it on speculation — the user picks the pack. ## Common errors (real responses) - `isError` "The payment service is unreachable. Try again in a minute. (unavailable)" on checkout — Stripe-side; wait and retry once, then send the user to the dashboard billing page instead. - `isError` "forbidden" mentioning a scope (e.g. `billing.read`) — the key lacks the scope; the user must create a key with it in Settings → API keys. - `isError` "Not run: this tool spends credits…(invalid_request)" — spend tool without `confirm`; get approval first. - `isError` "Invalid params" — quoting a non-default tool is fine inside `post_quote`, but the real call to it must go through `call_tool`. ## Stop rule After the checkout link or the quote is delivered, stop. Never loop balance checks, and never retry `unavailable` more than twice without telling the user.