Skip to main content
Glama
XeroAPI

Xero MCP Server

Official

list-contacts

Retrieve and search through all contacts in Xero, including suppliers and customers, with pagination support for managing large contact lists.

Instructions

List all contacts in Xero. This includes Suppliers and Customers.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pageNoOptional page number to retrieve for pagination. If not provided, the first page will be returned. If 100 contacts are returned, call this tool again with the next page number.
searchTermNoSearch parameter that performs a case-insensitive text search across the Name, FirstName, LastName, ContactNumber and EmailAddress fields

Implementation Reference

  • Core handler function for listing Xero contacts, handling API call and error formatting.
    export async function listXeroContacts(page?: number, searchTerm?: string): Promise<
      XeroClientResponse<Contact[]>
    > {
      try {
        const contacts = await getContacts(page, searchTerm);
    
        return {
          result: contacts,
          isError: false,
          error: null,
        };
      } catch (error) {
        return {
          result: null,
          isError: true,
          error: formatError(error),
        };
      }
    }
  • Tool-specific execution handler that invokes the core listXeroContacts and formats the output for MCP response.
    async (params) => {
      const { page, searchTerm } = params;
      const response = await listXeroContacts(page, searchTerm);
    
      if (response.isError) {
        return {
          content: [
            {
              type: "text" as const,
              text: `Error listing contacts: ${response.error}`,
            },
          ],
        };
      }
    
      const contacts = response.result;
    
      return {
        content: [
          {
            type: "text" as const,
            text: `Found ${contacts?.length || 0} contacts${page ? ` (page ${page})` : ''}:`,
          },
          ...(contacts?.map((contact) => ({
            type: "text" as const,
            text: [
              `Contact: ${contact.name}`,
              `ID: ${contact.contactID}`,
              contact.firstName ? `First Name: ${contact.firstName}` : null,
              contact.lastName ? `Last Name: ${contact.lastName}` : null,
              contact.emailAddress
                ? `Email: ${contact.emailAddress}`
                : "No email",
              contact.accountsReceivableTaxType
                ? `AR Tax Type: ${contact.accountsReceivableTaxType}`
                : null,
              contact.accountsPayableTaxType
                ? `AP Tax Type: ${contact.accountsPayableTaxType}`
                : null,
              `Type: ${
                [
                  contact.isCustomer ? "Customer" : null,
                  contact.isSupplier ? "Supplier" : null,
                ]
                  .filter(Boolean)
                  .join(", ") || "Unknown"
              }`,
              contact.defaultCurrency
                ? `Default Currency: ${contact.defaultCurrency}`
                : null,
              contact.updatedDateUTC
                ? `Last Updated: ${contact.updatedDateUTC}`
                : null,
              `Status: ${contact.contactStatus || "Unknown"}`,
              contact.contactGroups?.length
                ? `Groups: ${contact.contactGroups.map((g) => g.name).join(", ")}`
                : null,
              contact.hasAttachments ? "Has Attachments: Yes" : null,
              contact.hasValidationErrors ? "Has Validation Errors: Yes" : null,
            ]
              .filter(Boolean)
              .join("\n"),
          })) || []),
        ],
      };
    },
  • Input schema validation using Zod for 'page' and 'searchTerm' parameters.
    {
      page: z.number().optional().describe("Optional page number to retrieve for pagination. \
        If not provided, the first page will be returned. If 100 contacts are returned, \
        call this tool again with the next page number."),
      searchTerm: z.string().optional().describe("Search parameter that performs a case-insensitive text search across the Name, FirstName, LastName, ContactNumber and EmailAddress fields"),
    },
  • Local registration of ListContactsTool within the array of list tools.
    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
    ];
  • Global registration of all ListTools, including list-contacts, to the MCP server.
    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?

With no annotations provided, the description carries full burden but only states what is listed, not behavioral traits like pagination behavior (implied by schema), rate limits, authentication needs, or what data is returned. It mentions inclusion of Suppliers and Customers but lacks details on format, sorting, or default behavior.

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 two concise sentences with zero waste, front-loading the core purpose and efficiently specifying scope. Every word earns its place without redundancy.

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?

For a list tool with no annotations and no output schema, the description is incomplete. It lacks information on return format, pagination details (beyond schema hints), error handling, or how results are structured, leaving significant gaps for an AI agent.

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 (page and searchTerm). The description adds no additional parameter semantics beyond what the schema provides, meeting the baseline for high coverage.

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 verb ('List') and resource ('all contacts in Xero'), specifying that it includes Suppliers and Customers. It distinguishes the scope but doesn't explicitly differentiate from sibling tools like 'list-contact-groups' or 'list-aged-payables-by-contact', which prevents a perfect score.

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 like 'list-contact-groups' or 'create-contact'. The description mentions inclusion of Suppliers and Customers but doesn't specify exclusions or prerequisites, leaving usage context implied at best.

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