Skip to main content
Glama
XeroAPI

Xero MCP Server

Official

list-payroll-employee-leave-balances

Retrieve current leave balances for a specific employee in Xero, showing available annual, sick, and other leave types to manage workforce attendance.

Instructions

List all leave balances for a specific employee in Xero. This shows current leave balances for all leave types available to the employee, including annual, sick, and other leave types.

Input Schema

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

Implementation Reference

  • MCP tool handler function that processes input, calls the Xero API handler, and formats the leave balances into readable text content blocks for the MCP response.
    async ({ employeeId }) => { const response = await listXeroPayrollEmployeeLeaveBalances(employeeId); if (response.isError) { return { content: [ { type: "text" as const, text: `Error listing employee leave balances: ${response.error}`, }, ], }; } const leaveBalances = response.result; return { content: [ { type: "text" as const, text: `Found ${leaveBalances?.length || 0} leave balances for employee ${employeeId}:`, }, ...(leaveBalances?.map((balance: EmployeeLeaveBalance) => ({ type: "text" as const, text: [ `Leave Type ID: ${balance.leaveTypeID || "Unknown"}`, `Name: ${balance.name || "Unnamed"}`, balance.typeOfUnits ? `Type Of Units: ${balance.typeOfUnits}` : null, balance.balance !== undefined ? `Current Balance: ${balance.balance}` : null, ] .filter(Boolean) .join("\n"), })) || []), ], }; },
  • Zod validation schema defining the input parameter 'employeeId' for the tool.
    { employeeId: z.string().describe("The Xero employee ID to fetch leave balances for"), },
  • Specific registration of the tool by including it in the ListTools export array used for MCP server registration.
    ListPayrollEmployeeLeaveBalancesTool,
  • Core helper function that handles the API call to Xero for retrieving employee leave balances and error handling.
    export async function listXeroPayrollEmployeeLeaveBalances( employeeId: string, ): Promise<XeroClientResponse<EmployeeLeaveBalance[]>> { try { const leaveBalances = await fetchEmployeeLeaveBalances(employeeId); if (!leaveBalances) { return { result: [], isError: false, error: null, }; } return { result: leaveBalances, isError: false, error: null, }; } catch (error) { return { result: null, isError: true, error: formatError(error), }; } }
  • Batch registration of all ListTools (including list-payroll-employee-leave-balances) to the MCP server via server.tool() calls.
    ListTools.map((tool) => tool()).forEach((tool) => server.tool(tool.name, tool.description, tool.schema, tool.handler), );

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