Skip to main content
Glama

list_customer_charges_credits

List all charges and credits for a customer. Filter by status or type (charge/credit) to view specific billing transactions.

Instructions

List charges and credits for a customer. GET /customers/{customerId}/charges_credits. Optional filters: status, type (charge or credit).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
customerIdYesCustomer ID (required)
statusNoFilter by status
typeNoFilter by type: charge or credit
pageNoNoPage number (1-based)
itemPerPageNoItems per page

Implementation Reference

  • The handler function that orchestrates the tool logic: parses Zod-validated args, then calls the service layer's listCustomerChargesCredits to perform the GET request.
    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 { customerId, status, type, pageNo, itemPerPage } = parsed.data;
      return handleToolCall(() =>
        customerService.listCustomerChargesCredits(client, customerId, {
          status,
          type,
          pageNo,
          itemPerPage,
        })
      );
    }
  • Zod schema for input validation. Validates customerId (required string), status (optional string), type (optional enum 'charge'|'credit'), pageNo and itemPerPage (optional positive integers).
    const schema = z.object({
      customerId: z.string().min(1, "customerId is required"),
      status: z.string().optional(),
      type: z.enum(["charge", "credit"]).optional(),
      pageNo: z.number().int().min(1).optional(),
      itemPerPage: z.number().int().min(1).optional(),
    });
  • Tool definition/registration metadata: MCP tool name, description, and input schema (JSON Schema format) for the MCP protocol.
    const definition = {
      name: "list_customer_charges_credits",
      description:
        "List charges and credits for a customer. GET /customers/{customerId}/charges_credits. Optional filters: status, type (charge or credit).",
      inputSchema: {
        type: "object" as const,
        properties: {
          customerId: { type: "string", description: "Customer ID (required)" },
          status: { type: "string", description: "Filter by status" },
          type: { type: "string", description: "Filter by type: charge or credit" },
          pageNo: { type: "number", description: "Page number (1-based)" },
          itemPerPage: { type: "number", description: "Items per page" },
        },
        required: ["customerId"],
      },
    };
  • Registration: the tool is included in the array returned by registerCustomerTools(), which collects all customer tools for the main tool registry.
    export function registerCustomerTools(): Tool[] {
      return [
        listCustomersTool,
        getCustomerTool,
        createCustomerTool,
        updateCustomerTool,
        deleteCustomerTool,
        getCustomerInvoicesTool,
        getCustomerUnpaidInvoicesTool,
        getCustomerSubscriptionsTool,
        getCustomerLogsTool,
        listCustomerAddressesTool,
        getCustomerAddressTool,
        createCustomerAddressTool,
        updateCustomerAddressTool,
        deleteCustomerAddressTool,
        listCustomerPaymentMethodsTool,
        getCustomerPaymentMethodTool,
        createCustomerPaymentMethodTool,
        updateCustomerPaymentMethodTool,
        deleteCustomerPaymentMethodTool,
        listCustomerChargesCreditsTool,
        createCustomerChargeCreditTool,
        deleteCustomerChargeCreditTool,
      ];
    }
  • Service-layer helper function that builds the URLSearchParams and performs the GET /customers/{customerId}/charges_credits HTTP request using the API client.
    export async function listCustomerChargesCredits(
      client: Client,
      customerId: string,
      params?: ListChargesCreditsParams
    ): Promise<PaginatedResponse<unknown>> {
      const search = new URLSearchParams();
      if (params?.status) search.append("status", params.status);
      if (params?.type) search.append("type", params.type);
      if (params?.include) search.append("include", params.include);
      if (params?.pageNo != null) search.append("pageNo", String(params.pageNo));
      if (params?.itemPerPage != null) search.append("itemPerPage", String(params.itemPerPage));
      const q = search.toString();
      return client.get<PaginatedResponse<unknown>>(
        `/customers/${customerId}/charges_credits${q ? `?${q}` : ""}`
      );
    }
Behavior2/5

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

No annotations are provided, so the description must disclose behavioral traits. It states the HTTP method (GET) implying read-only, but does not mention authentication needs, rate limits, or pagination behavior. The description lacks details about the return format or any side effects.

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?

The description is two efficient sentences. The first sentence states the purpose, and the second provides the endpoint and optional filters. No unnecessary words, well front-loaded.

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 is brief and misses important context about pagination (despite pagination parameters), output structure, and use cases. For a list tool with no output schema and no annotations, more completeness is expected. However, the core functionality is covered.

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?

Schema description coverage is 100% (5 parameters all described). The description adds context by explaining that 'status' and 'type' are filters, but does not mention the pagination parameters (pageNo, itemPerPage). This adds marginal value over the schema, leading to a baseline score of 3.

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 the action ('List charges and credits') and the resource ('for a customer'), and provides the endpoint. It distinguishes from sibling tools like create_customer_charge_credit and get_customer_invoices by specifying it's a list operation for charges/credits.

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 mentions optional filters (status, type) but does not provide guidance on when to use this tool versus alternatives like get_customer_invoices or list_transactions. Given the many sibling tools, explicit use cases or exclusions would improve this.

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