@mindstone/mcp-server-xero 0.0.17 → 0.1.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 (80) hide show
  1. package/README.md +46 -0
  2. package/dist/clients/xero-client.js +2 -3
  3. package/dist/handlers/create-xero-purchase-order.handler.js +50 -0
  4. package/dist/handlers/email-xero-invoice.handler.js +27 -0
  5. package/dist/handlers/list-xero-bank-summary.handler.js +38 -0
  6. package/dist/handlers/list-xero-budget-summary.handler.js +45 -0
  7. package/dist/handlers/list-xero-executive-summary.handler.js +37 -0
  8. package/dist/handlers/list-xero-purchase-orders.handler.js +29 -0
  9. package/dist/helpers/create-xero-tool.js +32 -1
  10. package/dist/helpers/get-deeplink.js +15 -4
  11. package/dist/helpers/xero-currencies.js +1 -1
  12. package/dist/server/xero-mcp-server.js +2 -1
  13. package/dist/tools/create/create-bank-transaction.tool.js +2 -1
  14. package/dist/tools/create/create-contact.tool.js +4 -3
  15. package/dist/tools/create/create-credit-note.tool.js +1 -0
  16. package/dist/tools/create/create-invoice.tool.js +1 -0
  17. package/dist/tools/create/create-item.tool.js +1 -0
  18. package/dist/tools/create/create-manual-journal.tool.js +4 -3
  19. package/dist/tools/create/create-payment.tool.js +1 -0
  20. package/dist/tools/create/create-payroll-timesheet.tool.js +1 -0
  21. package/dist/tools/create/create-purchase-order.tool.js +67 -0
  22. package/dist/tools/create/create-quote.tool.js +1 -0
  23. package/dist/tools/create/create-tracking-category.tool.js +2 -1
  24. package/dist/tools/create/create-tracking-options.tool.js +2 -1
  25. package/dist/tools/create/index.js +3 -1
  26. package/dist/tools/delete/delete-payroll-timesheet.tool.js +1 -0
  27. package/dist/tools/get/get-invoice-attachment.tool.js +1 -0
  28. package/dist/tools/get/get-payroll-timesheet.tool.js +1 -0
  29. package/dist/tools/history/index.js +2 -0
  30. package/dist/tools/list/index.js +9 -1
  31. package/dist/tools/list/list-accounts.tool.js +1 -0
  32. package/dist/tools/list/list-aged-payables-by-contact.tool.js +1 -0
  33. package/dist/tools/list/list-aged-receivables-by-contact.tool.js +1 -0
  34. package/dist/tools/list/list-bank-summary.tool.js +42 -0
  35. package/dist/tools/list/list-bank-transactions.tool.js +2 -1
  36. package/dist/tools/list/list-budget-summary.tool.js +48 -0
  37. package/dist/tools/list/list-contact-groups.tool.js +1 -0
  38. package/dist/tools/list/list-contacts.tool.js +1 -0
  39. package/dist/tools/list/list-credit-notes.tool.js +1 -0
  40. package/dist/tools/list/list-currencies.tool.js +1 -0
  41. package/dist/tools/list/list-executive-summary.tool.js +37 -0
  42. package/dist/tools/list/list-invoice-attachments.tool.js +1 -0
  43. package/dist/tools/list/list-invoices.tool.js +1 -0
  44. package/dist/tools/list/list-items.tool.js +1 -0
  45. package/dist/tools/list/list-manual-journals.tool.js +1 -0
  46. package/dist/tools/list/list-organisation-details.tool.js +1 -0
  47. package/dist/tools/list/list-payments.tool.js +1 -0
  48. package/dist/tools/list/list-payroll-employee-leave-balances.tool.js +1 -0
  49. package/dist/tools/list/list-payroll-employee-leave-types.tool.js +1 -0
  50. package/dist/tools/list/list-payroll-employee-leave.tool.js +1 -0
  51. package/dist/tools/list/list-payroll-employees.tool.js +1 -0
  52. package/dist/tools/list/list-payroll-leave-periods.tool.js +1 -0
  53. package/dist/tools/list/list-payroll-leave-types.tool.js +1 -0
  54. package/dist/tools/list/list-payroll-timesheets.tool.js +1 -0
  55. package/dist/tools/list/list-profit-and-loss.tool.js +1 -0
  56. package/dist/tools/list/list-purchase-orders.tool.js +98 -0
  57. package/dist/tools/list/list-quotes.tool.js +1 -0
  58. package/dist/tools/list/list-report-balance-sheet.tool.js +1 -0
  59. package/dist/tools/list/list-tax-rates.tool.js +1 -0
  60. package/dist/tools/list/list-tracking-categories.tool.js +2 -1
  61. package/dist/tools/list/list-trial-balance.tool.js +1 -0
  62. package/dist/tools/tool-factory.js +4 -1
  63. package/dist/tools/update/approve-payroll-timesheet.tool.js +1 -0
  64. package/dist/tools/update/email-invoice.tool.js +30 -0
  65. package/dist/tools/update/index.js +3 -1
  66. package/dist/tools/update/revert-payroll-timesheet.tool.js +1 -0
  67. package/dist/tools/update/update-bank-transaction.tool.js +1 -0
  68. package/dist/tools/update/update-contact.tool.js +4 -3
  69. package/dist/tools/update/update-credit-note.tool.js +1 -0
  70. package/dist/tools/update/update-invoice.tool.js +1 -0
  71. package/dist/tools/update/update-item.tool.js +1 -0
  72. package/dist/tools/update/update-manual-journal-tool.js +4 -3
  73. package/dist/tools/update/update-payroll-timesheet-add-line.tool.js +1 -0
  74. package/dist/tools/update/update-payroll-timesheet-update-line.tool.js +1 -0
  75. package/dist/tools/update/update-quote.tool.js +1 -0
  76. package/dist/tools/update/update-tracking-category.tool.js +2 -1
  77. package/dist/tools/update/update-tracking-options.tool.js +2 -1
  78. package/dist/untrusted-content.js +130 -0
  79. package/package.json +2 -2
  80. package/dist/helpers/ensure-error.js +0 -13
@@ -14,7 +14,8 @@ const CreateTrackingOptionsTool = CreateXeroTool("create-tracking-options", `Cre
14
14
  type: "text",
15
15
  text: `Error while creating tracking options: ${response.error}`
16
16
  }
17
- ]
17
+ ],
18
+ isError: true,
18
19
  };
19
20
  }
20
21
  const trackingOptions = response.result;
@@ -5,6 +5,7 @@ import CreateInvoiceTool from "./create-invoice.tool.js";
5
5
  import CreateItemTool from "./create-item.tool.js";
6
6
  import CreateManualJournalTool from "./create-manual-journal.tool.js";
7
7
  import CreatePaymentTool from "./create-payment.tool.js";
8
+ import CreatePurchaseOrderTool from "./create-purchase-order.tool.js";
8
9
  import CreatePayrollTimesheetTool from "./create-payroll-timesheet.tool.js";
9
10
  import CreateQuoteTool from "./create-quote.tool.js";
10
11
  import CreateTrackingCategoryTool from "./create-tracking-category.tool.js";
@@ -20,5 +21,6 @@ export const CreateTools = [
20
21
  CreateBankTransactionTool,
21
22
  CreatePayrollTimesheetTool,
22
23
  CreateTrackingCategoryTool,
23
- CreateTrackingOptionsTool
24
+ CreateTrackingOptionsTool,
25
+ CreatePurchaseOrderTool
24
26
  ];
@@ -14,6 +14,7 @@ const DeletePayrollTimesheetTool = CreateXeroTool("delete-timesheet", `Delete an
14
14
  text: `Error deleting timesheet: ${response.error}`,
15
15
  },
16
16
  ],
17
+ isError: true,
17
18
  };
18
19
  }
19
20
  return {
@@ -23,6 +23,7 @@ Requires the accounting.attachments.read scope on the Xero Custom Connection.`,
23
23
  text: `Error downloading attachment: ${response.error}`,
24
24
  },
25
25
  ],
26
+ isError: true,
26
27
  };
27
28
  }
28
29
  const result = response.result;
@@ -15,6 +15,7 @@ This provides details such as the timesheet ID, employee ID, start and end dates
15
15
  text: `Error retrieving timesheet: ${response.error}`,
16
16
  },
17
17
  ],
18
+ isError: true,
18
19
  };
19
20
  }
20
21
  const timesheet = response.result;
@@ -73,6 +73,7 @@ function createGetHistoryTool(def) {
73
73
  text: `Error retrieving ${def.entity} history: ${response.error}`,
74
74
  },
75
75
  ],
76
+ isError: true,
76
77
  };
77
78
  }
78
79
  const records = response.result;
@@ -115,6 +116,7 @@ function createAddNoteTool(def) {
115
116
  text: `Error adding note to ${def.entity}: ${response.error}`,
116
117
  },
117
118
  ],
119
+ isError: true,
118
120
  };
119
121
  }
120
122
  const record = response.result;
@@ -1,7 +1,9 @@
1
1
  import ListAccountsTool from "./list-accounts.tool.js";
2
2
  import ListAgedPayablesByContact from "./list-aged-payables-by-contact.tool.js";
3
3
  import ListAgedReceivablesByContact from "./list-aged-receivables-by-contact.tool.js";
4
+ import ListBankSummaryTool from "./list-bank-summary.tool.js";
4
5
  import ListBankTransactionsTool from "./list-bank-transactions.tool.js";
6
+ import ListBudgetSummaryTool from "./list-budget-summary.tool.js";
5
7
  import ListContactsTool from "./list-contacts.tool.js";
6
8
  import ListCreditNotesTool from "./list-credit-notes.tool.js";
7
9
  import ListCurrenciesTool from "./list-currencies.tool.js";
@@ -10,6 +12,7 @@ import ListItemsTool from "./list-items.tool.js";
10
12
  import ListManualJournalsTool from "./list-manual-journals.tool.js";
11
13
  import ListOrganisationDetailsTool from "./list-organisation-details.tool.js";
12
14
  import ListPaymentsTool from "./list-payments.tool.js";
15
+ import ListPurchaseOrdersTool from "./list-purchase-orders.tool.js";
13
16
  import ListPayrollEmployeeLeaveBalancesTool from "./list-payroll-employee-leave-balances.tool.js";
14
17
  import ListPayrollEmployeeLeaveTypesTool from "./list-payroll-employee-leave-types.tool.js";
15
18
  import ListPayrollEmployeeLeaveTool from "./list-payroll-employee-leave.tool.js";
@@ -25,6 +28,7 @@ import ListTrackingCategoriesTool from "./list-tracking-categories.tool.js";
25
28
  import ListTrialBalanceTool from "./list-trial-balance.tool.js";
26
29
  import ListContactGroupsTool from "./list-contact-groups.tool.js";
27
30
  import ListInvoiceAttachmentsTool from "./list-invoice-attachments.tool.js";
31
+ import ListExecutiveSummaryTool from "./list-executive-summary.tool.js";
28
32
  export const ListTools = [
29
33
  ListAccountsTool,
30
34
  ListContactsTool,
@@ -52,5 +56,9 @@ export const ListTools = [
52
56
  ListPayrollTimesheetsTool,
53
57
  ListContactGroupsTool,
54
58
  ListTrackingCategoriesTool,
55
- ListInvoiceAttachmentsTool
59
+ ListInvoiceAttachmentsTool,
60
+ ListBankSummaryTool,
61
+ ListBudgetSummaryTool,
62
+ ListExecutiveSummaryTool,
63
+ ListPurchaseOrdersTool
56
64
  ];
@@ -10,6 +10,7 @@ const ListAccountsTool = CreateXeroTool("list-accounts", "Lists all accounts in
10
10
  text: `Error listing accounts: ${response.error}`,
11
11
  },
12
12
  ],
13
+ isError: true,
13
14
  };
14
15
  }
15
16
  const accounts = response.result;
@@ -21,6 +21,7 @@ const ListAgedPayablesByContact = CreateXeroTool("list-aged-payables-by-contact"
21
21
  text: `Error listing aged payables by contact: ${response.error}`,
22
22
  },
23
23
  ],
24
+ isError: true,
24
25
  };
25
26
  }
26
27
  const agedPayablesReport = response.result;
@@ -21,6 +21,7 @@ const ListAgedReceivablesByContact = CreateXeroTool("list-aged-receivables-by-co
21
21
  text: `Error listing aged receivables by contact: ${response.error}`,
22
22
  },
23
23
  ],
24
+ isError: true,
24
25
  };
25
26
  }
26
27
  const agedReceivablesReport = response.result;
@@ -0,0 +1,42 @@
1
+ import { z } from "zod";
2
+ import { listXeroBankSummary } from "../../handlers/list-xero-bank-summary.handler.js";
3
+ import { CreateXeroTool } from "../../helpers/create-xero-tool.js";
4
+ const ListBankSummaryTool = CreateXeroTool("list-bank-summary", "Get the bank summary report from Xero: opening and closing balances plus total money in/out per bank account over a period. Useful for cash-position questions.", {
5
+ fromDate: z
6
+ .string()
7
+ .regex(/^\d{4}-\d{2}-\d{2}$/, "Must be YYYY-MM-DD format")
8
+ .optional()
9
+ .describe("Optional start date of the report period (YYYY-MM-DD)"),
10
+ toDate: z
11
+ .string()
12
+ .regex(/^\d{4}-\d{2}-\d{2}$/, "Must be YYYY-MM-DD format")
13
+ .optional()
14
+ .describe("Optional end date of the report period (YYYY-MM-DD)"),
15
+ }, async ({ fromDate, toDate }) => {
16
+ const response = await listXeroBankSummary(fromDate, toDate);
17
+ if (response.error !== null) {
18
+ return {
19
+ content: [
20
+ {
21
+ type: "text",
22
+ text: `Error getting bank summary report: ${response.error}`,
23
+ },
24
+ ],
25
+ isError: true,
26
+ };
27
+ }
28
+ const report = response.result;
29
+ return {
30
+ content: [
31
+ {
32
+ type: "text",
33
+ text: `Bank Summary Report: ${report?.reportName ?? "Unnamed"}`,
34
+ },
35
+ {
36
+ type: "text",
37
+ text: JSON.stringify(report.rows, null, 2),
38
+ },
39
+ ],
40
+ };
41
+ });
42
+ export default ListBankSummaryTool;
@@ -24,7 +24,8 @@ COMMON MISTAKES:
24
24
  type: "text",
25
25
  text: `Error listing bank transactions: ${response.error}`
26
26
  }
27
- ]
27
+ ],
28
+ isError: true,
28
29
  };
29
30
  }
30
31
  const bankTransactions = response.result;
@@ -0,0 +1,48 @@
1
+ import { z } from "zod";
2
+ import { listXeroBudgetSummary } from "../../handlers/list-xero-budget-summary.handler.js";
3
+ import { CreateXeroTool } from "../../helpers/create-xero-tool.js";
4
+ const ListBudgetSummaryTool = CreateXeroTool("list-budget-summary", "Get the budget summary report from Xero: budgeted vs actual figures per account. Useful for 'are we tracking to budget?' questions. Requires budgets to be set up in the Xero organisation.", {
5
+ date: z
6
+ .string()
7
+ .regex(/^\d{4}-\d{2}-\d{2}$/, "Must be YYYY-MM-DD format")
8
+ .optional()
9
+ .describe("Optional date for the report (YYYY-MM-DD)"),
10
+ periods: z
11
+ .number()
12
+ .int()
13
+ .min(1)
14
+ .max(12)
15
+ .optional()
16
+ .describe("Optional number of periods to compare (1-12)"),
17
+ timeframe: z
18
+ .enum(["MONTH", "QUARTER", "YEAR"])
19
+ .optional()
20
+ .describe("Optional period size to compare (MONTH, QUARTER, YEAR)"),
21
+ }, async ({ date, periods, timeframe }) => {
22
+ const response = await listXeroBudgetSummary(date, periods, timeframe);
23
+ if (response.error !== null) {
24
+ return {
25
+ content: [
26
+ {
27
+ type: "text",
28
+ text: `Error getting budget summary report: ${response.error}`,
29
+ },
30
+ ],
31
+ isError: true,
32
+ };
33
+ }
34
+ const report = response.result;
35
+ return {
36
+ content: [
37
+ {
38
+ type: "text",
39
+ text: `Budget Summary Report: ${report?.reportName ?? "Unnamed"}`,
40
+ },
41
+ {
42
+ type: "text",
43
+ text: JSON.stringify(report.rows, null, 2),
44
+ },
45
+ ],
46
+ };
47
+ });
48
+ export default ListBudgetSummaryTool;
@@ -17,6 +17,7 @@ const ListContactGroupsTool = CreateXeroTool("list-contact-groups", `List all co
17
17
  text: `Error listing contact groups: ${response.error}`,
18
18
  },
19
19
  ],
20
+ isError: true,
20
21
  };
21
22
  }
22
23
  const contactGroups = response.result;
@@ -17,6 +17,7 @@ const ListContactsTool = CreateXeroTool("list-contacts", "List all contacts in X
17
17
  text: `Error listing contacts: ${response.error}`,
18
18
  },
19
19
  ],
20
+ isError: true,
20
21
  };
21
22
  }
22
23
  const contacts = response.result;
@@ -24,6 +24,7 @@ COMMON MISTAKES:
24
24
  text: `Error listing credit notes: ${response.error}`,
25
25
  },
26
26
  ],
27
+ isError: true,
27
28
  };
28
29
  }
29
30
  const creditNotes = response.result;
@@ -10,6 +10,7 @@ const ListCurrenciesTool = CreateXeroTool("list-currencies", "Lists currencies e
10
10
  text: `Error listing currencies: ${response.error}`,
11
11
  },
12
12
  ],
13
+ isError: true,
13
14
  };
14
15
  }
15
16
  const currencies = response.result;
@@ -0,0 +1,37 @@
1
+ import { z } from "zod";
2
+ import { listXeroExecutiveSummary } from "../../handlers/list-xero-executive-summary.handler.js";
3
+ import { CreateXeroTool } from "../../helpers/create-xero-tool.js";
4
+ const ListExecutiveSummaryTool = CreateXeroTool("list-executive-summary", "Get the executive summary report from Xero: a high-level snapshot of key financial metrics (cash, debtors, creditors, revenue, profit) for a date. Useful for 'how is the business doing?' questions.", {
5
+ date: z
6
+ .string()
7
+ .regex(/^\d{4}-\d{2}-\d{2}$/, "Must be YYYY-MM-DD format")
8
+ .optional()
9
+ .describe("Optional date for the report (YYYY-MM-DD)"),
10
+ }, async ({ date }) => {
11
+ const response = await listXeroExecutiveSummary(date);
12
+ if (response.error !== null) {
13
+ return {
14
+ content: [
15
+ {
16
+ type: "text",
17
+ text: `Error getting executive summary report: ${response.error}`,
18
+ },
19
+ ],
20
+ isError: true,
21
+ };
22
+ }
23
+ const report = response.result;
24
+ return {
25
+ content: [
26
+ {
27
+ type: "text",
28
+ text: `Executive Summary Report: ${report?.reportName ?? "Unnamed"}`,
29
+ },
30
+ {
31
+ type: "text",
32
+ text: JSON.stringify(report.rows, null, 2),
33
+ },
34
+ ],
35
+ };
36
+ });
37
+ export default ListExecutiveSummaryTool;
@@ -16,6 +16,7 @@ const ListInvoiceAttachmentsTool = CreateXeroTool("list-invoice-attachments", "L
16
16
  text: `Error listing invoice attachments: ${response.error}`,
17
17
  },
18
18
  ],
19
+ isError: true,
19
20
  };
20
21
  }
21
22
  const attachments = response.result;
@@ -75,6 +75,7 @@ COMMON MISTAKES:
75
75
  text: `Error listing invoices: ${response.error}`,
76
76
  },
77
77
  ],
78
+ isError: true,
78
79
  };
79
80
  }
80
81
  const invoices = response.result;
@@ -17,6 +17,7 @@ COMMON MISTAKES:
17
17
  text: `Error listing items: ${response.error}`,
18
18
  },
19
19
  ],
20
+ isError: true,
20
21
  };
21
22
  }
22
23
  const items = response.result;
@@ -31,6 +31,7 @@ COMMON MISTAKES:
31
31
  text: `Error listing manual journals: ${response.error}`,
32
32
  },
33
33
  ],
34
+ isError: true,
34
35
  };
35
36
  }
36
37
  const manualJournals = response.result;
@@ -11,6 +11,7 @@ const ListOrganisationDetailsTool = CreateXeroTool("list-organisation-details",
11
11
  text: `Error fetching organisation details: ${response.error || "Unknown error"}`,
12
12
  },
13
13
  ],
14
+ isError: true,
14
15
  };
15
16
  }
16
17
  const organisation = response.result;
@@ -65,6 +65,7 @@ COMMON MISTAKES:
65
65
  text: `Error listing payments: ${response.error}`,
66
66
  },
67
67
  ],
68
+ isError: true,
68
69
  };
69
70
  }
70
71
  const payments = response.result;
@@ -13,6 +13,7 @@ const ListPayrollEmployeeLeaveBalancesTool = CreateXeroTool("list-payroll-employ
13
13
  text: `Error listing employee leave balances: ${response.error}`,
14
14
  },
15
15
  ],
16
+ isError: true,
16
17
  };
17
18
  }
18
19
  const leaveBalances = response.result;
@@ -15,6 +15,7 @@ const ListPayrollEmployeeLeaveTypesTool = CreateXeroTool("list-payroll-employee-
15
15
  text: `Error listing employee leave types: ${response.error}`,
16
16
  },
17
17
  ],
18
+ isError: true,
18
19
  };
19
20
  }
20
21
  const leaveTypes = response.result;
@@ -13,6 +13,7 @@ const ListPayrollEmployeeLeaveTool = CreateXeroTool("list-payroll-employee-leave
13
13
  text: `Error listing employee leave: ${response.error}`,
14
14
  },
15
15
  ],
16
+ isError: true,
16
17
  };
17
18
  }
18
19
  const leave = response.result;
@@ -12,6 +12,7 @@ The response presents a complete overview of all staff currently registered in y
12
12
  text: `Error listing payroll employees: ${response.error}`,
13
13
  },
14
14
  ],
15
+ isError: true,
15
16
  };
16
17
  }
17
18
  const employees = response.result;
@@ -15,6 +15,7 @@ const ListPayrollLeavePeriodsToolTool = CreateXeroTool("list-payroll-leave-perio
15
15
  text: `Error listing employee leave periods: ${response.error}`,
16
16
  },
17
17
  ],
18
+ isError: true,
18
19
  };
19
20
  }
20
21
  const periods = response.result;
@@ -10,6 +10,7 @@ const ListPayrollLeaveTypesTool = CreateXeroTool("list-payroll-leave-types", "Li
10
10
  text: `Error listing payroll leave types: ${response.error}`,
11
11
  },
12
12
  ],
13
+ isError: true,
13
14
  };
14
15
  }
15
16
  const leaveTypes = response.result;
@@ -11,6 +11,7 @@ This retrieves comprehensive timesheet details including timesheet IDs, employee
11
11
  text: `Error listing timesheets: ${response.error}`,
12
12
  },
13
13
  ],
14
+ isError: true,
14
15
  };
15
16
  }
16
17
  const timesheets = response.result;
@@ -18,6 +18,7 @@ const ListProfitAndLossTool = CreateXeroTool("list-profit-and-loss", "Lists prof
18
18
  text: `Error listing profit and loss report: ${response.error}`,
19
19
  },
20
20
  ],
21
+ isError: true,
21
22
  };
22
23
  }
23
24
  const profitAndLossReport = response.result;
@@ -0,0 +1,98 @@
1
+ import { z } from "zod";
2
+ import { listXeroPurchaseOrders } from "../../handlers/list-xero-purchase-orders.handler.js";
3
+ import { CreateXeroTool } from "../../helpers/create-xero-tool.js";
4
+ const ListPurchaseOrdersTool = CreateXeroTool("list-purchase-orders", `List purchase orders in Xero. Returns up to pageSize results per page (default 100, max 100).
5
+
6
+ FILTERING: Use status to filter (DRAFT, SUBMITTED, AUTHORISED, BILLED, DELETED). Use dateFrom/dateTo for date ranges (YYYY-MM-DD).
7
+
8
+ PAGINATION: If results returned equals pageSize, there may be more pages. Call again with page+1.`, {
9
+ page: z
10
+ .number()
11
+ .int()
12
+ .min(1)
13
+ .optional()
14
+ .describe("Page number (1-based). If results equal pageSize, there may be more pages."),
15
+ status: z
16
+ .enum(["DRAFT", "SUBMITTED", "AUTHORISED", "BILLED", "DELETED"])
17
+ .optional()
18
+ .describe("Filter by purchase order status"),
19
+ dateFrom: z
20
+ .string()
21
+ .regex(/^\d{4}-\d{2}-\d{2}$/, "Must be YYYY-MM-DD format")
22
+ .optional()
23
+ .describe("Only purchase orders on or after this date (YYYY-MM-DD)"),
24
+ dateTo: z
25
+ .string()
26
+ .regex(/^\d{4}-\d{2}-\d{2}$/, "Must be YYYY-MM-DD format")
27
+ .optional()
28
+ .describe("Only purchase orders on or before this date (YYYY-MM-DD)"),
29
+ orderBy: z
30
+ .enum(["Date", "DeliveryDate", "PurchaseOrderNumber"])
31
+ .optional()
32
+ .describe("Sort field. Default: Xero's default order"),
33
+ orderDirection: z
34
+ .enum(["ASC", "DESC"])
35
+ .optional()
36
+ .describe("Sort direction. Only applied when orderBy is set"),
37
+ pageSize: z
38
+ .number()
39
+ .int()
40
+ .min(1)
41
+ .max(100)
42
+ .optional()
43
+ .describe("Results per page (default 100, max 100)"),
44
+ }, async ({ page, status, dateFrom, dateTo, orderBy, orderDirection, pageSize }) => {
45
+ const order = orderBy
46
+ ? `${orderBy} ${orderDirection ?? "ASC"}`
47
+ : undefined;
48
+ const response = await listXeroPurchaseOrders(page ?? 1, status, dateFrom, dateTo, order, pageSize);
49
+ if (response.error !== null) {
50
+ return {
51
+ content: [
52
+ {
53
+ type: "text",
54
+ text: `Error listing purchase orders: ${response.error}`,
55
+ },
56
+ ],
57
+ isError: true,
58
+ };
59
+ }
60
+ const purchaseOrders = response.result;
61
+ const effectivePageSize = pageSize ?? 100;
62
+ const count = purchaseOrders?.length ?? 0;
63
+ return {
64
+ content: [
65
+ {
66
+ type: "text",
67
+ text: count === effectivePageSize
68
+ ? `Found ${count} purchase orders. The number of results equals pageSize (${effectivePageSize}), so there may be more pages.`
69
+ : `Found ${count} purchase orders:`,
70
+ },
71
+ ...(purchaseOrders?.map((purchaseOrder) => ({
72
+ type: "text",
73
+ text: [
74
+ `Purchase Order ID: ${purchaseOrder.purchaseOrderID}`,
75
+ `Purchase Order: ${purchaseOrder.purchaseOrderNumber}`,
76
+ purchaseOrder.reference
77
+ ? `Reference: ${purchaseOrder.reference}`
78
+ : null,
79
+ `Status: ${purchaseOrder.status || "Unknown"}`,
80
+ purchaseOrder.contact
81
+ ? `Contact: ${purchaseOrder.contact.name} (${purchaseOrder.contact.contactID})`
82
+ : null,
83
+ purchaseOrder.date ? `Date: ${purchaseOrder.date}` : null,
84
+ purchaseOrder.deliveryDate
85
+ ? `Delivery Date: ${purchaseOrder.deliveryDate}`
86
+ : null,
87
+ purchaseOrder.currencyCode
88
+ ? `Currency: ${purchaseOrder.currencyCode}`
89
+ : null,
90
+ `Total: ${purchaseOrder.total || 0}`,
91
+ ]
92
+ .filter(Boolean)
93
+ .join("\n"),
94
+ })) || []),
95
+ ],
96
+ };
97
+ });
98
+ export default ListPurchaseOrdersTool;
@@ -22,6 +22,7 @@ COMMON MISTAKES:
22
22
  text: `Error listing quotes: ${response.error}`,
23
23
  },
24
24
  ],
25
+ isError: true,
25
26
  };
26
27
  }
27
28
  const quotes = response.result;
@@ -20,6 +20,7 @@ const ListReportBalanceSheetTool = CreateXeroTool("list-report-balance-sheet", "
20
20
  text: `Error listing balance sheet report: ${response.error}`,
21
21
  },
22
22
  ],
23
+ isError: true,
23
24
  };
24
25
  }
25
26
  const balanceSheetReport = response.result;
@@ -10,6 +10,7 @@ const ListTaxRatesTool = CreateXeroTool("list-tax-rates", "Lists all tax rates i
10
10
  text: `Error listing tax rates: ${response.error}`,
11
11
  },
12
12
  ],
13
+ isError: true,
13
14
  };
14
15
  }
15
16
  const taxRates = response.result;
@@ -14,7 +14,8 @@ const ListTrackingCategoriesTool = CreateXeroTool("list-tracking-categories", "L
14
14
  type: "text",
15
15
  text: `Error listing tracking categories: ${response.error}`
16
16
  }
17
- ]
17
+ ],
18
+ isError: true,
18
19
  };
19
20
  }
20
21
  const trackingCategories = response.result;
@@ -14,6 +14,7 @@ const ListTrialBalanceTool = CreateXeroTool("list-trial-balance", "Lists trial b
14
14
  text: `Error listing trial balance: ${response.error}`,
15
15
  },
16
16
  ],
17
+ isError: true,
17
18
  };
18
19
  }
19
20
  const trialBalanceReport = response.result;
@@ -18,7 +18,10 @@ export function ToolFactory(server) {
18
18
  DeleteTools.map((tool) => tool()).forEach((tool) => server.tool(tool.name, tool.description, tool.schema, WRITE_ANNOTATIONS, tool.handler));
19
19
  GetTools.map((tool) => tool()).forEach((tool) => server.tool(tool.name, tool.description, tool.schema, READ_ONLY_ANNOTATIONS, tool.handler));
20
20
  CreateTools.map((tool) => tool()).forEach((tool) => server.tool(tool.name, tool.description, tool.schema, WRITE_ANNOTATIONS, tool.handler));
21
- HistoryTools.map((tool) => tool()).forEach((tool) => server.tool(tool.name, tool.description, tool.schema, tool.name.startsWith("get-") ? READ_ONLY_ANNOTATIONS : WRITE_ANNOTATIONS, tool.handler));
21
+ HistoryTools.map((tool) => tool()).forEach((tool) => {
22
+ const isReadOnly = tool.name.startsWith("get-");
23
+ server.tool(tool.name, tool.description, tool.schema, isReadOnly ? READ_ONLY_ANNOTATIONS : WRITE_ANNOTATIONS, tool.handler);
24
+ });
22
25
  ListTools.map((tool) => tool()).forEach((tool) => server.tool(tool.name, tool.description, tool.schema, READ_ONLY_ANNOTATIONS, tool.handler));
23
26
  UpdateTools.map((tool) => tool()).forEach((tool) => server.tool(tool.name, tool.description, tool.schema, WRITE_ANNOTATIONS, tool.handler));
24
27
  }
@@ -14,6 +14,7 @@ const ApprovePayrollTimesheetTool = CreateXeroTool("approve-timesheet", `Approve
14
14
  text: `Error approving timesheet: ${response.error}`,
15
15
  },
16
16
  ],
17
+ isError: true,
17
18
  };
18
19
  }
19
20
  const timesheet = response.result;
@@ -0,0 +1,30 @@
1
+ import { z } from "zod";
2
+ import { emailXeroInvoice } from "../../handlers/email-xero-invoice.handler.js";
3
+ import { CreateXeroTool } from "../../helpers/create-xero-tool.js";
4
+ const EmailInvoiceTool = CreateXeroTool("email-invoice", "Email a copy of an invoice to its related contact via Xero. The invoice must be AUTHORISED — Xero rejects emails for DRAFT or SUBMITTED invoices. Use list-invoices to find the invoice ID.", {
5
+ invoiceId: z
6
+ .string()
7
+ .describe("The Xero invoice ID (UUID) of the AUTHORISED invoice to email"),
8
+ }, async ({ invoiceId }) => {
9
+ const response = await emailXeroInvoice(invoiceId);
10
+ if (response.error !== null) {
11
+ return {
12
+ content: [
13
+ {
14
+ type: "text",
15
+ text: `Error emailing invoice: ${response.error}`,
16
+ },
17
+ ],
18
+ isError: true,
19
+ };
20
+ }
21
+ return {
22
+ content: [
23
+ {
24
+ type: "text",
25
+ text: `Invoice ${invoiceId} was emailed to its related contact.`,
26
+ },
27
+ ],
28
+ };
29
+ });
30
+ export default EmailInvoiceTool;