Skip to main content
Glama
XeroAPI

Xero MCP Server

Official

list-trial-balance

Retrieve a snapshot of Xero's general ledger showing debit and credit balances for each account to verify accounting accuracy and prepare financial statements.

Instructions

Lists trial balance in Xero. This provides a snapshot of the general ledger, showing debit and credit balances for each account.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
dateNoOptional date in YYYY-MM-DD format
paymentsOnlyNoOptional flag to include only accounts with payments

Implementation Reference

  • Defines the MCP tool 'list-trial-balance' including Zod input schema, handler logic that calls core handler, and formats response as MCP content blocks.
    const ListTrialBalanceTool = CreateXeroTool(
      "list-trial-balance",
      "Lists trial balance in Xero. This provides a snapshot of the general ledger, showing debit and credit balances for each account.",
      {
        date: z.string().optional().describe("Optional date in YYYY-MM-DD format"),
        paymentsOnly: z.boolean().optional().describe("Optional flag to include only accounts with payments"),
      },
      async (args) => {
        const response = await listXeroTrialBalance(args?.date, args?.paymentsOnly);
        if (response.error !== null) {
          return {
            content: [
              {
                type: "text" as const,
                text: `Error listing trial balance: ${response.error}`,
              },
            ],
          };
        }
    
       const trialBalanceReport = response.result;
    
        return {
          content: [
            {
              type: "text" as const,
              text: `Trial Balance Report: ${trialBalanceReport?.reportName || "Unnamed"}`,
            },
            {
              type: "text" as const,
              text: `Date: ${trialBalanceReport?.reportDate || "Not specified"}`,
            },
            {
              type: "text" as const,
              text: `Updated At: ${trialBalanceReport?.updatedDateUTC ? trialBalanceReport.updatedDateUTC.toISOString() : "Unknown"}`,
            },
            {
              type: "text" as const,
              text: JSON.stringify(trialBalanceReport.rows, null, 2),
            },
          ],
        };
      },
    );
  • Core handler that fetches trial balance report from Xero API using xeroClient.accountingApi.getReportTrialBalance (via internal fetchTrialBalance).
    export async function listXeroTrialBalance(
      date?: string,
      paymentsOnly?: boolean,
    ): Promise<XeroClientResponse<ReportWithRow>> {
      try {
        const trialBalance = await fetchTrialBalance(date, paymentsOnly);
    
        if (!trialBalance) {
          return {
            result: null,
            isError: true,
            error: "Failed to fetch trial balance data from Xero.",
          };
        }
    
        return {
          result: trialBalance,
          isError: false,
          error: null,
        };
      } catch (error) {
        return {
          result: null,
          isError: true,
          error: formatError(error),
        };
      }
    } 
  • Registers the ListTrialBalanceTool in the ListTools array exported for higher-level registration.
    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
    ];
  • Final registration of all ListTools (including list-trial-balance) to the MCP server via server.tool() calls.
    ListTools.map((tool) => tool()).forEach((tool) =>
      server.tool(tool.name, tool.description, tool.schema, tool.handler),
    );
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It describes the output as a 'snapshot' but lacks critical details such as whether this is a read-only operation, if it requires authentication, any rate limits, pagination behavior, or error handling. For a tool with no annotation coverage, this leaves significant gaps in understanding its behavior.

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

Conciseness4/5

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

The description is concise with two sentences that are front-loaded with the core purpose. It avoids unnecessary words, but could be slightly improved by integrating usage context or behavioral details without sacrificing brevity.

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

Completeness3/5

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

Given no annotations and no output schema, the description is moderately complete for a simple listing tool with two optional parameters. It explains what the tool does but lacks details on output format, error cases, or operational constraints, which are important for full contextual understanding.

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?

Schema description coverage is 100%, so the schema fully documents the two parameters (date and paymentsOnly). The description does not add any meaning beyond what the schema provides, such as explaining the implications of the paymentsOnly flag or date formatting nuances. Baseline 3 is appropriate when the schema handles parameter documentation.

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

Purpose5/5

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

The description clearly states the action ('Lists trial balance') and resource ('in Xero'), with specific details about what it provides ('snapshot of the general ledger, showing debit and credit balances for each account'). It effectively distinguishes this tool from sibling tools like list-accounts or list-profit-and-loss by focusing on trial balance rather than other financial reports.

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?

The description provides no guidance on when to use this tool versus alternatives. It does not mention any prerequisites, exclusions, or specific contexts for usage, nor does it compare it to similar tools like list-accounts or list-profit-and-loss, leaving the agent without direction on selection.

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