Skip to main content
Glama
XeroAPI

Xero MCP Server

Official

list-payments

Retrieve and filter payment records from Xero accounting software by invoice number, ID, payment ID, or reference to track financial transactions and payment history.

Instructions

List payments in Xero. This tool shows all payments made against invoices, including payment date, amount, and payment method. You can filter payments by invoice number, invoice ID, payment ID, or invoice reference. Ask the user if they want to see payments for a specific invoice, contact, payment or reference before running. If many payments are returned, ask the user if they want to see the next page.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pageNo
invoiceNumberNo
invoiceIdNo
paymentIdNo
referenceNo

Implementation Reference

  • The main handler function for the 'list-payments' tool. It calls the listXeroPayments helper, handles errors, and formats the payments into readable text blocks.
    async ({ page, invoiceNumber, invoiceId, paymentId, reference }) => {
      const response = await listXeroPayments(page, {
        invoiceNumber,
        invoiceId,
        paymentId,
        reference,
      });
    
      if (response.error !== null) {
        return {
          content: [
            {
              type: "text" as const,
              text: `Error listing payments: ${response.error}`,
            },
          ],
        };
      }
    
      const payments = response.result;
    
      return {
        content: [
          {
            type: "text" as const,
            text: `Found ${payments?.length || 0} payments:`,
          },
          ...(payments?.map((payment) => ({
            type: "text" as const,
            text: paymentFormatter(payment),
          })) || []),
        ],
      };
    },
  • Zod schema defining the input parameters for the list-payments tool: page, invoiceNumber, invoiceId, paymentId, reference.
      page: z.number().default(1),
      invoiceNumber: z.string().optional(),
      invoiceId: z.string().optional(),
      paymentId: z.string().optional(),
      reference: z.string().optional(),
    },
  • Registration of the list-payments tool (as part of ListTools) by calling server.tool with its name, description, schema, and handler.
    ListTools.map((tool) => tool()).forEach((tool) =>
      server.tool(tool.name, tool.description, tool.schema, tool.handler),
    );
  • Core helper function that queries the Xero API for payments based on filters and returns structured response or error.
    export async function listXeroPayments(
      page: number = 1,
      {
        invoiceNumber,
        invoiceId,
        paymentId,
        reference,
      }: {
        invoiceNumber?: string;
        invoiceId?: string;
        paymentId?: string;
        reference?: string;
      },
    ): Promise<XeroClientResponse<Payment[]>> {
      try {
        const payments = await getPayments(page, {
          invoiceNumber,
          invoiceId,
          paymentId,
          reference,
        });
    
        return {
          result: payments,
          isError: false,
          error: null,
        };
      } catch (error) {
        return {
          result: null,
          isError: true,
          error: formatError(error),
        };
      }
    }
  • Helper function to format a single payment object into a human-readable string.
    function paymentFormatter(payment: Payment): string {
      return [
        `Payment ID: ${payment.paymentID || "Unknown"}`,
        `Date: ${payment.date || "Unknown date"}`,
        `Amount: ${payment.amount || 0}`,
        payment.reference ? `Reference: ${payment.reference}` : null,
        payment.status ? `Status: ${payment.status}` : null,
        payment.paymentType ? `Payment Type: ${payment.paymentType}` : null,
        payment.updatedDateUTC ? `Last Updated: ${payment.updatedDateUTC}` : null,
        payment.account?.name
          ? `Account: ${payment.account.name} (${payment.account.accountID || "Unknown ID"})`
          : null,
        payment.invoice
          ? [
              `Invoice:`,
              `  Invoice Number: ${payment.invoice.invoiceNumber || "Unknown"}`,
              `  Invoice ID: ${payment.invoice.invoiceID || "Unknown"}`,
              payment.invoice.contact
                ? `  Contact: ${payment.invoice.contact.name || "Unknown"} (${payment.invoice.contact.contactID || "Unknown ID"})`
                : null,
              payment.invoice.type ? `  Type: ${payment.invoice.type}` : null,
              payment.invoice.total !== undefined
                ? `  Total: ${payment.invoice.total}`
                : null,
              payment.invoice.amountDue !== undefined
                ? `  Amount Due: ${payment.invoice.amountDue}`
                : null,
            ]
              .filter(Boolean)
              .join("\n")
          : null,
      ]
        .filter(Boolean)
        .join("\n");
    }
Behavior3/5

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

With no annotations provided, the description carries the full burden. It discloses pagination behavior ('If many payments are returned, ask the user if they want to see the next page'), which is valuable. However, it doesn't mention authentication requirements, rate limits, error conditions, or what happens when no payments match filters.

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 appropriately sized with 4 sentences that each add value. It's front-loaded with the core purpose, followed by details about what's shown, filtering options, and behavioral guidance. No wasted words, though the pagination guidance could be slightly more concise.

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?

For a 5-parameter tool with no annotations and no output schema, the description provides good purpose and parameter guidance but lacks details about authentication, error handling, response format, and the 'page' parameter's semantics. It's adequate but has clear gaps given the tool's complexity.

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

Parameters4/5

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

With 0% schema description coverage for 5 parameters, the description compensates well by explaining the filtering options ('filter payments by invoice number, invoice ID, payment ID, or invoice reference'). It maps clearly to 4 of the 5 parameters, though it doesn't mention the 'page' parameter explicitly. This provides substantial value beyond the bare schema.

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 verb ('List') and resource ('payments in Xero'), specifies what payments are shown ('payments made against invoices'), and distinguishes from siblings by focusing on payments rather than invoices, contacts, or other entities. It provides specific details about included data fields.

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

Usage Guidelines4/5

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

The description provides clear context for when to use this tool ('List payments in Xero') and includes explicit guidance about asking users for filtering preferences before running. However, it doesn't explicitly state when NOT to use it or name specific alternative tools for different scenarios.

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