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
    ];
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden but only states the basic action without disclosing behavioral traits. It doesn't mention whether this is a read-only operation, authentication needs, rate limits, or what the output looks like (e.g., format, pagination), which is inadequate for a tool with multiple parameters.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence with zero wasted words. It's appropriately sized and front-loaded, clearly stating the tool's purpose without unnecessary elaboration.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity of a report tool with 7 parameters, no annotations, and no output schema, the description is incomplete. It lacks behavioral context, usage guidelines, and details on output format, leaving significant gaps for the agent to understand how to effectively use this tool.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema description coverage is 100%, so the schema fully documents all 7 parameters. The description adds no additional meaning beyond implying a report is generated, meeting the baseline of 3 where the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('List') and resource ('Balance Sheet report from Xero'), making the purpose unambiguous. However, it doesn't differentiate from sibling tools like 'list-profit-and-loss' or 'list-trial-balance' beyond naming the specific report type, missing explicit sibling distinction.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool versus alternatives. The description lacks context about prerequisites, timing, or comparisons to other report tools (e.g., 'list-profit-and-loss'), leaving the agent without usage direction.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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