get_appointment_invoices
Retrieve invoices linked to a specific appointment using its ID. Access billing details from the Cliniko system for a given appointment.
Instructions
Get invoices for a specific appointment (READ-ONLY)
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| appointment_id | Yes | Appointment ID |
Implementation Reference
- src/tools/invoices.ts:102-136 (registration)Registration of the 'get_appointment_invoices' tool using server.tool(), with input schema requiring 'appointment_id' and handler that calls client.getAppointmentInvoices.
server.tool('get_appointment_invoices', { description: 'Get invoices for a specific appointment (READ-ONLY)', inputSchema: { type: 'object', properties: { appointment_id: { type: 'number', description: 'Appointment ID' } }, required: ['appointment_id'] }, }, async ({ appointment_id }: { appointment_id: number }) => { try { const result = await client.getAppointmentInvoices(appointment_id); const invoices = result.invoices || []; return { content: [{ type: 'text', text: invoices.length > 0 ? `Found ${invoices.length} invoice(s) for appointment ${appointment_id}:\n\n` + invoices.map((inv: any) => `- Invoice #${inv.invoice_number || inv.id}: ${inv.status} ($${inv.total || 0})` ).join('\n') : `No invoices found for appointment ${appointment_id}. Invoices must be created manually in Cliniko.` }], data: result }; } catch (error) { return { content: [{ type: 'text', text: `Error fetching appointment invoices: ${error instanceof Error ? error.message : String(error)}` }] }; } }); - src/tools/invoices.ts:111-136 (handler)The handler function for get_appointment_invoices. Calls client.getAppointmentInvoices(appointment_id), formats the invoices into a text response showing invoice number, status, and total, or a message if none found.
}, async ({ appointment_id }: { appointment_id: number }) => { try { const result = await client.getAppointmentInvoices(appointment_id); const invoices = result.invoices || []; return { content: [{ type: 'text', text: invoices.length > 0 ? `Found ${invoices.length} invoice(s) for appointment ${appointment_id}:\n\n` + invoices.map((inv: any) => `- Invoice #${inv.invoice_number || inv.id}: ${inv.status} ($${inv.total || 0})` ).join('\n') : `No invoices found for appointment ${appointment_id}. Invoices must be created manually in Cliniko.` }], data: result }; } catch (error) { return { content: [{ type: 'text', text: `Error fetching appointment invoices: ${error instanceof Error ? error.message : String(error)}` }] }; } }); - src/tools/invoices.ts:103-110 (schema)Input schema for get_appointment_invoices: expects a required 'appointment_id' (type: number).
description: 'Get invoices for a specific appointment (READ-ONLY)', inputSchema: { type: 'object', properties: { appointment_id: { type: 'number', description: 'Appointment ID' } }, required: ['appointment_id'] }, - src/cliniko-client.ts:229-231 (helper)The getAppointmentInvoices method on ClinikoClient, which makes a GET request to /appointments/{appointmentId}/invoices and returns a ClinikoListResponse<Invoice>.
async getAppointmentInvoices(appointmentId: number): Promise<ClinikoListResponse<Invoice>> { return this.request<ClinikoListResponse<Invoice>>(`/appointments/${appointmentId}/invoices`); }