Skip to main content
Glama
XeroAPI

Xero MCP Server

Official

list-report-balance-sheet

Retrieve the Balance Sheet report from Xero to analyze financial position, assets, liabilities, and equity with customizable date ranges, periods, and tracking options.

Instructions

List the Balance Sheet report from Xero.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
dateNoOptional date in YYYY-MM-DD format
periodsNoOptional number of periods to compare
timeframeNoOptional timeframe for the report (MONTH, QUARTER, YEAR)
trackingOptionID1NoOptional tracking option ID 1
trackingOptionID2NoOptional tracking option ID 2
standardLayoutNoOptional flag to use standard layout
paymentsOnlyNoOptional flag to include only accounts with payments

Implementation Reference

  • Main handler function listXeroReportBalanceSheet that orchestrates fetching the balance sheet report from Xero, handling errors, and returning structured response.
    export async function listXeroReportBalanceSheet(params: ListReportBalanceSheetParams): Promise<XeroClientResponse<ReportWithRow>> { try { const balanceSheet = await getReportBalanceSheet(params); if (!balanceSheet) { return { result: null, isError: true, error: "Failed to fetch balance sheet data from Xero.", }; } return { result: balanceSheet, isError: false, error: null, }; } catch (error) { return { result: null, isError: true, error: formatError(error), }; } };
  • Helper function within the handler file that performs the actual Xero API call to retrieve the balance sheet report.
    async function getReportBalanceSheet(params: ListReportBalanceSheetParams): Promise<ReportWithRow | null> { const { date, periods, timeframe, trackingOptionID1, trackingOptionID2, standardLayout, paymentsOnly, } = params; await xeroClient.authenticate(); const response = await xeroClient.accountingApi.getReportBalanceSheet( xeroClient.tenantId, date || undefined, periods || undefined, timeframe || undefined, trackingOptionID1 || undefined, trackingOptionID2 || undefined, standardLayout ?? undefined, paymentsOnly ?? undefined, getClientHeaders(), ); return response.body.reports?.[0] ?? null; }
  • Creates and exports the tool named 'list-report-balance-sheet' using CreateXeroTool, including input schema (Zod), description, and execution logic that calls the handler and formats response.
    const ListReportBalanceSheetTool = CreateXeroTool( "list-report-balance-sheet", "List the Balance Sheet report from Xero.", { date: z.string().optional().describe("Optional date in YYYY-MM-DD format"), periods: z.number().optional().describe("Optional number of periods to compare"), timeframe: z.enum(["MONTH", "QUARTER", "YEAR"]).optional().describe("Optional timeframe for the report (MONTH, QUARTER, YEAR)"), trackingOptionID1: z.string().optional().describe("Optional tracking option ID 1"), trackingOptionID2: z.string().optional().describe("Optional tracking option ID 2"), standardLayout: z.boolean().optional().describe("Optional flag to use standard layout"), paymentsOnly: z.boolean().optional().describe("Optional flag to include only accounts with payments"), }, async (args: ListReportBalanceSheetParams) => { const response = await listXeroReportBalanceSheet(args); // Check if the response contains an error if (response.error !== null) { return { content: [ { type: "text" as const, text: `Error listing balance sheet report: ${response.error}`, }, ], }; } const balanceSheetReport = response.result; return { content: [ { type: "text" as const, text: `Balance sheet Report: ${balanceSheetReport?.reportName ?? "Unnamed"}`, }, { type: "text" as const, text: JSON.stringify(balanceSheetReport.rows, null, 2), }, ], }; } );
  • TypeScript interface defining the input parameters for the list-report-balance-sheet tool.
    export interface ListReportBalanceSheetParams { date?: string; periods?: number; timeframe?: timeframeType; trackingOptionID1?: string; trackingOptionID2?: string; standardLayout?: boolean; paymentsOnly?: boolean; }
  • Registers ListReportBalanceSheetTool in the ListTools array for inclusion in the tools list.
    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