list-payroll-employee-leave
Retrieve leave records for a specific Xero employee, showing approved, pending, and processed time off to track attendance and manage workforce planning.
Instructions
List all leave records for a specific employee in Xero. This shows all leave transactions including approved, pending, and processed time off. Provide an employee ID to see their leave history.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| employeeId | Yes | The Xero employee ID to fetch leave records for |
Implementation Reference
- Core handler that performs the Xero API call to retrieve employee leave records using payrollNZApi.getEmployeeLeaves, handles authentication, errors, and returns structured response.export async function listXeroPayrollEmployeeLeave( employeeId: string, ): Promise<XeroClientResponse<EmployeeLeave[]>> { try { const leave = await fetchEmployeeLeave({ employeeId }); if (!leave) { return { result: [], isError: false, error: null, }; } return { result: leave, isError: false, error: null, }; } catch (error) { return { result: null, isError: true, error: formatError(error), }; } }
- MCP tool implementation defining the tool name, description, input schema with Zod, and handler logic that calls core handler and formats response as text blocks for MCP.const ListPayrollEmployeeLeaveTool = CreateXeroTool( "list-payroll-employee-leave", "List all leave records for a specific employee in Xero. This shows all leave transactions including approved, pending, and processed time off. Provide an employee ID to see their leave history.", { employeeId: z.string().describe("The Xero employee ID to fetch leave records for"), }, async ({ employeeId }) => { const response = await listXeroPayrollEmployeeLeave(employeeId); if (response.isError) { return { content: [ { type: "text" as const, text: `Error listing employee leave: ${response.error}`, }, ], }; } const leave = response.result; return { content: [ { type: "text" as const, text: `Found ${leave?.length || 0} leave records for employee ${employeeId}:`, }, ...(leave?.map((leaveItem: EmployeeLeave) => ({ type: "text" as const, text: [ `Leave ID: ${leaveItem.leaveID || "Unknown"}`, `Leave Type: ${leaveItem.leaveTypeID || "Unknown"}`, `Description: ${leaveItem.description || "No description"}`, leaveItem.startDate ? `Start Date: ${leaveItem.startDate}` : null, leaveItem.endDate ? `End Date: ${leaveItem.endDate}` : null, leaveItem.periods ? `Periods: ${leaveItem.periods.length || 0}` : null, leaveItem.updatedDateUTC ? `Last Updated: ${leaveItem.updatedDateUTC}` : null, ] .filter(Boolean) .join("\n"), })) || []), ], }; }, );
- Zod input schema validating the employeeId parameter.employeeId: z.string().describe("The Xero employee ID to fetch leave records for"), },
- src/tools/list/index.ts:32-58 (registration)Registers the list-payroll-employee-leave tool (ListPayrollEmployeeLeaveTool) in the exported ListTools array for use in the MCP server.export const ListTools = [ ListAccountsTool, ListContactsTool, ListCreditNotesTool, ListInvoicesTool, ListItemsTool, ListManualJournalsTool, ListQuotesTool, ListTaxRatesTool, ListTrialBalanceTool, ListPaymentsTool, ListProfitAndLossTool, ListBankTransactionsTool, ListPayrollEmployeesTool, ListReportBalanceSheetTool, ListOrganisationDetailsTool, ListPayrollEmployeeLeaveTool, ListPayrollLeavePeriodsToolTool, ListPayrollEmployeeLeaveTypesTool, ListPayrollEmployeeLeaveBalancesTool, ListPayrollLeaveTypesTool, ListAgedReceivablesByContact, ListAgedPayablesByContact, ListPayrollTimesheetsTool, ListContactGroupsTool, ListTrackingCategoriesTool ];