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.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "credit_type_id": "<credit_type_id>",
      "amount": "<amount>"
    },
    "name": "deduct_credits"
  }
}

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. Signed in with 1Profile and owning several projects, it picks one)
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. Changed1 schema field changed
    • changedInput schema / properties / project_id / description
      Previous value: -"Cred project ID (optional; the API key already identifies the project)"New value: +"Cred project ID (optional; the API key already identifies the project. Signed in with 1Profile and owning several projects, it picks one)"
  2. First observed

TDQS

A4.6/5.0
Behavior5/5

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

With no annotations supplied, the description carries the full burden and does so: it names the failure codes and their side effects (400 INSUFFICIENT_CREDITS => nothing deducted, 404 USER_NOT_FOUND), replay semantics with idempotent_replay: true, the auto_topup_triggered side effect (a saved-card purchase), and the 1 CRD per-call cost that is charged even on rejected calls but waived on 429. That is exactly the review-level disclosure an agent needs before invoking a mutation.

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

Conciseness4/5

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

Every sentence carries information — failure codes, cost accounting, replay behavior, top-up side effect — with the verb and scope front-loaded. It is dense and unsegmented, reading as one long block, so scanability suffers slightly, but there is no filler to cut.

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, annotation-free mutation with no output schema, the description covers what would otherwise be blind spots: failure modes and their side effects, idempotent return fields (idempotent_replay, request_id, auto_topup_triggered), and the billing model. Little an agent needs in order to call it safely is left unstated.

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, but the description adds meaning beyond the schema by explaining why idempotency_key matters (replays charge nothing more, agents should key anything retryable), what auto_topup and the retry loop imply, and reaffirming the email-first identifier precedence. It does not explain the required credit_type_id (list_credit_types is not referenced) or amount bounds.

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 identifier resolution rule ("user_email (checked first) or user_id"). The spend-direction verb inherently separates it from issue_credits, redeem_credits, and refund_credits, so an agent can place it without reading the schema.

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 clear operational context: pass idempotency_key on anything an agent might retry, and without a key every call deducts again. It does not, however, state when to use this versus buy_credits_x402, issue_credits, or charge_saved_card, nor that a balance should be checked with get_balance first — those remain inference.

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