Skip to main content
Glama

charge_invoice

Charge an invoice via card/online payment. Provide invoice ID, amount in cents, and set paymentType to thirdPartyPaymentProvider for card/online.

Instructions

Charge an invoice (card/online payment). POST /invoices/{invoiceId}/charge. AMOUNT IN CENTS: e.g. 5500 = $55.00. Required: invoiceId, amount (integer cents), paymentType (offlinePaymentProvider | thirdPartyPaymentProvider | walletPaymentProvider | otherPayment). Use thirdPartyPaymentProvider for card/online.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
invoiceIdYesInvoice ID (required)
amountYesAmount in CENTS (e.g. 5500 = $55.00). Integer, required.
paymentTypeYesPayment type (required): offlinePaymentProvider, thirdPartyPaymentProvider, walletPaymentProvider, or otherPayment. Use thirdPartyPaymentProvider for card/online.

Implementation Reference

  • Handler function for the charge_invoice tool. Parses args with Zod schema (invoiceId, amount, paymentType), then calls invoiceService.chargeInvoice to POST /invoices/{invoiceId}/charge.
    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 { invoiceId, amount, paymentType } = parsed.data;
      return handleToolCall(() =>
        invoiceService.chargeInvoice(client, invoiceId, { amount, paymentType })
      );
    }
  • Zod validation schema for charge_invoice: invoiceId (string), amount (positive integer in cents), paymentType (enum of 4 values).
    const schema = z.object({
      invoiceId: z.string().min(1, "invoiceId is required"),
      amount: z.number().int().min(1, "amount is required and must be positive (in CENTS)"),
      paymentType: z.enum(paymentTypeEnum, { required_error: "paymentType is required" }),
    });
  • MCP tool definition (name: charge_invoice, description, inputSchema with properties invoiceId, amount, paymentType).
    const definition = {
      name: "charge_invoice",
      description:
        "Charge an invoice (card/online payment). POST /invoices/{invoiceId}/charge. AMOUNT IN CENTS: e.g. 5500 = $55.00. Required: invoiceId, amount (integer cents), paymentType (offlinePaymentProvider | thirdPartyPaymentProvider | walletPaymentProvider | otherPayment). Use thirdPartyPaymentProvider for card/online.",
      inputSchema: {
        type: "object" as const,
        properties: {
          invoiceId: { type: "string", description: "Invoice ID (required)" },
          amount: {
            type: "number",
            description: "Amount in CENTS (e.g. 5500 = $55.00). Integer, required.",
          },
          paymentType: {
            type: "string",
            description: "Payment type (required): offlinePaymentProvider, thirdPartyPaymentProvider, walletPaymentProvider, or otherPayment. Use thirdPartyPaymentProvider for card/online.",
          },
        },
        required: ["invoiceId", "amount", "paymentType"],
      },
    };
  • Exported Tool object combining definition and handler for charge_invoice.
    export const chargeInvoiceTool: Tool = {
      definition,
      handler,
    };
  • registerInvoiceTools() includes chargeInvoiceTool in the list of all invoice tools returned.
    export function registerInvoiceTools(): Tool[] {
      return [
        listInvoicesTool,
        getInvoiceTool,
        createInvoiceTool,
        updateInvoiceTool,
        deleteInvoiceTool,
        chargeInvoiceTool,
        chargeInvoiceExternalTool,
        voidInvoiceTool,
      ];
    }
Behavior2/5

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

No annotations are provided, so the description carries the full burden. It mentions the endpoint and 'AMOUNT IN CENTS' but does not disclose side effects, idempotency, error states, or authentication needs.

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 lines with no redundancy: one sentence for purpose, one for endpoint, and one for parameter hints. Every part adds information.

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

Completeness2/5

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

For a mutation tool with no output schema, the description omits return values, error handling, and prerequisites (e.g., invoice state). It is minimally adequate but leaves significant gaps.

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%, providing a baseline of 3. The description adds value by giving an example for amount (5500 = $55.00), listing paymentType options, and recommending a specific provider for card/online payments.

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

Purpose4/5

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

The description clearly states the verb 'charge' and resource 'invoice', and mentions card/online payment. It specifies the endpoint and payment types, but does not explicitly differentiate from the sibling 'charge_invoice_external'.

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 lists required parameters and advises using 'thirdPartyPaymentProvider' for card/online payments, implying when to use. However, it lacks guidance on when not to use or alternatives (e.g., charge_invoice_external).

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