Skip to main content
Glama
XeroAPI

Xero MCP Server

Official

list-credit-notes

Retrieve and manage credit notes from Xero accounting software, enabling users to view specific contact records or browse all entries with paginated results.

Instructions

List credit notes in Xero. Ask the user if they want to see credit notes for a specific contact, or to see all credit notes before running. Ask the user if they want the next page of credit notes after running this tool if 10 credit notes are returned. If they want the next page, call this tool again with the next page number and the contact if one was provided in the previous call.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pageYes
contactIdNo

Implementation Reference

  • Primary tool implementation: creates the 'list-credit-notes' tool with schema (page, optional contactId), description, and handler that calls listXeroCreditNotes, handles errors, and formats credit note details into text response.
    const ListCreditNotesTool = CreateXeroTool(
      "list-credit-notes",
      `List credit notes in Xero. 
      Ask the user if they want to see credit notes for a specific contact,
      or to see all credit notes before running. 
      Ask the user if they want the next page of credit notes after running this tool 
      if 10 credit notes are returned. 
      If they want the next page, call this tool again with the next page number 
      and the contact if one was provided in the previous call.`,
      {
        page: z.number(),
        contactId: z.string().optional(),
      },
      async ({ page, contactId }) => {
        const response = await listXeroCreditNotes(page, contactId);
        if (response.error !== null) {
          return {
            content: [
              {
                type: "text" as const,
                text: `Error listing credit notes: ${response.error}`,
              },
            ],
          };
        }
    
        const creditNotes = response.result;
    
        return {
          content: [
            {
              type: "text" as const,
              text: `Found ${creditNotes?.length || 0} credit notes:`,
            },
            ...(creditNotes?.map((creditNote) => ({
              type: "text" as const,
              text: [
                `Credit Note ID: ${creditNote.creditNoteID}`,
                `Credit Note Number: ${creditNote.creditNoteNumber}`,
                creditNote.reference ? `Reference: ${creditNote.reference}` : null,
                `Type: ${creditNote.type || "Unknown"}`,
                `Status: ${creditNote.status || "Unknown"}`,
                creditNote.contact
                  ? `Contact: ${creditNote.contact.name} (${creditNote.contact.contactID})`
                  : null,
                creditNote.date ? `Date: ${creditNote.date}` : null,
                creditNote.lineAmountTypes
                  ? `Line Amount Types: ${creditNote.lineAmountTypes}`
                  : null,
                creditNote.subTotal ? `Sub Total: ${creditNote.subTotal}` : null,
                creditNote.totalTax ? `Total Tax: ${creditNote.totalTax}` : null,
                `Total: ${creditNote.total || 0}`,
                creditNote.currencyCode
                  ? `Currency: ${creditNote.currencyCode}`
                  : null,
                creditNote.currencyRate
                  ? `Currency Rate: ${creditNote.currencyRate}`
                  : null,
                creditNote.updatedDateUTC
                  ? `Last Updated: ${creditNote.updatedDateUTC}`
                  : null,
              ]
                .filter(Boolean)
                .join("\n"),
            })) || []),
          ],
        };
      },
    );
  • Core handler function listXeroCreditNotes that authenticates with Xero, fetches credit notes using accountingApi.getCreditNotes with pagination and optional contact filter, handles errors.
    /**
     * List all credit notes from Xero
     */
    export async function listXeroCreditNotes(
      page: number = 1,
      contactId?: string,
    ): Promise<XeroClientResponse<CreditNote[]>> {
      try {
        const creditNotes = await getCreditNotes(contactId, page);
    
        return {
          result: creditNotes,
          isError: false,
          error: null,
        };
      } catch (error) {
        return {
          result: null,
          isError: true,
          error: formatError(error),
        };
      }
    }
  • Input schema for the tool: requires page number, optional contactId.
    {
      page: z.number(),
      contactId: z.string().optional(),
    },
  • Registers ListCreditNotesTool in the ListTools array for batch 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
    ];
  • Imports ListTools and registers all list tools (including list-credit-notes) to the MCP server using server.tool().
    import { ListTools } from "./list/index.js";
    import { UpdateTools } from "./update/index.js";
    
    export function ToolFactory(server: McpServer) {
    
      DeleteTools.map((tool) => tool()).forEach((tool) =>
        server.tool(tool.name, tool.description, tool.schema, tool.handler),
      );
      GetTools.map((tool) => tool()).forEach((tool) =>
        server.tool(tool.name, tool.description, tool.schema, tool.handler),
      );
      CreateTools.map((tool) => tool()).forEach((tool) =>
        server.tool(tool.name, tool.description, tool.schema, tool.handler),
      );
      ListTools.map((tool) => tool()).forEach((tool) =>
        server.tool(tool.name, tool.description, tool.schema, tool.handler),
      );
      UpdateTools.map((tool) => tool()).forEach((tool) =>
        server.tool(tool.name, tool.description, tool.schema, tool.handler),
      );
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 key behavioral traits: pagination behavior (10 items per page, requires re-calling with next page number), user interaction requirements (asking about contact filtering and pagination), and that contact filtering is optional. However, it doesn't cover aspects like rate limits, authentication needs, error handling, or what happens if no credit notes exist.

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

Conciseness3/5

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

The description is appropriately sized (4 sentences) but could be more front-loaded. The first sentence states the purpose clearly, but the subsequent sentences mix usage instructions with behavioral details. Some redundancy exists (e.g., mentioning asking about contact filtering twice). It earns its place but could be structured better.

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, 0% schema coverage, and no output schema, the description does a fair job. It covers purpose, usage, pagination behavior, and parameter semantics. However, it lacks details on return format, error conditions, authentication requirements, and doesn't fully compensate for the missing structured data. It's adequate but has clear gaps for a listing tool.

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?

Schema description coverage is 0%, so the description must compensate. It explains the semantics of both parameters: 'page' for pagination (with implied starting point and increment logic) and 'contactId' for filtering by contact. It clarifies that contactId is optional and should be persisted across pagination calls. This adds significant value beyond the bare schema.

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 credit notes in Xero.' It specifies the verb ('List') and resource ('credit notes'), but doesn't explicitly differentiate from sibling tools like 'list-invoices' or 'list-payments' beyond the resource type. The description is specific about what it does but lacks sibling comparison.

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

Usage Guidelines5/5

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

The description provides explicit guidance on when to use this tool: it instructs to ask the user about filtering by contact and pagination before/after running. It implies usage for listing credit notes with optional contact filtering and pagination, though it doesn't name specific alternatives among 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