Skip to main content
Glama

refund_credits

Refund or reverse credits. MOVES MONEY for purchases: with purchase_id or stripe_payment_intent_id it refunds the Stripe charge (prorated when partial; refund_payment: false skips the money) and claws the purchased credits back. With transaction_id (or reference_id = latest matching transaction) it reverses that ledger entry: an issue is clawed back, a deduct is returned to the user. Pass exactly one source. amount refunds part (default: all). idempotency_key is required here: retry with the same key to get the first result (idempotent_replay: true). Errors: 404 PURCHASE_NOT_FOUND / TRANSACTION_NOT_FOUND, 409 ALREADY_REFUNDED, 400 REFUND_EXCEEDS_ORIGINAL, 400 INSUFFICIENT_CREDITS (user already spent them), 400 NOT_REFUNDABLE (redeem/escrow entries), 402 STRIPE_REFUND_FAILED (no credits changed). 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": {
      "idempotency_key": "<idempotency_key>"
    },
    "name": "refund_credits"
  }
}

Input Schema

NameRequiredDescriptionDefault
amountNoCredits to refund (default: the full original amount)
reasonNoReason, shown in the ledger
api_keyNoCred API key (optional if set via the x-api-key header)
metadataNoExtra metadata stored on the refund transaction
project_idNoCred project ID (optional; the API key already identifies the project. Signed in with 1Profile and owning several projects, it picks one)
purchase_idNoCred purchase ID (refunds the payment + credits)
reference_idNoReverse the latest non-refund transaction with this reference_id
x402_paymentNoBase64 x402 PaymentPayload, only when a previous call failed with an x402 PaymentRequired because the account is out of CRD
refund_paymentNoPurchases only: false reverses credits without refunding money (default true)
transaction_idNoLedger transaction ID to reverse
idempotency_keyYesUnique key for this refund (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.
stripe_payment_intent_idNoStripe pi_… of the purchase (alternative to purchase_id)

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.8/5.0
Behavior5/5

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

No annotations exist, so the description carries the full burden and does: 'MOVES MONEY', prorated partial refunds, refund_payment: false skipping the money move, claw-back semantics, idempotent replay behavior, and negative cases (409 ALREADY_REFUNDED, 400 REFUND_EXCEEDS_ORIGINAL, 402 STRIPE_REFUND_FAILED with no credits changed). It even discloses billing behavior — 1 CRD per call charged even on rejection, 429 free — and that errors carry a request_id for support.

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?

Front-loaded with the highest-stakes fact ('MOVES MONEY') and then ordered by mode, then amount, idempotency, errors, cost. Dense but nearly every clause carries operational information; the heavy parenthetical stacking and error-code list make it dense to parse in one pass.

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 12-parameter, no-annotation, no-output-schema mutation tool, the description covers what an agent needs: which source to pass, partial-refund semantics, idempotency, failure modes with status codes, and cost. The idempotent_replay flag hints at the return shape despite the absence of an output schema.

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 meaning the schema does not, notably the mutual-exclusion rule ('exactly one source'), that reference_id targets the *latest* matching transaction, and that amount defaults to all. Most remaining parameter detail (idempotency retry, refund_payment) is already present in the schema, so it does not exceed the top band.

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 pair and resource ('Refund or reverse credits') and immediately splits the two modes: purchase refunds via purchase_id/stripe_payment_intent_id versus ledger reversals via transaction_id/reference_id. The clause 'an issue is clawed back, a deduct is returned' ties the tool to the sibling issue/deduct operations without ambiguity.

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

Usage Guidelines5/5

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

Explicitly names the alternative inputs and the condition that selects each ('with purchase_id ... it refunds the Stripe charge'; 'with transaction_id ... it reverses that ledger entry') and enforces an exclusion ('Pass exactly one source'). It also flags prerequisites (idempotency_key is required) and the cost/error conditions an agent needs before invoking.

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