cancel_appointment
Cancel an appointment in your healthcare practice by providing the appointment ID and optional reason for cancellation.
Instructions
Cancel an appointment
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| appointment_id | Yes | Appointment ID | |
| cancellation_reason | No | Reason for cancellation |
Implementation Reference
- src/tools/appointments.ts:149-172 (registration)Registration of the 'cancel_appointment' tool with MCP server. Defines input schema (appointment_id required, cancellation_reason optional) and the handler that calls client.cancelAppointment().
// Cancel appointment server.tool('cancel_appointment', { description: 'Cancel an appointment', inputSchema: { type: 'object', properties: { appointment_id: { type: 'number', description: 'Appointment ID' }, cancellation_reason: { type: 'string', description: 'Reason for cancellation' } }, required: ['appointment_id'] }, }, async ({ appointment_id, cancellation_reason }: { appointment_id: number; cancellation_reason?: string }) => { try { const appointment = await client.cancelAppointment(appointment_id, cancellation_reason); return { content: [{ type: 'text', text: JSON.stringify(appointment, null, 2) }] }; } catch (error) { throw new Error(`Failed to cancel appointment: ${error instanceof Error ? error.message : 'Unknown error'}`); } }); - src/tools/appointments.ts:160-171 (handler)The actual handler function for cancel_appointment. Receives appointment_id and optional cancellation_reason, calls the ClinikoClient cancelAppointment method, returns the cancelled appointment as JSON.
}, async ({ appointment_id, cancellation_reason }: { appointment_id: number; cancellation_reason?: string }) => { try { const appointment = await client.cancelAppointment(appointment_id, cancellation_reason); return { content: [{ type: 'text', text: JSON.stringify(appointment, null, 2) }] }; } catch (error) { throw new Error(`Failed to cancel appointment: ${error instanceof Error ? error.message : 'Unknown error'}`); } - src/tools/appointments.ts:152-159 (schema)Input schema (defined inline) for cancel_appointment. appointment_id (number, required) and cancellation_reason (string, optional).
inputSchema: { type: 'object', properties: { appointment_id: { type: 'number', description: 'Appointment ID' }, cancellation_reason: { type: 'string', description: 'Reason for cancellation' } }, required: ['appointment_id'] }, - src/cliniko-client.ts:135-140 (helper)ClinikoClient.cancelAppointment() method. Sends a PUT request to /appointments/{id}/cancel with an optional cancellation_reason in the request body. This is the API client helper that executes the actual HTTP request.
async cancelAppointment(id: number, reason?: string): Promise<Appointment> { return this.request<Appointment>(`/appointments/${id}/cancel`, { method: 'PUT', body: JSON.stringify({ cancellation_reason: reason }), }); } - src/index.ts:58-59 (registration)Top-level registration: registerAppointmentTools(toolRegistry, clinikoClient) is called in index.ts, which wires up all appointment tools including cancel_appointment.
registerPatientTools(toolRegistry, clinikoClient); registerAppointmentTools(toolRegistry, clinikoClient);