list-tax-rates
Retrieve all tax rates from Xero for accurate invoice creation and financial management. Enables access to essential tax data through the Xero MCP Server.
Instructions
Lists all tax rates in Xero. Use this tool to get the tax rates to be used when creating invoices in Xero
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- MCP tool definition and handler logic for 'list-tax-rates'. It calls listXeroTaxRates() and formats the tax rates list into a detailed text response.const ListTaxRatesTool = CreateXeroTool( "list-tax-rates", "Lists all tax rates in Xero. Use this tool to get the tax rates to be used when creating invoices in Xero", {}, async () => { const response = await listXeroTaxRates(); if (response.error !== null) { return { content: [ { type: "text" as const, text: `Error listing tax rates: ${response.error}`, }, ], }; } const taxRates = response.result; return { content: [ { type: "text" as const, text: `Found ${taxRates?.length || 0} tax rates:`, }, ...(taxRates?.map((taxRate) => ({ type: "text" as const, text: [ `Tax Rate: ${taxRate.name || "Unnamed"}`, `Tax Type: ${taxRate.taxType || "No tax type"}`, `Status: ${taxRate.status || "Unknown status"}`, `Display Tax Rate: ${taxRate.displayTaxRate || "0.0000"}%`, `Effective Rate: ${taxRate.effectiveRate || "0.0000"}%`, taxRate.taxComponents?.length ? `Tax Components:\n${taxRate.taxComponents .map( (comp) => ` - ${comp.name}: ${comp.rate}%${comp.isCompound ? " (Compound)" : ""}${comp.isNonRecoverable ? " (Non-recoverable)" : ""}`, ) .join("\n")}` : null, `Can Apply To:${[ taxRate.canApplyToAssets ? " Assets" : "", taxRate.canApplyToEquity ? " Equity" : "", taxRate.canApplyToExpenses ? " Expenses" : "", taxRate.canApplyToLiabilities ? " Liabilities" : "", taxRate.canApplyToRevenue ? " Revenue" : "", ].join("")}`, ] .filter(Boolean) .join("\n"), })) || []), ], }; }, );
- Core handler function that fetches tax rates from the Xero API using xeroClient.accountingApi.getTaxRates(), handles errors, and returns structured response.export async function listXeroTaxRates(): Promise< XeroClientResponse<TaxRate[]> > { try { const taxRates = await getTaxRates(); return { result: taxRates, isError: false, error: null, }; } catch (error) { return { result: null, isError: true, error: formatError(error), }; } }
- Internal helper function that authenticates the Xero client and retrieves the list of tax rates.async function getTaxRates(): Promise<TaxRate[]> { await xeroClient.authenticate(); const taxRates = await xeroClient.accountingApi.getTaxRates( xeroClient.tenantId, undefined, // where undefined, // order getClientHeaders(), ); return taxRates.body.taxRates ?? []; }
- src/tools/list/index.ts:32-58 (registration)Registration of the list-tax-rates tool (as ListTaxRatesTool) within the ListTools array for export and likely further registration in the MCP server.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 ];
- src/tools/list/index.ts:27-27 (registration)Import of the ListTaxRatesTool for inclusion in ListTools.import ListTaxRatesTool from "./list-tax-rates.tool.js";