get_invoice
Retrieve a specific invoice by its ID, with optional details like line items or transactions.
Instructions
Get an invoice by ID. GET /invoices/{invoiceId}. Optional: include.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| invoiceId | Yes | Invoice ID (required) | |
| include | No | Attributes to include (e.g. detail, transactions) |
Implementation Reference
- src/tools/invoices/getInvoice.ts:25-37 (handler)Handler function for get_invoice tool: validates args with Zod schema, then calls invoiceService.getInvoice(client, invoiceId, { include }) via handleToolCall wrapper.
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 { invoiceId, include } = parsed.data; return handleToolCall(() => invoiceService.getInvoice(client, invoiceId, { include })); } export const getInvoiceTool: Tool = { definition, handler, }; - Zod input schema for get_invoice: requires invoiceId (string), optional include (string).
const schema = z.object({ invoiceId: z.string().min(1, "invoiceId is required"), include: z.string().optional(), }); - Tool definition (name: 'get_invoice', description, inputSchema with properties invoiceId and include).
const definition = { name: "get_invoice", description: "Get an invoice by ID. GET /invoices/{invoiceId}. Optional: include.", inputSchema: { type: "object" as const, properties: { invoiceId: { type: "string", description: "Invoice ID (required)" }, include: { type: "string", description: "Attributes to include (e.g. detail, transactions)" }, }, required: ["invoiceId"], }, }; - Service-layer getInvoice function: builds URL with optional include param and calls client.get on /invoices/{invoiceId}.
export async function getInvoice( client: Client, invoiceId: string, params?: { include?: string } ): Promise<unknown> { const search = new URLSearchParams(); if (params?.include) search.append("include", params.include); const q = search.toString(); return client.get<unknown>(`/invoices/${invoiceId}${q ? `?${q}` : ""}`); } - src/tools/invoices/index.ts:16-27 (registration)Registration: getInvoiceTool is included in the array returned by registerInvoiceTools(), which is consumed by src/tools/index.ts to build the global tool registry.
export function registerInvoiceTools(): Tool[] { return [ listInvoicesTool, getInvoiceTool, createInvoiceTool, updateInvoiceTool, deleteInvoiceTool, chargeInvoiceTool, chargeInvoiceExternalTool, voidInvoiceTool, ]; }