Skip to main content
Glama

refund_transaction

Refund a transaction by providing its ID and the refund amount in cents. Supports partial refunds for subscription billing.

Instructions

Refund a transaction. POST /transactions/{transactionId}/refund. AMOUNT IN CENTS: e.g. 250 = $2.50, 5500 = $55.00. Required: transactionId, amount (integer cents).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
transactionIdYesTransaction ID (required)
amountYesRefund amount in CENTS (e.g. 250 = $2.50, 5500 = $55.00). Integer, required.

Implementation Reference

  • The handler function that executes the refund_transaction tool logic. It parses args with Zod schema, extracts transactionId and amount, then calls transactionService.refundTransaction.
    async function handler(client: Client, args: Record<string, unknown> | undefined) {
      const parsed = schema.safeParse(args);
      if (!parsed.success) {
        return errorResult(parsed.error.errors.map((e) => e.message).join("; "));
      }
      const { transactionId, amount } = parsed.data;
      return handleToolCall(() =>
        transactionService.refundTransaction(client, transactionId, amount)
      );
    }
  • Zod validation schema for refund_transaction. Requires transactionId (string) and amount (integer in cents).
    const schema = z.object({
      transactionId: z.string().min(1, "transactionId is required"),
      amount: z.number().int().min(0, "amount is required (in CENTS, e.g. 250 = $2.50)"),
    });
  • MCP tool definition/inputSchema for refund_transaction, describing name, description, and input JSON Schema properties.
    const definition = {
      name: "refund_transaction",
      description:
        "Refund a transaction. POST /transactions/{transactionId}/refund. AMOUNT IN CENTS: e.g. 250 = $2.50, 5500 = $55.00. Required: transactionId, amount (integer cents).",
      inputSchema: {
        type: "object" as const,
        properties: {
          transactionId: { type: "string", description: "Transaction ID (required)" },
          amount: {
            type: "number",
            description:
              "Refund amount in CENTS (e.g. 250 = $2.50, 5500 = $55.00). Integer, required.",
          },
        },
        required: ["transactionId", "amount"],
      },
    };
  • Registration of refundTransactionTool as part of the transaction tools array returned by registerTransactionTools().
    export function registerTransactionTools(): Tool[] {
      return [
        listTransactionsTool,
        getTransactionTool,
        refundTransactionTool,
        voidTransactionTool,
      ];
    }
  • The actual API call helper: POST /transactions/{transactionId}/refund?amount={amountCents}. Amount is passed in cents.
    /** POST /transactions/{transactionId}/refund?amount={amount}. amount in CENTS (e.g. 250 = $2.50). Required. */
    export async function refundTransaction(
      client: Client,
      transactionId: string,
      amountCents: number
    ): Promise<unknown> {
      const search = new URLSearchParams();
      search.append("amount", String(amountCents));
      const q = search.toString();
      return client.post<unknown>(
        `/transactions/${transactionId}/refund?${q}`,
        {}
      );
    }
Behavior2/5

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

No annotations are provided, so the description carries full burden. It discloses the action (refund) but omits side effects, idempotency, permissions, or reversibility. For a financial operation, more behavioral context is expected.

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?

Three sentences front-load the core action, then add endpoint and critical amount detail. No wasted words; each sentence serves a purpose.

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

Completeness3/5

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

The description covers the basic action and required fields but lacks return value, error handling, idempotency, or any post-refund behavior. Adequate but not comprehensive.

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

Parameters3/5

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

Input schema covers 100% of parameters with descriptions. The description reinforces the amount format (cents) and required fields, adding a helpful example. This is baseline-level value with minor extra context.

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?

The description clearly states 'Refund a transaction' – a specific verb and resource. It also provides the HTTP endpoint and distinguishes from sibling tools like void_transaction or charge_invoice by focusing on refunds.

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

Usage Guidelines3/5

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

The description implies usage (refund a transaction) but does not explicitly state when to use or not use this tool versus alternatives like void_transaction. No exclusions or context provided.

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

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/rhinosaas/rebillia-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server