Skip to main content
Glama

deduct_credits

Deduct (spend) credits from an existing user, identified by user_email (checked first) or user_id. Fails with 400 INSUFFICIENT_CREDITS (nothing deducted) or 404 USER_NOT_FOUND. Pass idempotency_key on anything an agent might retry: a replay returns the original transaction with idempotent_replay: true and charges nothing more. Without a key, every call deducts again. auto_topup_triggered: true means the balance fell below the user's auto top-up threshold and a saved-card purchase started. Costs 1 CRD (platform credit) per call, charged even when the call is then rejected (a 429 RATE_LIMITED costs nothing). Error results include request_id; quote it to support.

Input Schema

NameRequiredDescriptionDefault
amountYesCredits to deduct (positive)
reasonNoReason, shown in the ledger
api_keyNoCred API key (optional if set via the x-api-key header)
user_idNoExternal user ID
project_idNoCred project ID (optional; the API key already identifies the project)
user_emailNoUser email (checked first)
reference_idNoYour reference, e.g. a job ID (also lets refund_credits find it)
x402_paymentNoBase64 x402 PaymentPayload, only when a previous call failed with an x402 PaymentRequired because the account is out of CRD
credit_type_idYesCredit type to deduct from
idempotency_keyNoUnique key for this deduction (max 255 chars). Retrying with the same key and same arguments returns the first result instead of repeating it; reusing it for different arguments fails with 409 IDEMPOTENCY_KEY_REUSED. Generate a fresh key (e.g. a UUID) per intended operation and reuse it only to retry that operation.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

A4.7/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the full burden and does so thoroughly: 400 INSUFFICIENT_CREDITS means nothing was deducted, 404 USER_NOT_FOUND, replay returns the original transaction with idempotent_replay: true, auto_topup_triggered signals a saved-card purchase, and the 1 CRD per-call cost applies even on rejection except for 429. This is exactly the behavioral context an agent needs before a destructive spend.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Front-loads the action and identity resolution, then layers error semantics, idempotency, side effects, and cost in short, information-dense sentences. No filler; every clause conveys a distinct operational fact.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a 10-parameter mutation with no annotations and no output schema, the description covers the critical gaps: failure codes and their side effects, retry safety, auto top-up side effect, per-call cost, and request_id for support escalation. Nothing essential to calling it correctly is missing.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so the baseline is 3; the description still adds value by stating the email-first resolution order and by linking reference_id to refund_credits ('also lets refund_credits find it'). The idempotency_key explanation largely restates the already-detailed schema text, keeping it from a 5.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb and resource ('Deduct (spend) credits from an existing user') plus the identity resolution order (user_email checked first, then user_id). This clearly separates it from siblings like issue_credits, refund_credits, and redeem_credits without needing to name them.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Gives concrete operational guidance: pass idempotency_key on anything an agent might retry, and explains the consequence of omitting it ('every call deducts again'). It does not explicitly route to alternatives (e.g., use issue_credits to add balance), but the failure modes and retry policy cover the main decision points.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.

Resources