get_bill_run_invoices
Retrieve invoices associated with a specific bill run. Supports pagination to control the number of invoices returned per request.
Instructions
Get invoices for a bill run. GET /bill-run/{billRunId}/invoices. Returns paginated invoices. Optional: pageNo, itemPerPage.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| billRunId | Yes | Bill run ID (required) | |
| pageNo | No | Page number (default: 1) | |
| itemPerPage | No | Items per page (default: 25) |
Implementation Reference
- The main handler function for the get_bill_run_invoices tool. Parses args with Zod schema, calls the service to GET /bill-run/{billRunId}/invoices, and returns results via handleToolCall.
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 { billRunId, pageNo, itemPerPage } = parsed.data; return handleToolCall(() => billRunService.getBillRunInvoices(client, billRunId, { pageNo, itemPerPage }) ); } - Zod validation schema for the tool inputs: billRunId (required string), pageNo (optional int), itemPerPage (optional int).
const schema = z.object({ billRunId: z.string().min(1, "billRunId is required"), pageNo: z.number().int().min(1).optional(), itemPerPage: z.number().int().min(1).optional(), }); - src/tools/bill_runs/getBillRunInvoices.ts:13-26 (registration)Tool definition/registration: name 'get_bill_run_invoices', description, and inputSchema (JSON Schema format with required billRunId and optional pageNo/itemPerPage).
const definition = { name: "get_bill_run_invoices", description: "Get invoices for a bill run. GET /bill-run/{billRunId}/invoices. Returns paginated invoices. Optional: pageNo, itemPerPage.", inputSchema: { type: "object" as const, properties: { billRunId: { type: "string", description: "Bill run ID (required)" }, pageNo: { type: "number", description: "Page number (default: 1)" }, itemPerPage: { type: "number", description: "Items per page (default: 25)" }, }, required: ["billRunId"], }, }; - src/tools/bill_runs/index.ts:6-24 (registration)Import and registration of getBillRunInvoicesTool in the bill run tools collection, exported as part of registerBillRunTools().
import { getBillRunInvoicesTool } from "./getBillRunInvoices.js"; import { getBillRunTool } from "./getBillRun.js"; import { listBillRunsTool } from "./listBillRuns.js"; import { updateBillRunTool } from "./updateBillRun.js"; /** All 4 bill run tools. */ export function registerBillRunTools(): Tool[] { return [ listBillRunsTool, getBillRunTool, updateBillRunTool, getBillRunInvoicesTool, ]; } export { listBillRunsTool } from "./listBillRuns.js"; export { getBillRunTool } from "./getBillRun.js"; export { updateBillRunTool } from "./updateBillRun.js"; export { getBillRunInvoicesTool } from "./getBillRunInvoices.js"; - The underlying service function getBillRunInvoices that executes the GET /bill-run/{billRunId}/invoices HTTP request with optional pageNo and itemPerPage query parameters.
/** GET /bill-run/{billRunId}/invoices */ export async function getBillRunInvoices( client: Client, billRunId: string, params?: BillRunInvoicesParams ): Promise<unknown> { const search = new URLSearchParams(); 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<unknown>(`/bill-run/${billRunId}/invoices${q ? `?${q}` : ""}`); }