get_customer_unpaid_invoices
Retrieve unpaid invoices for a customer. Supports pagination to handle large numbers of invoices.
Instructions
List unpaid invoices for a customer. GET /customers/{customerId}/invoices/unpaid. Supports pagination (pageNo, itemPerPage).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| customerId | Yes | Customer ID (required) | |
| pageNo | No | Page number (default: 1) | |
| itemPerPage | No | Items per page (default: 25) |
Implementation Reference
- The handler function that validates args via Zod schema, extracts customerId/pageNo/itemPerPage, and delegates to customerService.getCustomerUnpaidInvoices.
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, pageNo, itemPerPage } = parsed.data; return handleToolCall(() => customerService.getCustomerUnpaidInvoices(client, customerId, { pageNo, itemPerPage, }) ); } - Zod schema defining input validation: customerId (required string), pageNo (optional number), itemPerPage (optional number).
const schema = z.object({ customerId: z.string().min(1, "customerId is required"), pageNo: z.number().optional(), itemPerPage: z.number().optional(), }); - MCP definition with name 'get_customer_unpaid_invoices', description, and inputSchema (JSON Schema format) for the tool.
const definition = { name: "get_customer_unpaid_invoices", description: "List unpaid invoices for a customer. GET /customers/{customerId}/invoices/unpaid. Supports pagination (pageNo, itemPerPage).", inputSchema: { type: "object" as const, properties: { customerId: { type: "string", description: "Customer ID (required)" }, pageNo: { type: "number", description: "Page number (default: 1)" }, itemPerPage: { type: "number", description: "Items per page (default: 25)" }, }, required: ["customerId"], }, }; - src/tools/customers/index.ts:39-39 (registration)Tool registered in the customer tools array (registerCustomerTools) at index position.
getCustomerUnpaidInvoicesTool, - The service function that makes the actual HTTP GET request to /customers/{customerId}/invoices/unpaid with optional pagination params.
export async function getCustomerUnpaidInvoices( client: Client, customerId: string, params?: Pick<PaginationIncludeParams, "pageNo" | "itemPerPage"> ): Promise<PaginatedResponse<Invoice>> { const search = new URLSearchParams(); if (params?.pageNo != null) search.append("pageNo", String(params.pageNo)); if (params?.itemPerPage != null) search.append("itemPerPage", String(params.itemPerPage)); return client.get<PaginatedResponse<Invoice>>( `/customers/${customerId}/invoices/unpaid${queryString(search)}` ); }