Skip to main content
Glama
XeroAPI

Xero MCP Server

Official

list-contact-groups

Retrieve contact groups from Xero to organize and manage business relationships. Optionally specify a group ID to view its contacts and details.

Instructions

List all contact groups in Xero. You can optionally specify a contact group ID to retrieve details for that specific group, including its contacts.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
contactGroupIdNoOptional ID of the contact group to retrieve

Implementation Reference

  • The handler function for the 'list-contact-groups' tool. It calls the Xero helper, handles errors, and formats the contact groups data into readable text blocks.
    async (args) => {
      const response = await listXeroContactGroups(args?.contactGroupId);
      
      if (response.error !== null) {
        return {
          content: [
            {
              type: "text" as const,
              text: `Error listing contact groups: ${response.error}`,
            },
          ],
        };
      }
    
      const contactGroups = response.result;
    
      return {
        content: [
          {
            type: "text" as const,
            text: `Found ${contactGroups?.length || 0} contact groups:`,
          },
          ...(contactGroups?.map((contactGroup) => ({
            type: "text" as const,
            text: [
              `Contact Group ID: ${contactGroup.contactGroupID}`,
              `Name: ${contactGroup.name}`,
              `Status: ${contactGroup.status}`,
              contactGroup.contacts
                ? contactGroup.contacts.map(contact => [
                    `Contact ID: ${contact.contactID}`,
                    `Name: ${contact.name}`,
                  ].join('\n')
                ).join('\n')
                : "No contacts in this contact group.",            
            ]
              .filter(Boolean)
              .join("\n"),
          })) || []),
        ],
      };
    },
  • Input schema using Zod for the tool, defining optional contactGroupId parameter.
      contactGroupId: z
        .string()
        .optional()
        .describe("Optional ID of the contact group to retrieve"),    
    },
  • Registers all tools from ListTools (including 'list-contact-groups') with the MCP server using server.tool().
    ListTools.map((tool) => tool()).forEach((tool) =>
      server.tool(tool.name, tool.description, tool.schema, tool.handler),
    );
  • Imports the ListContactGroupsTool for inclusion in ListTools.
    import ListContactGroupsTool from "./list-contact-groups.tool.js";
  • Helper function that authenticates with Xero and retrieves contact groups (all or by ID), returning structured response or error.
    export async function listXeroContactGroups(contactGroupId?: string): Promise<
      XeroClientResponse<ContactGroup[]>
    > {
      try {
        const contactGroups = await getContactGroups(contactGroupId);
    
        return {
          result: contactGroups,
          isError: false,
          error: null,
        };
      } catch (error) {
        return {
          result: null,
          isError: true,
          error: formatError(error),
        };
      }
    }
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. It mentions that listing all groups is the default behavior and that specifying an ID retrieves details for a specific group, but it lacks critical behavioral details such as pagination, rate limits, authentication requirements, error handling, or what 'details' include beyond contacts. This is inadequate for a tool with potential complexity.

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: the first states the primary function, and the second explains the optional parameter. It's front-loaded with the main purpose and avoids unnecessary words, though it could be slightly more structured by separating use cases more clearly.

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 no annotations, no output schema, and a single parameter with high schema coverage, the description is incomplete. It fails to address behavioral aspects like response format, pagination, or error cases, and doesn't leverage context from sibling tools. For a list operation in a complex system like Xero, more guidance is needed to ensure proper usage.

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%, with the parameter 'contactGroupId' documented as 'Optional ID of the contact group to retrieve'. The description adds minimal value by reiterating the optionality and hinting at additional details like contacts, but it doesn't provide extra semantics beyond the schema, such as ID format or retrieval specifics. Baseline 3 is appropriate given high schema 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 tool's purpose: 'List all contact groups in Xero' specifies the verb ('List') and resource ('contact groups'), and it distinguishes this from other list operations by focusing on contact groups. However, it doesn't explicitly differentiate from sibling tools like 'list-contacts' beyond the resource type, missing a direct comparison.

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

Usage Guidelines3/5

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

The description implies usage by mentioning the optional parameter for retrieving a specific group, but it doesn't provide explicit guidance on when to use this tool versus alternatives like 'list-contacts' or other list tools. There's no mention of prerequisites, exclusions, or comparative contexts with siblings.

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