Skip to main content
Glama

get_ledger

Retrieve recent billing ledger entries for your organization to monitor financial transactions and track credits or debits.

Instructions

Get recent billing ledger entries for your organization

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNoNumber of entries (default 20, max 100)
event_typeNoFilter: debit, credit_added, auto_reload_triggered

Implementation Reference

  • The core handler function for the get_ledger tool, responsible for calling the API client and sanitizing inputs.
    export async function handleGetLedger(
      input: GetLedgerInput,
      client: RhumbApiClient
    ): Promise<GetLedgerOutput> {
      const limit = Math.min(Math.max(input.limit ?? 20, 1), 100);
    
      try {
        const ledger = await client.getLedger(limit, input.event_type);
        return ledger;
      } catch (err) {
        return {
          entries: [],
          total_count: 0,
        };
      }
    }
  • Type definitions and schema for input/output of the get_ledger tool.
    export const GetLedgerInputSchema = {
      type: "object" as const,
      properties: {
        limit: { type: "number" as const, description: "Number of entries (default 20, max 100). Most recent first." },
        event_type: { type: "string" as const, description: "Filter: 'debit' (call charges), 'credit_added' (top-ups), 'auto_reload_triggered' (auto-refills). Omit for all types." },
      },
      required: [] as string[],
    };
    
    export type GetLedgerInput = {
      limit?: number;
      event_type?: string;
    };
    
    export type GetLedgerOutput = {
      entries: Array<{
        id: string;
        event_type: string;
        amount_usd_cents: number;
        balance_after_usd_cents: number;
        description: string;
        created_at: string;
      }>;
      total_count: number;
    };
  • MCP tool registration for "get_ledger" in the main server file.
    // -- get_ledger --------------------------------------------------------
    server.tool(
      "get_ledger",
      "Get your billing history: charges (debits), top-ups (credits), and auto-reload events. Each entry shows amount, balance after, description, and timestamp. Most recent first.",
      {
        limit: z.number().min(1).max(100).optional().describe("Number of entries (default 20, max 100)"),
        event_type: z.string().optional().describe("Filter: debit, credit_added, auto_reload_triggered")
      },
      async ({ limit, event_type }) => {
        const result = await handleGetLedger({ limit, event_type }, client);
        return {
          content: [{ type: "text" as const, text: JSON.stringify(result) }]
        };
      }

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/supertrained/rhumb'

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