Skip to main content
Glama
XeroAPI

Xero MCP Server

Official

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
NameRequiredDescriptionDefault
employeeIdYesThe 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"), },
  • 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 ];

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/XeroAPI/xero-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server