Skip to main content
Glama
XeroAPI

Xero MCP Server

Official

list-payroll-employee-leave-types

Retrieve all available leave types for a specific Xero employee, including accrual schedules, names, and entitlement details.

Instructions

List all leave types available for a specific employee in Xero. This shows detailed information about the types of leave an employee can take, including schedule of accrual, leave type name, and entitlement.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
employeeIdYesThe Xero employee ID to fetch leave types for

Implementation Reference

  • The execute function of the MCP tool 'list-payroll-employee-leave-types', which fetches data from the Xero helper and formats the leave types into a structured text response for the MCP protocol.
    async ({ employeeId }) => { const response = await listXeroPayrollEmployeeLeaveTypes(employeeId); if (response.isError) { return { content: [ { type: "text" as const, text: `Error listing employee leave types: ${response.error}`, }, ], }; } const leaveTypes = response.result; return { content: [ { type: "text" as const, text: `Found ${leaveTypes?.length || 0} leave types for employee ${employeeId}:`, }, ...(leaveTypes?.map((leaveType: EmployeeLeaveType) => ({ type: "text" as const, text: [ `Leave Type ID: ${leaveType.leaveTypeID || "Unknown"}`, `Schedule of Accrual: ${leaveType.scheduleOfAccrual || "Unknown"}`, leaveType.hoursAccruedAnnually ? `Hours Accrued Annually: ${leaveType.hoursAccruedAnnually}` : null, leaveType.maximumToAccrue ? `Maximum To Accrue: ${leaveType.maximumToAccrue}` : null, leaveType.openingBalance ? `Opening Balance: ${leaveType.openingBalance}` : null, leaveType.rateAccruedHourly ? `Rate Accrued Hourly: ${leaveType.rateAccruedHourly}` : null, leaveType.leaveTypeID ? `Leave Type ID: ${leaveType.leaveTypeID}` : null, leaveType.scheduleOfAccrualDate ? `Accrual Date: ${leaveType.scheduleOfAccrualDate}` : null, ] .filter(Boolean) .join("\n"), })) || []), ], }; },
  • Zod input schema defining the required 'employeeId' parameter for the tool.
    { employeeId: z .string() .describe("The Xero employee ID to fetch leave types for"), },
  • Inclusion of the tool in the ListTools export array, which collects all list-related tools for registration.
    ListPayrollEmployeeLeaveTypesTool,
  • Batch registration of all tools from ListTools (including this one) into the MCP server using server.tool().
    ListTools.map((tool) => tool()).forEach((tool) => server.tool(tool.name, tool.description, tool.schema, tool.handler), );
  • Core helper function that handles the Xero API call to retrieve employee leave types and returns a standardized response.
    export async function listXeroPayrollEmployeeLeaveTypes( employeeId: string, ): Promise<XeroClientResponse<EmployeeLeaveType[]>> { try { const leaveTypes = await fetchEmployeeLeaveTypes(employeeId); if (!leaveTypes) { return { result: [], isError: false, error: null, }; } return { result: leaveTypes, isError: false, error: null, }; } catch (error) { return { result: null, isError: true, error: formatError(error), }; } }

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