list_bill_runs
List bill runs with optional filters for status, related data, sorting, and pagination. Manage billing operations efficiently.
Instructions
List bill runs. GET /bill-run. Optional: include (e.g. invoice), query (filter by status: completed, pending, error), orderBy, sortBy, itemPerPage, pageNo.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| include | No | Include related data (e.g. invoice) | |
| query | No | Filter by status: completed, pending, or error | |
| orderBy | No | Sort column | |
| sortBy | No | Sort direction | |
| itemPerPage | No | Items per page | |
| pageNo | No | Page number |
Implementation Reference
- The handler function that executes the list_bill_runs tool logic. It parses args with Zod, then calls billRunService.listBillRuns(client, parsed.data).
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("; ")); } return handleToolCall(() => billRunService.listBillRuns(client, parsed.data)); } export const listBillRunsTool: Tool = { definition, handler, }; - Zod schema for input validation of list_bill_runs (include, query, orderBy, sortBy, itemPerPage, pageNo).
const schema = z.object({ include: z.string().optional(), query: z.enum(statusEnum).optional(), orderBy: z.string().optional(), sortBy: z.string().optional(), itemPerPage: z.number().int().min(1).optional(), pageNo: z.number().int().min(1).optional(), }); - src/tools/bill_runs/listBillRuns.ts:18-47 (registration)Tool definition registration with name 'list_bill_runs', description, and inputSchema for MCP.
const definition = { name: "list_bill_runs", description: "List bill runs. GET /bill-run. Optional: include (e.g. invoice), query (filter by status: completed, pending, error), orderBy, sortBy, itemPerPage, pageNo.", inputSchema: { type: "object" as const, properties: { include: { type: "string", description: "Include related data (e.g. invoice)" }, query: { type: "string", description: "Filter by status: completed, pending, or error", }, orderBy: { type: "string", description: "Sort column" }, sortBy: { type: "string", description: "Sort direction" }, itemPerPage: { type: "number", description: "Items per page" }, pageNo: { type: "number", description: "Page number" }, }, required: [], }, }; 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("; ")); } return handleToolCall(() => billRunService.listBillRuns(client, parsed.data)); } export const listBillRunsTool: Tool = { - src/tools/index.ts:54-57 (registration)Central tool registry that includes registerBillRunTools() which registers listBillRunsTool.
const tool = tools.find((t) => t.definition.name === name); if (!tool) return undefined; return tool.handler(client, args); } - The actual API call to GET /bill-run with query params (include, query, orderBy, sortBy, itemPerPage, pageNo).
/** GET /bill-run */ export async function listBillRuns( client: Client, params?: ListBillRunsParams ): Promise<PaginatedResponse<unknown>> { const search = new URLSearchParams(); if (params?.include) search.append("include", params.include); if (params?.query) search.append("query", params.query); if (params?.orderBy) search.append("orderBy", params.orderBy); if (params?.sortBy) search.append("sortBy", params.sortBy); if (params?.itemPerPage != null) search.append("itemPerPage", String(params.itemPerPage)); if (params?.pageNo != null) search.append("pageNo", String(params.pageNo)); const q = search.toString(); return client.get<PaginatedResponse<unknown>>(`/bill-run${q ? `?${q}` : ""}`); }