list-quotes
Retrieve and manage quotes in Xero by listing all available quotes or filtering by specific contacts. This tool supports pagination for handling large datasets, enabling users to navigate through multiple pages of quotes efficiently.
Instructions
List all quotes in Xero. Ask the user if they want to see quotes for a specific contact before running. Ask the user if they want the next page of quotes after running this tool if 10 quotes are returned. If they do, call this tool again with the page number and the contact provided in the previous call.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| contactId | No | ||
| page | Yes |
Implementation Reference
- src/tools/list/list-quotes.tool.ts:16-74 (handler)The handler function for the 'list-quotes' tool. It calls listXeroQuotes and formats the quotes into a textual response with details.async ({ page, contactId, quoteNumber }) => { const response = await listXeroQuotes(page, contactId, quoteNumber); if (response.error !== null) { return { content: [ { type: "text" as const, text: `Error listing quotes: ${response.error}`, }, ], }; } const quotes = response.result; return { content: [ { type: "text" as const, text: `Found ${quotes?.length || 0} quotes:`, }, ...(quotes?.map((quote) => ({ type: "text" as const, text: [ `Quote ID: ${quote.quoteID}`, `Quote Number: ${quote.quoteNumber}`, quote.reference ? `Reference: ${quote.reference}` : null, `Status: ${quote.status || "Unknown"}`, quote.contact ? `Contact: ${quote.contact.name} (${quote.contact.contactID})` : null, quote.dateString ? `Quote Date: ${quote.dateString}` : null, quote.expiryDateString ? `Expiry Date: ${quote.expiryDateString}` : null, quote.title ? `Title: ${quote.title}` : null, quote.summary ? `Summary: ${quote.summary}` : null, quote.terms ? `Terms: ${quote.terms}` : null, quote.lineAmountTypes ? `Line Amount Types: ${quote.lineAmountTypes}` : null, quote.subTotal ? `Sub Total: ${quote.subTotal}` : null, quote.totalTax ? `Total Tax: ${quote.totalTax}` : null, `Total: ${quote.total || 0}`, quote.totalDiscount ? `Total Discount: ${quote.totalDiscount}` : null, quote.currencyCode ? `Currency: ${quote.currencyCode}` : null, quote.currencyRate ? `Currency Rate: ${quote.currencyRate}` : null, quote.updatedDateUTC ? `Last Updated: ${quote.updatedDateUTC}` : null, ] .filter(Boolean) .join("\n"), })) || []), ], }; },
- Input schema for the list-quotes tool using Zod validation.page: z.number(), contactId: z.string().optional(), quoteNumber: z.string().optional(), },
- src/tools/list/index.ts:25-39 (registration)Import and registration of ListQuotesTool in the ListTools array for tool registration.import ListQuotesTool from "./list-quotes.tool.js"; import ListReportBalanceSheetTool from "./list-report-balance-sheet.tool.js"; import ListTaxRatesTool from "./list-tax-rates.tool.js"; import ListTrackingCategoriesTool from "./list-tracking-categories.tool.js"; import ListTrialBalanceTool from "./list-trial-balance.tool.js"; import ListContactGroupsTool from "./list-contact-groups.tool.js"; export const ListTools = [ ListAccountsTool, ListContactsTool, ListCreditNotesTool, ListInvoicesTool, ListItemsTool, ListManualJournalsTool, ListQuotesTool,
- Core helper function listXeroQuotes that interacts with Xero API to fetch quotes.export async function listXeroQuotes( page: number = 1, contactId?: string, quoteNumber?: string, ): Promise<XeroClientResponse<Quote[]>> { try { const quotes = await getQuotes(contactId, page, quoteNumber); return { result: quotes, isError: false, error: null, }; } catch (error) { return { result: null, isError: true, error: formatError(error), }; } }
- Low-level helper getQuotes that calls the Xero accounting API.async function getQuotes( contactId: string | undefined, page: number, quoteNumber: string | undefined, ): Promise<Quote[]> { await xeroClient.authenticate(); const quotes = await xeroClient.accountingApi.getQuotes( xeroClient.tenantId, undefined, // ifModifiedSince undefined, // dateFrom undefined, // dateTo undefined, // expiryDateFrom undefined, // expiryDateTo contactId, // contactID undefined, // status page, undefined, // order quoteNumber, // quoteNumber getClientHeaders(), ); return quotes.body.quotes ?? []; }