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
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | Number of entries (default 20, max 100) | |
| event_type | No | Filter: 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, }; } } - packages/mcp/src/types.ts:561-585 (schema)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; }; - packages/mcp/src/server.ts:322-335 (registration)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) }] }; }