list-items
Retrieve item codes and descriptions from Xero to populate invoices accurately. Use this tool to access product or service details for billing purposes.
Instructions
Lists all items in Xero. Use this tool to get the item codes and descriptions to be used when creating invoices in Xero
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| page | Yes |
Implementation Reference
- src/tools/list/list-items.tool.ts:11-56 (handler)The execution handler for the 'list-items' MCP tool. It calls the listXeroItems helper, handles errors, and formats the items list into MCP text content blocks.async ({ page }) => { const response = await listXeroItems(page); if (response.isError) { return { content: [ { type: "text" as const, text: `Error listing items: ${response.error}`, }, ], }; } const items = response.result; return { content: [ { type: "text" as const, text: `Found ${items?.length || 0} items:`, }, ...(items?.map((item) => ({ type: "text" as const, text: [ `Item: ${item.name || "Unnamed"}`, `ID: ${item.itemID}`, `Code: ${item.code}`, item.description ? `Description: ${item.description}` : null, item.purchaseDescription ? `Purchase Description: ${item.purchaseDescription}` : null, item.salesDetails?.unitPrice !== undefined ? `Sales Price: ${item.salesDetails.unitPrice}` : null, item.purchaseDetails?.unitPrice !== undefined ? `Purchase Price: ${item.purchaseDetails.unitPrice}` : null, item.salesDetails?.accountCode ? `Sales Account: ${item.salesDetails.accountCode}` : null, item.purchaseDetails?.accountCode ? `Purchase Account: ${item.purchaseDetails.accountCode}` : null, item.isTrackedAsInventory !== undefined ? `Tracked as Inventory: ${item.isTrackedAsInventory ? 'Yes' : 'No'}` : null, item.isSold !== undefined ? `Is Sold: ${item.isSold ? 'Yes' : 'No'}` : null, item.isPurchased !== undefined ? `Is Purchased: ${item.isPurchased ? 'Yes' : 'No'}` : null, item.updatedDateUTC ? `Last Updated: ${item.updatedDateUTC}` : null, item.validationErrors?.length ? `Validation Errors: ${item.validationErrors.map(e => e.message).join(", ")}` : null, ] .filter(Boolean) .join("\n"), })) || []), ], }; },
- Input schema for the 'list-items' tool: optional page number (defaults to 1).{ page: z.number(), },
- src/tools/tool-factory.ts:20-22 (registration)Top-level registration of the 'list-items' tool (as part of ListTools) on the MCP server using server.tool().ListTools.map((tool) => tool()).forEach((tool) => server.tool(tool.name, tool.description, tool.schema, tool.handler), );
- src/tools/list/index.ts:37-37 (registration)Includes ListItemsTool in the ListTools array exported for registration.ListItemsTool,
- Core helper function that fetches items from Xero API using xeroClient.accountingApi.getItems and wraps in standard response format.export async function listXeroItems( page: number = 1, ): Promise<XeroClientResponse<Item[]>> { try { const items = await getItems(page); return { result: items, isError: false, error: null, }; } catch (error) { return { result: null, isError: true, error: formatError(error), }; } }