@teamnetwork-nz/xero-mcp-server 1.11.0 → 1.13.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (28) hide show
  1. package/README.md +4 -1
  2. package/dist/clients/xero-client.js +1 -0
  3. package/dist/handlers/list-xero-journals.handler.js +134 -0
  4. package/dist/handlers/list-xero-report-bank-summary.handler.js +36 -0
  5. package/dist/helpers/datetime.js +21 -0
  6. package/dist/tools/create/convert-quote-to-invoice.tool.js +2 -1
  7. package/dist/tools/create/create-manual-journal.tool.js +2 -1
  8. package/dist/tools/get/get-invoice.tool.js +4 -4
  9. package/dist/tools/get/get-payroll-timesheet.tool.js +3 -3
  10. package/dist/tools/list/index.js +4 -0
  11. package/dist/tools/list/list-bank-transactions.tool.js +2 -1
  12. package/dist/tools/list/list-credit-notes.tool.js +3 -3
  13. package/dist/tools/list/list-invoices.tool.js +4 -4
  14. package/dist/tools/list/list-journals.tool.js +76 -0
  15. package/dist/tools/list/list-manual-journals.tool.js +2 -2
  16. package/dist/tools/list/list-organisation-details.tool.js +2 -2
  17. package/dist/tools/list/list-overpayments.tool.js +3 -3
  18. package/dist/tools/list/list-payments.tool.js +2 -2
  19. package/dist/tools/list/list-payroll-employee-leave-types.tool.js +2 -1
  20. package/dist/tools/list/list-payroll-employee-leave.tool.js +3 -3
  21. package/dist/tools/list/list-payroll-employees.tool.js +2 -2
  22. package/dist/tools/list/list-payroll-leave-periods.tool.js +3 -2
  23. package/dist/tools/list/list-payroll-timesheets.tool.js +3 -3
  24. package/dist/tools/list/list-prepayments.tool.js +3 -3
  25. package/dist/tools/list/list-profit-and-loss.tool.js +2 -1
  26. package/dist/tools/list/list-quotes.tool.js +3 -3
  27. package/dist/tools/list/list-report-bank-summary.tool.js +46 -0
  28. package/package.json +1 -1
package/README.md CHANGED
@@ -45,6 +45,7 @@ accounting.transactions
45
45
  accounting.contacts
46
46
  accounting.settings
47
47
  accounting.attachments
48
+ accounting.journals.read
48
49
  ```
49
50
 
50
51
  ### 2. Authentication
@@ -98,7 +99,7 @@ Scopes and tools are controlled by environment variables. This means you only pr
98
99
 
99
100
  | Variable | Default | Scopes requested | Tools enabled |
100
101
  |---|---|---|---|
101
- | *(core — always on)* | — | `accounting.transactions` `accounting.contacts` `accounting.settings` `accounting.attachments` | All invoicing, contact, payment, attachment & PDF tools |
102
+ | *(core — always on)* | — | `accounting.transactions` `accounting.contacts` `accounting.settings` `accounting.attachments` `accounting.journals.read` | All invoicing, contact, payment, attachment, PDF & journal tools |
102
103
  | `XERO_ENABLE_REPORTS` | `true` | `accounting.reports.read` | Trial Balance, P&L, Balance Sheet, Aged Payables/Receivables |
103
104
  | `XERO_ENABLE_PAYROLL` | `false` | `payroll.settings` `payroll.employees` `payroll.timesheets` | All payroll tools |
104
105
 
@@ -193,9 +194,11 @@ Date inputs to the Xero API (invoice dates, fromDate, toDate, etc.) are `YYYY-MM
193
194
  | `list-bank-transactions` | List bank transactions |
194
195
  | `create-bank-transaction` | Create a bank transaction |
195
196
  | `update-bank-transaction` | Update a bank transaction |
197
+ | `list-report-bank-summary` | Opening/closing balance and cash in/out per bank account (Xero's Bank Summary report) |
196
198
  | `list-manual-journals` | List manual journals |
197
199
  | `create-manual-journal` | Create a manual journal |
198
200
  | `update-manual-journal` | Update a manual journal |
201
+ | `list-journals` | List the underlying GL posting stream (double-entry journal lines per account) |
199
202
 
200
203
  ### Settings & Configuration
201
204
  | Tool | Description |
@@ -23,6 +23,7 @@ function buildScopes() {
23
23
  "accounting.contacts",
24
24
  "accounting.settings",
25
25
  "accounting.attachments",
26
+ "accounting.journals.read",
26
27
  ];
27
28
  if (process.env.XERO_ENABLE_REPORTS !== "false") {
28
29
  scopes.push("accounting.reports.read");
@@ -0,0 +1,134 @@
1
+ import { xeroClient } from "../clients/xero-client.js";
2
+ import { formatError } from "../helpers/format-error.js";
3
+ import { getClientHeaders } from "../helpers/get-client-headers.js";
4
+ import { formatXeroDate } from "../helpers/datetime.js";
5
+ const BATCH_SIZE = 100; // fixed by the Xero API — getJournals has no pageSize param
6
+ const MAX_SEEK_CALLS = 40; // binary/exponential search bound while locating fromDate
7
+ const MAX_COLLECT_BATCHES = 20; // bound on sequential batches fetched after seeking
8
+ async function fetchBatch(offset, paymentsOnly) {
9
+ const response = await xeroClient.accountingApi.getJournals(xeroClient.tenantId, undefined, // ifModifiedSince
10
+ offset, paymentsOnly, getClientHeaders());
11
+ return response.body.journals ?? [];
12
+ }
13
+ function lastDate(batch) {
14
+ return formatXeroDate(batch[batch.length - 1]?.journalDate);
15
+ }
16
+ /**
17
+ * Journal numbers are strictly ascending and chronological, so "has the batch starting after
18
+ * offset N reached fromDate yet" is a monotonic predicate in N — safe to binary search.
19
+ * An empty batch (offset past the last journal) counts as "reached" too, since there's nothing
20
+ * left to find beyond it — that keeps the predicate monotonic even when a probe overshoots the
21
+ * actual end of the ledger, which an exponential doubling search will routinely do.
22
+ * Finds the largest offset that is still safely before fromDate (0 if fromDate is at/before the
23
+ * start of the ledger, or if the ledger is empty).
24
+ */
25
+ async function seekOffsetBeforeDate(fromDate, paymentsOnly) {
26
+ let calls = 0;
27
+ const reached = async (offset) => {
28
+ const batch = await fetchBatch(offset, paymentsOnly);
29
+ calls += 1;
30
+ return batch.length === 0 || lastDate(batch) >= fromDate;
31
+ };
32
+ if (await reached(0))
33
+ return 0;
34
+ // Exponential search for an offset whose batch has reached fromDate (or the end of the ledger).
35
+ let lo = 0;
36
+ let hi = BATCH_SIZE;
37
+ while (!(await reached(hi))) {
38
+ if (calls >= MAX_SEEK_CALLS)
39
+ return lo;
40
+ lo = hi;
41
+ hi *= 2;
42
+ }
43
+ // Binary search within (lo, hi] to converge to within one batch width of the target.
44
+ while (hi - lo > BATCH_SIZE && calls < MAX_SEEK_CALLS) {
45
+ const mid = lo + Math.floor((hi - lo) / 2);
46
+ if (await reached(mid)) {
47
+ hi = mid;
48
+ }
49
+ else {
50
+ lo = mid;
51
+ }
52
+ }
53
+ return lo;
54
+ }
55
+ async function getJournalsInRange(fromDate, toDate, accountId, accountCode, paymentsOnly, maxResults = 100) {
56
+ await xeroClient.authenticate();
57
+ const startOffset = fromDate ? await seekOffsetBeforeDate(fromDate, paymentsOnly) : 0;
58
+ const matched = [];
59
+ let offset = startOffset;
60
+ let truncated = false;
61
+ for (let batchCount = 0; batchCount < MAX_COLLECT_BATCHES; batchCount++) {
62
+ const batch = await fetchBatch(offset, paymentsOnly);
63
+ if (batch.length === 0)
64
+ break;
65
+ for (const journal of batch) {
66
+ const date = formatXeroDate(journal.journalDate);
67
+ if (fromDate && date < fromDate)
68
+ continue;
69
+ if (toDate && date > toDate) {
70
+ return { journals: matched, truncated: false };
71
+ }
72
+ if (accountId && !journal.journalLines?.some((line) => line.accountID === accountId))
73
+ continue;
74
+ if (accountCode && !journal.journalLines?.some((line) => line.accountCode === accountCode))
75
+ continue;
76
+ matched.push(journal);
77
+ if (matched.length >= maxResults) {
78
+ return { journals: matched, nextOffset: journal.journalNumber, truncated: true };
79
+ }
80
+ }
81
+ offset = batch[batch.length - 1].journalNumber ?? offset;
82
+ if (batch.length < BATCH_SIZE)
83
+ break; // reached the end of the ledger
84
+ if (batchCount === MAX_COLLECT_BATCHES - 1) {
85
+ truncated = true;
86
+ }
87
+ }
88
+ return { journals: matched, nextOffset: truncated ? offset : undefined, truncated };
89
+ }
90
+ async function getJournalsRaw(offset, paymentsOnly) {
91
+ await xeroClient.authenticate();
92
+ return fetchBatch(offset, paymentsOnly);
93
+ }
94
+ /**
95
+ * List journals from Xero — the underlying double-entry GL posting stream, one line per
96
+ * debit/credit per account. This is what Xero's own UI shows when drilling into a
97
+ * P&L/Balance Sheet line, and is the definitive source for "what actually posted to account X".
98
+ *
99
+ * Two modes:
100
+ * - Raw/incremental (no fromDate): thin wrapper around Xero's own offset-based sync contract —
101
+ * returns one batch (up to 100 journals) starting after `offset`.
102
+ * - Date-range convenience (fromDate given): seeks to the right starting point via binary
103
+ * search (journal numbers are strictly chronological) and collects matching journals up to
104
+ * `maxResults`, optionally filtered to a single account.
105
+ */
106
+ export async function listXeroJournals(offset = 0, paymentsOnly, fromDate, toDate, accountId, accountCode, maxResults = 100) {
107
+ try {
108
+ if (!fromDate && !toDate && !accountId && !accountCode) {
109
+ const journals = await getJournalsRaw(offset, paymentsOnly);
110
+ return {
111
+ result: {
112
+ journals,
113
+ nextOffset: journals[journals.length - 1]?.journalNumber,
114
+ truncated: journals.length === BATCH_SIZE,
115
+ },
116
+ isError: false,
117
+ error: null,
118
+ };
119
+ }
120
+ const result = await getJournalsInRange(fromDate, toDate, accountId, accountCode, paymentsOnly, maxResults);
121
+ return {
122
+ result,
123
+ isError: false,
124
+ error: null,
125
+ };
126
+ }
127
+ catch (error) {
128
+ return {
129
+ result: null,
130
+ isError: true,
131
+ error: formatError(error),
132
+ };
133
+ }
134
+ }
@@ -0,0 +1,36 @@
1
+ import { xeroClient } from "../clients/xero-client.js";
2
+ import { formatError } from "../helpers/format-error.js";
3
+ import { getClientHeaders } from "../helpers/get-client-headers.js";
4
+ async function fetchBankSummary(fromDate, toDate) {
5
+ await xeroClient.authenticate();
6
+ const response = await xeroClient.accountingApi.getReportBankSummary(xeroClient.tenantId, fromDate, toDate, getClientHeaders());
7
+ return response.body.reports?.[0] ?? null;
8
+ }
9
+ /**
10
+ * List bank summary report from Xero — opening/closing balance and net cash
11
+ * movement per bank account for a date range, as computed by Xero itself.
12
+ */
13
+ export async function listXeroReportBankSummary(fromDate, toDate) {
14
+ try {
15
+ const bankSummary = await fetchBankSummary(fromDate, toDate);
16
+ if (!bankSummary) {
17
+ return {
18
+ result: null,
19
+ isError: true,
20
+ error: "Failed to fetch bank summary data from Xero.",
21
+ };
22
+ }
23
+ return {
24
+ result: bankSummary,
25
+ isError: false,
26
+ error: null,
27
+ };
28
+ }
29
+ catch (error) {
30
+ return {
31
+ result: null,
32
+ isError: true,
33
+ error: formatError(error),
34
+ };
35
+ }
36
+ }
@@ -73,6 +73,27 @@ export function formatUtcDatetime(val) {
73
73
  const { year, month, day, hour, minute, second } = dateParts(d, tz);
74
74
  return `${year}-${month}-${day} ${hour}:${minute}:${second}`;
75
75
  }
76
+ /**
77
+ * Formats a Xero date-only field (invoice date, due date, journal date, allocation date,
78
+ * payroll start/end date, etc.) as YYYY-MM-DD.
79
+ *
80
+ * Unlike formatUtcDatetime, this does NOT convert to the configured display timezone.
81
+ * These fields are calendar dates with no meaningful time-of-day component, and Xero encodes
82
+ * them as a UTC-midnight instant regardless of the org's real timezone — converting that into
83
+ * a timezone behind UTC would silently shift the date back a day. The correct read is always
84
+ * the UTC calendar components. Accepts a Date object (accounting API fields deserialize this
85
+ * way) or a plain string (payroll API fields, or a "...String" field already YYYY-MM-DD).
86
+ */
87
+ export function formatXeroDate(val) {
88
+ if (!val)
89
+ return "";
90
+ if (val instanceof Date) {
91
+ if (isNaN(val.getTime()))
92
+ return String(val);
93
+ return val.toISOString().slice(0, 10);
94
+ }
95
+ return val.slice(0, 10);
96
+ }
76
97
  /**
77
98
  * Converts a local date string (YYYY-MM-DD) to a UTC Date, treating the
78
99
  * input as midnight in the configured timezone.
@@ -2,6 +2,7 @@ import { z } from "zod";
2
2
  import { convertXeroQuoteToInvoice } from "../../handlers/convert-xero-quote-to-invoice.handler.js";
3
3
  import { DeepLinkType, getDeepLink } from "../../helpers/get-deeplink.js";
4
4
  import { CreateXeroTool } from "../../helpers/create-xero-tool.js";
5
+ import { formatXeroDate } from "../../helpers/datetime.js";
5
6
  const ConvertQuoteToInvoiceTool = CreateXeroTool("convert-quote-to-invoice", "Convert an existing Xero quote into a draft invoice. \
6
7
  Line items, contact, and reference are copied from the quote. \
7
8
  The quote ID can be obtained from the list-quotes tool. \
@@ -33,7 +34,7 @@ const ConvertQuoteToInvoiceTool = CreateXeroTool("convert-quote-to-invoice", "Co
33
34
  `Contact: ${invoice.contact?.name ?? "N/A"}`,
34
35
  `Reference (Quote): ${invoice.reference ?? "N/A"}`,
35
36
  `Total: ${invoice.total}`,
36
- `Due Date: ${invoice.dueDate}`,
37
+ `Due Date: ${formatXeroDate(invoice.dueDate)}`,
37
38
  `Status: ${invoice.status}`,
38
39
  deepLink ? `Link to view: ${deepLink}` : null,
39
40
  ]
@@ -3,6 +3,7 @@ import { CreateXeroTool } from "../../helpers/create-xero-tool.js";
3
3
  import { createXeroManualJournal } from "../../handlers/create-xero-manual-journal.handler.js";
4
4
  import { DeepLinkType, getDeepLink } from "../../helpers/get-deeplink.js";
5
5
  import { ensureError } from "../../helpers/ensure-error.js";
6
+ import { formatXeroDate } from "../../helpers/datetime.js";
6
7
  const CreateManualJournalTool = CreateXeroTool("create-manual-journal", "Create a manual journal in Xero.\
7
8
  Retrieve a list of account codes in Xero to use for the journal lines.\
8
9
  Journal lines must contain at least two individual journal lines with account codes, \
@@ -68,7 +69,7 @@ const CreateManualJournalTool = CreateXeroTool("create-manual-journal", "Create
68
69
  type: "text",
69
70
  text: [
70
71
  `Manual journal created: ${manualJournal.narration} (ID: ${manualJournal.manualJournalID})`,
71
- manualJournal.date ? `Date: ${manualJournal.date}` : null,
72
+ manualJournal.date ? `Date: ${formatXeroDate(manualJournal.date)}` : null,
72
73
  manualJournal.status
73
74
  ? `Status: ${manualJournal.status}`
74
75
  : "No status",
@@ -3,7 +3,7 @@ import { getXeroInvoice } from "../../handlers/get-xero-invoice.handler.js";
3
3
  import { DeepLinkType, getDeepLink } from "../../helpers/get-deeplink.js";
4
4
  import { CreateXeroTool } from "../../helpers/create-xero-tool.js";
5
5
  import { formatLineItem } from "../../helpers/format-line-item.js";
6
- import { formatUtcDatetime } from "../../helpers/datetime.js";
6
+ import { formatUtcDatetime, formatXeroDate } from "../../helpers/datetime.js";
7
7
  import { Invoice } from "xero-node";
8
8
  const GetInvoiceTool = CreateXeroTool("get-invoice", "Get full details of a single invoice in Xero by its ID, including all line items. \
9
9
  Use list-invoices first to find the invoice ID if you only have an invoice number. \
@@ -35,8 +35,8 @@ const GetInvoiceTool = CreateXeroTool("get-invoice", "Get full details of a sing
35
35
  invoice.contact
36
36
  ? `Contact: ${invoice.contact.name} (${invoice.contact.contactID})`
37
37
  : null,
38
- invoice.date ? `Date: ${invoice.date}` : null,
39
- invoice.dueDate ? `Due Date: ${invoice.dueDate}` : null,
38
+ invoice.date ? `Date: ${formatXeroDate(invoice.date)}` : null,
39
+ invoice.dueDate ? `Due Date: ${formatXeroDate(invoice.dueDate)}` : null,
40
40
  invoice.lineAmountTypes
41
41
  ? `Line Amount Types: ${invoice.lineAmountTypes}`
42
42
  : null,
@@ -53,7 +53,7 @@ const GetInvoiceTool = CreateXeroTool("get-invoice", "Get full details of a sing
53
53
  ? `Amount Credited: ${invoice.amountCredited}`
54
54
  : null,
55
55
  invoice.fullyPaidOnDate
56
- ? `Fully Paid On: ${invoice.fullyPaidOnDate}`
56
+ ? `Fully Paid On: ${formatXeroDate(invoice.fullyPaidOnDate)}`
57
57
  : null,
58
58
  invoice.updatedDateUTC
59
59
  ? `Last Updated: ${formatUtcDatetime(invoice.updatedDateUTC)}`
@@ -1,7 +1,7 @@
1
1
  import { z } from "zod";
2
2
  import { getXeroPayrollTimesheet, } from "../../handlers/get-xero-payroll-timesheet.handler.js";
3
3
  import { CreateXeroTool } from "../../helpers/create-xero-tool.js";
4
- import { formatUtcDatetime } from "../../helpers/datetime.js";
4
+ import { formatUtcDatetime, formatXeroDate } from "../../helpers/datetime.js";
5
5
  const GetPayrollTimesheetTool = CreateXeroTool("get-timesheet", `Retrieve a single payroll timesheet from Xero by its ID.
6
6
  This provides details such as the timesheet ID, employee ID, start and end dates, total hours, and the last updated date.`, {
7
7
  timesheetID: z.string().describe("The ID of the timesheet to retrieve."),
@@ -36,8 +36,8 @@ This provides details such as the timesheet ID, employee ID, start and end dates
36
36
  text: [
37
37
  `Timesheet ID: ${timesheet.timesheetID}`,
38
38
  `Employee ID: ${timesheet.employeeID}`,
39
- `Start Date: ${timesheet.startDate}`,
40
- `End Date: ${timesheet.endDate}`,
39
+ `Start Date: ${formatXeroDate(timesheet.startDate)}`,
40
+ `End Date: ${formatXeroDate(timesheet.endDate)}`,
41
41
  `Total Hours: ${timesheet.totalHours}`,
42
42
  `Last Updated: ${formatUtcDatetime(timesheet.updatedDateUTC)}`,
43
43
  ]
@@ -6,6 +6,7 @@ import ListContactsTool from "./list-contacts.tool.js";
6
6
  import ListCreditNotesTool from "./list-credit-notes.tool.js";
7
7
  import ListInvoicesTool from "./list-invoices.tool.js";
8
8
  import ListItemsTool from "./list-items.tool.js";
9
+ import ListJournalsTool from "./list-journals.tool.js";
9
10
  import ListManualJournalsTool from "./list-manual-journals.tool.js";
10
11
  import ListOrganisationDetailsTool from "./list-organisation-details.tool.js";
11
12
  import ListOverpaymentsTool from "./list-overpayments.tool.js";
@@ -21,6 +22,7 @@ import ListPayrollTimesheetsTool from "./list-payroll-timesheets.tool.js";
21
22
  import ListProfitAndLossTool from "./list-profit-and-loss.tool.js";
22
23
  import ListQuotesTool from "./list-quotes.tool.js";
23
24
  import ListReportBalanceSheetTool from "./list-report-balance-sheet.tool.js";
25
+ import ListReportBankSummaryTool from "./list-report-bank-summary.tool.js";
24
26
  import ListTaxRatesTool from "./list-tax-rates.tool.js";
25
27
  import ListTrackingCategoriesTool from "./list-tracking-categories.tool.js";
26
28
  import ListTrialBalanceTool from "./list-trial-balance.tool.js";
@@ -32,6 +34,7 @@ export const CoreListTools = [
32
34
  ListCreditNotesTool,
33
35
  ListInvoicesTool,
34
36
  ListItemsTool,
37
+ ListJournalsTool,
35
38
  ListManualJournalsTool,
36
39
  ListQuotesTool,
37
40
  ListTaxRatesTool,
@@ -48,6 +51,7 @@ export const ReportListTools = [
48
51
  ListTrialBalanceTool,
49
52
  ListProfitAndLossTool,
50
53
  ListReportBalanceSheetTool,
54
+ ListReportBankSummaryTool,
51
55
  ListAgedReceivablesByContact,
52
56
  ListAgedPayablesByContact,
53
57
  ];
@@ -2,6 +2,7 @@ import { z } from "zod";
2
2
  import { CreateXeroTool } from "../../helpers/create-xero-tool.js";
3
3
  import { listXeroBankTransactions } from "../../handlers/list-xero-bank-transactions.handler.js";
4
4
  import { formatLineItem } from "../../helpers/format-line-item.js";
5
+ import { formatXeroDate } from "../../helpers/datetime.js";
5
6
  const ListBankTransactionsTool = CreateXeroTool("list-bank-transactions", "List bank transactions from Xero. " +
6
7
  "Always use filters — do NOT page through all transactions to find specific ones. " +
7
8
  "Common patterns: " +
@@ -46,7 +47,7 @@ const ListBankTransactionsTool = CreateXeroTool("list-bank-transactions", "List
46
47
  ? `Contact: ${transaction.contact.name} (${transaction.contact.contactID})`
47
48
  : null,
48
49
  transaction.reference ? `Reference: ${transaction.reference}` : null,
49
- transaction.date ? `Date: ${transaction.date}` : null,
50
+ transaction.date ? `Date: ${formatXeroDate(transaction.date)}` : null,
50
51
  transaction.subTotal ? `Sub Total: ${transaction.subTotal}` : null,
51
52
  transaction.totalTax ? `Total Tax: ${transaction.totalTax}` : null,
52
53
  transaction.total ? `Total: ${transaction.total}` : null,
@@ -1,7 +1,7 @@
1
1
  import { z } from "zod";
2
2
  import { listXeroCreditNotes } from "../../handlers/list-xero-credit-notes.handler.js";
3
3
  import { CreateXeroTool } from "../../helpers/create-xero-tool.js";
4
- import { formatUtcDatetime } from "../../helpers/datetime.js";
4
+ import { formatUtcDatetime, formatXeroDate } from "../../helpers/datetime.js";
5
5
  const ListCreditNotesTool = CreateXeroTool("list-credit-notes", "List credit notes from Xero. " +
6
6
  "ACCREC = sales credit notes (issued to customers). ACCPAY = purchase credit notes (received from suppliers). " +
7
7
  "Common patterns: " +
@@ -48,7 +48,7 @@ const ListCreditNotesTool = CreateXeroTool("list-credit-notes", "List credit not
48
48
  creditNote.contact
49
49
  ? `Contact: ${creditNote.contact.name} (${creditNote.contact.contactID})`
50
50
  : null,
51
- creditNote.date ? `Date: ${creditNote.date}` : null,
51
+ creditNote.date ? `Date: ${formatXeroDate(creditNote.date)}` : null,
52
52
  creditNote.lineAmountTypes
53
53
  ? `Line Amount Types: ${creditNote.lineAmountTypes}`
54
54
  : null,
@@ -63,7 +63,7 @@ const ListCreditNotesTool = CreateXeroTool("list-credit-notes", "List credit not
63
63
  : null,
64
64
  creditNote.allocations?.length
65
65
  ? `Allocations:\n${creditNote.allocations
66
- .map((allocation) => ` - ${allocation.amount} on ${allocation.date} → Invoice ${allocation.invoice?.invoiceNumber ?? allocation.invoice?.invoiceID ?? "Unknown"}`)
66
+ .map((allocation) => ` - ${allocation.amount} on ${formatXeroDate(allocation.date)} → Invoice ${allocation.invoice?.invoiceNumber ?? allocation.invoice?.invoiceID ?? "Unknown"}`)
67
67
  .join("\n")}`
68
68
  : null,
69
69
  creditNote.currencyCode
@@ -2,7 +2,7 @@ import { z } from "zod";
2
2
  import { listXeroInvoices } from "../../handlers/list-xero-invoices.handler.js";
3
3
  import { CreateXeroTool } from "../../helpers/create-xero-tool.js";
4
4
  import { formatLineItem } from "../../helpers/format-line-item.js";
5
- import { formatUtcDatetime } from "../../helpers/datetime.js";
5
+ import { formatUtcDatetime, formatXeroDate } from "../../helpers/datetime.js";
6
6
  const ListInvoicesTool = CreateXeroTool("list-invoices", "List invoices from Xero. " +
7
7
  "ACCREC = sales invoices (Accounts Receivable, money owed to you). " +
8
8
  "ACCPAY = bills/purchase invoices (Accounts Payable, money you owe suppliers). " +
@@ -57,8 +57,8 @@ const ListInvoicesTool = CreateXeroTool("list-invoices", "List invoices from Xer
57
57
  invoice.contact
58
58
  ? `Contact: ${invoice.contact.name} (${invoice.contact.contactID})`
59
59
  : null,
60
- invoice.date ? `Date: ${invoice.date}` : null,
61
- invoice.dueDate ? `Due Date: ${invoice.dueDate}` : null,
60
+ invoice.date ? `Date: ${formatXeroDate(invoice.date)}` : null,
61
+ invoice.dueDate ? `Due Date: ${formatXeroDate(invoice.dueDate)}` : null,
62
62
  invoice.lineAmountTypes
63
63
  ? `Line Amount Types: ${invoice.lineAmountTypes}`
64
64
  : null,
@@ -76,7 +76,7 @@ const ListInvoicesTool = CreateXeroTool("list-invoices", "List invoices from Xer
76
76
  ? `Last Updated: ${formatUtcDatetime(invoice.updatedDateUTC)}`
77
77
  : null,
78
78
  invoice.fullyPaidOnDate
79
- ? `Fully Paid On: ${invoice.fullyPaidOnDate}`
79
+ ? `Fully Paid On: ${formatXeroDate(invoice.fullyPaidOnDate)}`
80
80
  : null,
81
81
  invoice.amountDue ? `Amount Due: ${invoice.amountDue}` : null,
82
82
  invoice.amountPaid ? `Amount Paid: ${invoice.amountPaid}` : null,
@@ -0,0 +1,76 @@
1
+ import { z } from "zod";
2
+ import { listXeroJournals } from "../../handlers/list-xero-journals.handler.js";
3
+ import { CreateXeroTool } from "../../helpers/create-xero-tool.js";
4
+ import { formatXeroDate } from "../../helpers/datetime.js";
5
+ function journalFormatter(journal) {
6
+ return [
7
+ `Journal Number: ${journal.journalNumber}`,
8
+ `Journal ID: ${journal.journalID}`,
9
+ journal.journalDate ? `Date: ${formatXeroDate(journal.journalDate)}` : null,
10
+ journal.sourceType ? `Source Type: ${journal.sourceType}` : null,
11
+ journal.sourceID ? `Source ID: ${journal.sourceID}` : null,
12
+ journal.reference ? `Reference: ${journal.reference}` : null,
13
+ journal.journalLines?.length
14
+ ? `Lines:\n${journal.journalLines
15
+ .map((line) => ` - ${line.accountCode ?? "?"} ${line.accountName ?? "Unknown account"}: ` +
16
+ `Net ${line.netAmount ?? 0}${line.grossAmount !== undefined ? `, Gross ${line.grossAmount}` : ""}` +
17
+ (line.description ? ` — ${line.description}` : ""))
18
+ .join("\n")}`
19
+ : null,
20
+ ]
21
+ .filter(Boolean)
22
+ .join("\n");
23
+ }
24
+ const ListJournalsTool = CreateXeroTool("list-journals", "List journals from Xero — the underlying double-entry general ledger posting stream " +
25
+ "(one line per debit/credit per account). This is the authoritative source for drilling " +
26
+ "into what actually posted to a specific account, matching what Xero's own UI shows when " +
27
+ "you click into a P&L or Balance Sheet line. " +
28
+ "Two modes: " +
29
+ "(1) Raw/incremental — omit fromDate: a thin wrapper around Xero's own sync contract, " +
30
+ "returning up to 100 journals starting after `offset` (Xero's fixed batch size — no pageSize). " +
31
+ "Use `nextOffset` from the response to page forward. " +
32
+ "(2) Date-range — set fromDate (and optionally toDate/accountId/accountCode): the tool " +
33
+ "seeks to the right starting point internally (journal numbers are strictly chronological, " +
34
+ "so this is a bounded binary search, not a full ledger scan) and collects matching journals " +
35
+ "up to maxResults. " +
36
+ "IMPORTANT: if you set accountId/accountCode WITHOUT fromDate, the scan starts from the very " +
37
+ "beginning of the ledger (oldest first) — always pass fromDate alongside an account filter " +
38
+ "unless you specifically want the oldest matching activity. " +
39
+ "This endpoint has no date/account filter on Xero's side — for a lighter-weight net movement " +
40
+ "figure per bank account, prefer list-report-bank-summary; use list-journals when you need " +
41
+ "the actual line-by-line postings.", {
42
+ offset: z.number().optional().describe("Raw mode only: journal number to start after (exclusive). Omit fromDate to use this mode directly."),
43
+ paymentsOnly: z.boolean().optional().describe("If true, only returns journals related to payments."),
44
+ fromDate: z.string().optional().describe("Date-range mode: only return journals on or after this date (YYYY-MM-DD). Setting this enables seek+collect mode."),
45
+ toDate: z.string().optional().describe("Date-range mode: only return journals on or before this date (YYYY-MM-DD)."),
46
+ accountId: z.string().optional().describe("Date-range mode: only return journals with at least one line posted to this account ID."),
47
+ accountCode: z.string().optional().describe("Date-range mode: only return journals with at least one line posted to this account code."),
48
+ maxResults: z.number().min(1).max(500).optional().default(100).describe("Date-range mode: maximum journals to return before stopping and reporting truncated=true (default 100)."),
49
+ }, async ({ offset, paymentsOnly, fromDate, toDate, accountId, accountCode, maxResults }) => {
50
+ const response = await listXeroJournals(offset ?? 0, paymentsOnly, fromDate, toDate, accountId, accountCode, maxResults);
51
+ if (response.error !== null) {
52
+ return {
53
+ content: [
54
+ {
55
+ type: "text",
56
+ text: `Error listing journals: ${response.error}`,
57
+ },
58
+ ],
59
+ };
60
+ }
61
+ const { journals, nextOffset, truncated } = response.result;
62
+ return {
63
+ content: [
64
+ {
65
+ type: "text",
66
+ text: `Found ${journals.length} journals${truncated ? " (truncated — more may exist)" : ""}:` +
67
+ (nextOffset !== undefined ? ` Next offset: ${nextOffset}` : ""),
68
+ },
69
+ ...journals.map((journal) => ({
70
+ type: "text",
71
+ text: journalFormatter(journal),
72
+ })),
73
+ ],
74
+ };
75
+ });
76
+ export default ListJournalsTool;
@@ -1,7 +1,7 @@
1
1
  import { listXeroManualJournals } from "../../handlers/list-xero-manual-journals.handler.js";
2
2
  import { CreateXeroTool } from "../../helpers/create-xero-tool.js";
3
3
  import { z } from "zod";
4
- import { formatUtcDatetime } from "../../helpers/datetime.js";
4
+ import { formatUtcDatetime, formatXeroDate } from "../../helpers/datetime.js";
5
5
  const ListManualJournalsTool = CreateXeroTool("list-manual-journals", `List all manual journals from Xero.
6
6
  Ask the user if they want to see a specific manual journal or all manual journals before running.
7
7
  Can optionally pass in manual journal ID to retrieve a specific journal, or a date to filter journals modified after that date.
@@ -44,7 +44,7 @@ If they want the next page, call this tool again with the next page number, modi
44
44
  journal.narration
45
45
  ? `Description: ${journal.narration}`
46
46
  : "No description",
47
- journal.date ? `Date: ${journal.date}` : null,
47
+ journal.date ? `Date: ${formatXeroDate(journal.date)}` : null,
48
48
  journal.journalLines
49
49
  ? journal.journalLines.map((line) => [
50
50
  `Line Amount: ${line.lineAmount}`,
@@ -1,7 +1,7 @@
1
1
  import { listXeroOrganisationDetails } from "../../handlers/list-xero-organisation-details.handler.js";
2
2
  import { getExternalLink } from "../../helpers/get-external-link.js";
3
3
  import { CreateXeroTool } from "../../helpers/create-xero-tool.js";
4
- import { formatUtcDatetime } from "../../helpers/datetime.js";
4
+ import { formatUtcDatetime, formatXeroDate } from "../../helpers/datetime.js";
5
5
  const ListOrganisationDetailsTool = CreateXeroTool("list-organisation-details", "Lists the organisation details from Xero. Use this tool to get information about the current Xero organisation.", {}, async () => {
6
6
  const response = await listXeroOrganisationDetails();
7
7
  if (response.error !== null) {
@@ -63,7 +63,7 @@ const ListOrganisationDetailsTool = CreateXeroTool("list-organisation-details",
63
63
  `Financial Year End Month: ${organisation.financialYearEndMonth} || "No financial year end month set."`,
64
64
  `Sales Tax Basis: ${organisation.salesTaxBasis} || "No sales tax basis available."`,
65
65
  `Sales Tax Period: ${organisation.salesTaxPeriod} || "No sales tax period available."`,
66
- organisation.periodLockDate ? `Period Lock Date: ${organisation.periodLockDate}` : null,
66
+ organisation.periodLockDate ? `Period Lock Date: ${formatXeroDate(organisation.periodLockDate)}` : null,
67
67
  organisation.organisationStatus ? `Organisation Status: ${organisation.organisationStatus}` : null,
68
68
  `Created Date: ${organisation.createdDateUTC ? formatUtcDatetime(organisation.createdDateUTC) : "No created date available."}`,
69
69
  `Edition: ${organisation.edition} || "No edition available."`,
@@ -1,7 +1,7 @@
1
1
  import { z } from "zod";
2
2
  import { listXeroOverpayments } from "../../handlers/list-xero-overpayments.handler.js";
3
3
  import { CreateXeroTool } from "../../helpers/create-xero-tool.js";
4
- import { formatUtcDatetime } from "../../helpers/datetime.js";
4
+ import { formatUtcDatetime, formatXeroDate } from "../../helpers/datetime.js";
5
5
  const ListOverpaymentsTool = CreateXeroTool("list-overpayments", "List overpayments from Xero. Overpayments are a SEPARATE record type from Payments — " +
6
6
  "they're created when a customer pays more than an invoice total, or a supplier is paid " +
7
7
  "more than a bill total, and are NOT returned by list-payments. " +
@@ -46,7 +46,7 @@ const ListOverpaymentsTool = CreateXeroTool("list-overpayments", "List overpayme
46
46
  overpayment.contact
47
47
  ? `Contact: ${overpayment.contact.name} (${overpayment.contact.contactID})`
48
48
  : null,
49
- overpayment.date ? `Date: ${overpayment.date}` : null,
49
+ overpayment.date ? `Date: ${formatXeroDate(overpayment.date)}` : null,
50
50
  `Total: ${overpayment.total || 0}`,
51
51
  overpayment.remainingCredit !== undefined
52
52
  ? `Remaining Credit: ${overpayment.remainingCredit}`
@@ -56,7 +56,7 @@ const ListOverpaymentsTool = CreateXeroTool("list-overpayments", "List overpayme
56
56
  : null,
57
57
  overpayment.allocations?.length
58
58
  ? `Allocations:\n${overpayment.allocations
59
- .map((allocation) => ` - ${allocation.amount} on ${allocation.date} → Invoice ${allocation.invoice?.invoiceNumber ?? allocation.invoice?.invoiceID ?? "Unknown"}`)
59
+ .map((allocation) => ` - ${allocation.amount} on ${formatXeroDate(allocation.date)} → Invoice ${allocation.invoice?.invoiceNumber ?? allocation.invoice?.invoiceID ?? "Unknown"}`)
60
60
  .join("\n")}`
61
61
  : null,
62
62
  overpayment.currencyCode
@@ -1,11 +1,11 @@
1
1
  import { z } from "zod";
2
2
  import { listXeroPayments } from "../../handlers/list-xero-payments.handler.js";
3
3
  import { CreateXeroTool } from "../../helpers/create-xero-tool.js";
4
- import { formatUtcDatetime } from "../../helpers/datetime.js";
4
+ import { formatUtcDatetime, formatXeroDate } from "../../helpers/datetime.js";
5
5
  function paymentFormatter(payment) {
6
6
  return [
7
7
  `Payment ID: ${payment.paymentID || "Unknown"}`,
8
- `Date: ${payment.date || "Unknown date"}`,
8
+ `Date: ${payment.date ? formatXeroDate(payment.date) : "Unknown date"}`,
9
9
  `Amount: ${payment.amount || 0}`,
10
10
  payment.reference ? `Reference: ${payment.reference}` : null,
11
11
  payment.status ? `Status: ${payment.status}` : null,
@@ -1,6 +1,7 @@
1
1
  import { z } from "zod";
2
2
  import { listXeroPayrollEmployeeLeaveTypes } from "../../handlers/list-xero-payroll-employee-leave-types.handler.js";
3
3
  import { CreateXeroTool } from "../../helpers/create-xero-tool.js";
4
+ import { formatXeroDate } from "../../helpers/datetime.js";
4
5
  const ListPayrollEmployeeLeaveTypesTool = CreateXeroTool("list-payroll-employee-leave-types", "List all leave types available for a specific employee in Xero. This shows detailed information about the types of leave an employee can take, including schedule of accrual, leave type name, and entitlement.", {
5
6
  employeeId: z
6
7
  .string()
@@ -45,7 +46,7 @@ const ListPayrollEmployeeLeaveTypesTool = CreateXeroTool("list-payroll-employee-
45
46
  ? `Leave Type ID: ${leaveType.leaveTypeID}`
46
47
  : null,
47
48
  leaveType.scheduleOfAccrualDate
48
- ? `Accrual Date: ${leaveType.scheduleOfAccrualDate}`
49
+ ? `Accrual Date: ${formatXeroDate(leaveType.scheduleOfAccrualDate)}`
49
50
  : null,
50
51
  ]
51
52
  .filter(Boolean)
@@ -1,7 +1,7 @@
1
1
  import { z } from "zod";
2
2
  import { listXeroPayrollEmployeeLeave } from "../../handlers/list-xero-payroll-employee-leave.handler.js";
3
3
  import { CreateXeroTool } from "../../helpers/create-xero-tool.js";
4
- import { formatUtcDatetime } from "../../helpers/datetime.js";
4
+ import { formatUtcDatetime, formatXeroDate } from "../../helpers/datetime.js";
5
5
  const ListPayrollEmployeeLeaveTool = CreateXeroTool("list-payroll-employee-leave", "List all leave records for a specific employee in Xero. This shows all leave transactions including approved, pending, and processed time off. Provide an employee ID to see their leave history.", {
6
6
  employeeId: z.string().describe("The Xero employee ID to fetch leave records for"),
7
7
  }, async ({ employeeId }) => {
@@ -29,8 +29,8 @@ const ListPayrollEmployeeLeaveTool = CreateXeroTool("list-payroll-employee-leave
29
29
  `Leave ID: ${leaveItem.leaveID || "Unknown"}`,
30
30
  `Leave Type: ${leaveItem.leaveTypeID || "Unknown"}`,
31
31
  `Description: ${leaveItem.description || "No description"}`,
32
- leaveItem.startDate ? `Start Date: ${leaveItem.startDate}` : null,
33
- leaveItem.endDate ? `End Date: ${leaveItem.endDate}` : null,
32
+ leaveItem.startDate ? `Start Date: ${formatXeroDate(leaveItem.startDate)}` : null,
33
+ leaveItem.endDate ? `End Date: ${formatXeroDate(leaveItem.endDate)}` : null,
34
34
  leaveItem.periods ? `Periods: ${leaveItem.periods.length || 0}` : null,
35
35
  leaveItem.updatedDateUTC ? `Last Updated: ${formatUtcDatetime(leaveItem.updatedDateUTC)}` : null,
36
36
  ]
@@ -1,6 +1,6 @@
1
1
  import { listXeroPayrollEmployees } from "../../handlers/list-xero-payroll-employees.handler.js";
2
2
  import { CreateXeroTool } from "../../helpers/create-xero-tool.js";
3
- import { formatUtcDatetime } from "../../helpers/datetime.js";
3
+ import { formatUtcDatetime, formatXeroDate } from "../../helpers/datetime.js";
4
4
  const ListPayrollEmployeesTool = CreateXeroTool("list-payroll-employees", `List all payroll employees in Xero.
5
5
  This retrieves comprehensive employee details including names, User IDs, dates of birth, email addresses, gender, phone numbers, start dates, engagement types (Permanent, FixedTerm, or Casual), titles, and when records were last updated.
6
6
  The response presents a complete overview of all staff currently registered in your Xero payroll, with their personal and employment information. If there are many employees, ask the user if they would like to see more detailed information about specific employees before proceeding.`, {}, async () => {
@@ -29,7 +29,7 @@ The response presents a complete overview of all staff currently registered in y
29
29
  employee.email ? `Email: ${employee.email}` : "No email",
30
30
  employee.gender ? `Gender: ${employee.gender}` : null,
31
31
  employee.phoneNumber ? `Phone: ${employee.phoneNumber}` : null,
32
- employee.startDate ? `Start Date: ${employee.startDate}` : null,
32
+ employee.startDate ? `Start Date: ${formatXeroDate(employee.startDate)}` : null,
33
33
  employee.engagementType
34
34
  ? `Engagement Type: ${employee.engagementType}`
35
35
  : "No status", // Permanent, FixedTerm, Casual
@@ -1,6 +1,7 @@
1
1
  import { z } from "zod";
2
2
  import { listXeroPayrollLeavePeriods } from "../../handlers/list-xero-payroll-leave-periods.handler.js";
3
3
  import { CreateXeroTool } from "../../helpers/create-xero-tool.js";
4
+ import { formatXeroDate } from "../../helpers/datetime.js";
4
5
  const ListPayrollLeavePeriodsToolTool = CreateXeroTool("list-payroll-leave-periods", "List all leave periods for a specific employee in Xero. This shows detailed time off periods including start and end dates, period status, payment dates, and leave types. Provide an employee ID to see their leave periods.", {
5
6
  employeeId: z.string().describe("The Xero employee ID to fetch leave periods for"),
6
7
  startDate: z.string().optional().describe("Optional start date in YYYY-MM-DD format"),
@@ -28,8 +29,8 @@ const ListPayrollLeavePeriodsToolTool = CreateXeroTool("list-payroll-leave-perio
28
29
  type: "text",
29
30
  text: [
30
31
  `Period Status: ${period.periodStatus || "Unknown"}`,
31
- period.periodStartDate ? `Start Date: ${period.periodStartDate}` : null,
32
- period.periodEndDate ? `End Date: ${period.periodEndDate}` : null,
32
+ period.periodStartDate ? `Start Date: ${formatXeroDate(period.periodStartDate)}` : null,
33
+ period.periodEndDate ? `End Date: ${formatXeroDate(period.periodEndDate)}` : null,
33
34
  period.numberOfUnits ? `Number of Units: ${period.numberOfUnits}` : null,
34
35
  period.numberOfUnitsTaken ? `Payment Date: ${period.numberOfUnitsTaken}` : null,
35
36
  period.typeOfUnits ? `Payment Date: ${period.typeOfUnits}` : null,
@@ -1,6 +1,6 @@
1
1
  import { listXeroPayrollTimesheets, } from "../../handlers/list-xero-timesheets.handler.js";
2
2
  import { CreateXeroTool } from "../../helpers/create-xero-tool.js";
3
- import { formatUtcDatetime } from "../../helpers/datetime.js";
3
+ import { formatUtcDatetime, formatXeroDate } from "../../helpers/datetime.js";
4
4
  const ListPayrollTimesheetsTool = CreateXeroTool("list-timesheets", `List all payroll timesheets in Xero.
5
5
  This retrieves comprehensive timesheet details including timesheet IDs, employee IDs, start and end dates, total hours, and the last updated date.`, {}, async () => {
6
6
  const response = await listXeroPayrollTimesheets();
@@ -26,8 +26,8 @@ This retrieves comprehensive timesheet details including timesheet IDs, employee
26
26
  text: [
27
27
  `Timesheet ID: ${timesheet.timesheetID}`,
28
28
  `Employee ID: ${timesheet.employeeID}`,
29
- `Start Date: ${timesheet.startDate}`,
30
- `End Date: ${timesheet.endDate}`,
29
+ `Start Date: ${formatXeroDate(timesheet.startDate)}`,
30
+ `End Date: ${formatXeroDate(timesheet.endDate)}`,
31
31
  `Total Hours: ${timesheet.totalHours}`,
32
32
  `Last Updated: ${formatUtcDatetime(timesheet.updatedDateUTC)}`,
33
33
  ]
@@ -1,7 +1,7 @@
1
1
  import { z } from "zod";
2
2
  import { listXeroPrepayments } from "../../handlers/list-xero-prepayments.handler.js";
3
3
  import { CreateXeroTool } from "../../helpers/create-xero-tool.js";
4
- import { formatUtcDatetime } from "../../helpers/datetime.js";
4
+ import { formatUtcDatetime, formatXeroDate } from "../../helpers/datetime.js";
5
5
  const ListPrepaymentsTool = CreateXeroTool("list-prepayments", "List prepayments from Xero. Prepayments are a SEPARATE record type from Payments — " +
6
6
  "they're created when a customer pays before an invoice is raised (or a supplier is paid " +
7
7
  "in advance), and are NOT returned by list-payments. " +
@@ -45,7 +45,7 @@ const ListPrepaymentsTool = CreateXeroTool("list-prepayments", "List prepayments
45
45
  prepayment.contact
46
46
  ? `Contact: ${prepayment.contact.name} (${prepayment.contact.contactID})`
47
47
  : null,
48
- prepayment.date ? `Date: ${prepayment.date}` : null,
48
+ prepayment.date ? `Date: ${formatXeroDate(prepayment.date)}` : null,
49
49
  `Total: ${prepayment.total || 0}`,
50
50
  prepayment.remainingCredit !== undefined
51
51
  ? `Remaining Credit: ${prepayment.remainingCredit}`
@@ -55,7 +55,7 @@ const ListPrepaymentsTool = CreateXeroTool("list-prepayments", "List prepayments
55
55
  : null,
56
56
  prepayment.allocations?.length
57
57
  ? `Allocations:\n${prepayment.allocations
58
- .map((allocation) => ` - ${allocation.amount} on ${allocation.date} → Invoice ${allocation.invoice?.invoiceNumber ?? allocation.invoice?.invoiceID ?? "Unknown"}`)
58
+ .map((allocation) => ` - ${allocation.amount} on ${formatXeroDate(allocation.date)} → Invoice ${allocation.invoice?.invoiceNumber ?? allocation.invoice?.invoiceID ?? "Unknown"}`)
59
59
  .join("\n")}`
60
60
  : null,
61
61
  prepayment.currencyCode
@@ -7,7 +7,8 @@ const ListProfitAndLossTool = CreateXeroTool("list-profit-and-loss", "Lists prof
7
7
  toDate: z.string().optional().describe("Optional end date in YYYY-MM-DD format"),
8
8
  periods: z.number().int().min(1).max(11).optional().describe("Optional number of prior comparison periods (1-11). Xero returns the requested base period plus this many comparisons, so periods=3 returns 4 columns."),
9
9
  timeframe: z.enum(["MONTH", "QUARTER", "YEAR"]).optional().describe("Optional spacing between comparison periods (MONTH, QUARTER, YEAR). It does not split a multi-month fromDate/toDate range into individual columns — " +
10
- "Xero repeats the whole fromDate/toDate span for each comparison. Example: for 4 separate monthly columns, set fromDate/toDate to a single month and periods=3, NOT a 4-month range with periods=3 (which instead returns 4 rolling 4-month totals)."),
10
+ "Xero repeats the whole fromDate/toDate span for each comparison. Example: for 4 separate monthly columns, set fromDate/toDate to a single month and periods=3, NOT a 4-month range with periods=3 (which instead returns 4 rolling 4-month totals). " +
11
+ "If fromDate/toDate covers the CURRENT, still-in-progress month, Xero returns month-to-date actuals (as of today) for that base column, not a projected full month — the prior comparison columns are still full months. To get full-month totals for every column (including the most recent), set toDate to the end of the last fully completed month rather than the current month."),
11
12
  standardLayout: z.boolean().optional().describe("Optional flag to use standard layout"),
12
13
  paymentsOnly: z.boolean().optional().describe("Optional flag to include only accounts with payments"),
13
14
  }, async (args) => {
@@ -1,7 +1,7 @@
1
1
  import { z } from "zod";
2
2
  import { listXeroQuotes } from "../../handlers/list-xero-quotes.handler.js";
3
3
  import { CreateXeroTool } from "../../helpers/create-xero-tool.js";
4
- import { formatUtcDatetime } from "../../helpers/datetime.js";
4
+ import { formatUtcDatetime, formatXeroDate } from "../../helpers/datetime.js";
5
5
  const ListQuotesTool = CreateXeroTool("list-quotes", "List quotes in Xero. Supports filtering by contact, quote number, status, and date range.", {
6
6
  page: z.number().describe("Page number for pagination (starts at 1)."),
7
7
  contactId: z.string().optional().describe("Filter by contact ID."),
@@ -38,9 +38,9 @@ const ListQuotesTool = CreateXeroTool("list-quotes", "List quotes in Xero. Suppo
38
38
  quote.contact
39
39
  ? `Contact: ${quote.contact.name} (${quote.contact.contactID})`
40
40
  : null,
41
- quote.dateString ? `Quote Date: ${quote.dateString}` : null,
41
+ quote.dateString ? `Quote Date: ${formatXeroDate(quote.dateString)}` : null,
42
42
  quote.expiryDateString
43
- ? `Expiry Date: ${quote.expiryDateString}`
43
+ ? `Expiry Date: ${formatXeroDate(quote.expiryDateString)}`
44
44
  : null,
45
45
  quote.title ? `Title: ${quote.title}` : null,
46
46
  quote.summary ? `Summary: ${quote.summary}` : null,
@@ -0,0 +1,46 @@
1
+ import { z } from "zod";
2
+ import { listXeroReportBankSummary } from "../../handlers/list-xero-report-bank-summary.handler.js";
3
+ import { CreateXeroTool } from "../../helpers/create-xero-tool.js";
4
+ import { formatUtcDatetime } from "../../helpers/datetime.js";
5
+ const ListReportBankSummaryTool = CreateXeroTool("list-report-bank-summary", "Lists the Bank Summary report from Xero — opening balance, cash received, cash spent, " +
6
+ "and closing balance per bank account for a date range, computed by Xero itself. " +
7
+ "Use this instead of summing list-bank-transactions to validate or report on account " +
8
+ "movement — it correctly accounts for transfers between accounts and other postings that " +
9
+ "a simple BankTransactions sum can miss.", {
10
+ fromDate: z.string().optional().describe("Start date in YYYY-MM-DD format."),
11
+ toDate: z.string().optional().describe("End date in YYYY-MM-DD format."),
12
+ }, async (args) => {
13
+ const response = await listXeroReportBankSummary(args?.fromDate, args?.toDate);
14
+ if (response.error !== null) {
15
+ return {
16
+ content: [
17
+ {
18
+ type: "text",
19
+ text: `Error listing bank summary: ${response.error}`,
20
+ },
21
+ ],
22
+ };
23
+ }
24
+ const bankSummaryReport = response.result;
25
+ return {
26
+ content: [
27
+ {
28
+ type: "text",
29
+ text: `Bank Summary Report: ${bankSummaryReport?.reportName || "Unnamed"}`,
30
+ },
31
+ {
32
+ type: "text",
33
+ text: `Date: ${bankSummaryReport?.reportDate || "Not specified"}`,
34
+ },
35
+ {
36
+ type: "text",
37
+ text: `Updated At: ${bankSummaryReport?.updatedDateUTC ? formatUtcDatetime(bankSummaryReport.updatedDateUTC) : "Unknown"}`,
38
+ },
39
+ {
40
+ type: "text",
41
+ text: JSON.stringify(bankSummaryReport?.rows, null, 2),
42
+ },
43
+ ],
44
+ };
45
+ });
46
+ export default ListReportBankSummaryTool;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@teamnetwork-nz/xero-mcp-server",
3
- "version": "1.11.0",
3
+ "version": "1.13.1",
4
4
  "description": "MCP server implementation for Xero integration - TEAMnetwork",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",