@teamnetwork-nz/xero-mcp-server 1.6.0

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 (154) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +282 -0
  3. package/dist/clients/xero-client.js +141 -0
  4. package/dist/consts/deeplinks.js +24 -0
  5. package/dist/handlers/approve-xero-payroll-timesheet.handler.js +28 -0
  6. package/dist/handlers/archive-xero-contact.handler.js +28 -0
  7. package/dist/handlers/authorise-xero-invoice.handler.js +34 -0
  8. package/dist/handlers/convert-xero-quote-to-invoice.handler.js +50 -0
  9. package/dist/handlers/create-xero-bank-transaction.handler.js +51 -0
  10. package/dist/handlers/create-xero-contact.handler.js +49 -0
  11. package/dist/handlers/create-xero-credit-note.handler.js +50 -0
  12. package/dist/handlers/create-xero-invoice.handler.js +53 -0
  13. package/dist/handlers/create-xero-item.handler.js +59 -0
  14. package/dist/handlers/create-xero-manual-journal.handler.js +57 -0
  15. package/dist/handlers/create-xero-payment.handler.js +50 -0
  16. package/dist/handlers/create-xero-payroll-timesheet.handler.js +28 -0
  17. package/dist/handlers/create-xero-quote.handler.js +53 -0
  18. package/dist/handlers/create-xero-tracking-category.handler.js +35 -0
  19. package/dist/handlers/create-xero-tracking-option.handler.js +31 -0
  20. package/dist/handlers/delete-xero-invoice-attachment.handler.js +30 -0
  21. package/dist/handlers/delete-xero-payroll-timesheet.handler.js +28 -0
  22. package/dist/handlers/download-xero-invoice-attachment.handler.js +23 -0
  23. package/dist/handlers/download-xero-invoice-pdf.handler.js +25 -0
  24. package/dist/handlers/get-xero-invoice.handler.js +19 -0
  25. package/dist/handlers/get-xero-payroll-timesheet.handler.js +28 -0
  26. package/dist/handlers/list-aged-payables-by-contact.handler.js +37 -0
  27. package/dist/handlers/list-aged-receivables-by-contact.handler.js +37 -0
  28. package/dist/handlers/list-xero-accounts.handler.js +32 -0
  29. package/dist/handlers/list-xero-bank-transactions.handler.js +39 -0
  30. package/dist/handlers/list-xero-contact-groups.handler.js +34 -0
  31. package/dist/handlers/list-xero-contacts.handler.js +47 -0
  32. package/dist/handlers/list-xero-credit-notes.handler.js +42 -0
  33. package/dist/handlers/list-xero-invoice-attachments.handler.js +20 -0
  34. package/dist/handlers/list-xero-invoices.handler.js +54 -0
  35. package/dist/handlers/list-xero-items.handler.js +32 -0
  36. package/dist/handlers/list-xero-manual-journals.handler.js +33 -0
  37. package/dist/handlers/list-xero-organisation-details.handler.js +32 -0
  38. package/dist/handlers/list-xero-payments.handler.js +52 -0
  39. package/dist/handlers/list-xero-payroll-employee-leave-balances.handler.js +42 -0
  40. package/dist/handlers/list-xero-payroll-employee-leave-types.handler.js +42 -0
  41. package/dist/handlers/list-xero-payroll-employee-leave.handler.js +44 -0
  42. package/dist/handlers/list-xero-payroll-employees.handler.js +31 -0
  43. package/dist/handlers/list-xero-payroll-leave-periods.handler.js +44 -0
  44. package/dist/handlers/list-xero-payroll-leave-types.handler.js +40 -0
  45. package/dist/handlers/list-xero-profit-and-loss.handler.js +52 -0
  46. package/dist/handlers/list-xero-quotes.handler.js +36 -0
  47. package/dist/handlers/list-xero-report-balance-sheet.handler.js +34 -0
  48. package/dist/handlers/list-xero-tax-rates.handler.js +30 -0
  49. package/dist/handlers/list-xero-timesheets.handler.js +29 -0
  50. package/dist/handlers/list-xero-tracking-categories.handler.js +29 -0
  51. package/dist/handlers/list-xero-trial-balance.handler.js +42 -0
  52. package/dist/handlers/revert-xero-payroll-timesheet.handler.js +28 -0
  53. package/dist/handlers/update-xero-bank-transaction.handler.js +56 -0
  54. package/dist/handlers/update-xero-contact.handler.js +66 -0
  55. package/dist/handlers/update-xero-credit-note.handler.js +61 -0
  56. package/dist/handlers/update-xero-invoice.handler.js +62 -0
  57. package/dist/handlers/update-xero-item.handler.js +46 -0
  58. package/dist/handlers/update-xero-manual-journal.handler.js +46 -0
  59. package/dist/handlers/update-xero-payroll-timesheet-add-line.handler.js +28 -0
  60. package/dist/handlers/update-xero-payroll-timesheet-update-line.handler.js +28 -0
  61. package/dist/handlers/update-xero-quote.handler.js +78 -0
  62. package/dist/handlers/update-xero-tracking-category.handler.js +43 -0
  63. package/dist/handlers/update-xero-tracking-options.handler.js +51 -0
  64. package/dist/handlers/upload-xero-invoice-attachment.handler.js +36 -0
  65. package/dist/handlers/void-xero-invoice.handler.js +52 -0
  66. package/dist/helpers/build-where-clause.js +29 -0
  67. package/dist/helpers/create-xero-tool.js +6 -0
  68. package/dist/helpers/datetime.js +91 -0
  69. package/dist/helpers/ensure-error.js +13 -0
  70. package/dist/helpers/format-aged-report-filter.js +8 -0
  71. package/dist/helpers/format-error.js +25 -0
  72. package/dist/helpers/format-line-item.js +13 -0
  73. package/dist/helpers/format-tracking-option.js +7 -0
  74. package/dist/helpers/get-client-headers.js +8 -0
  75. package/dist/helpers/get-deeplink.js +41 -0
  76. package/dist/helpers/get-download-path.js +16 -0
  77. package/dist/helpers/get-external-link.js +8 -0
  78. package/dist/helpers/get-package-version.js +20 -0
  79. package/dist/index.js +18 -0
  80. package/dist/resources/register-resources.js +27 -0
  81. package/dist/server/xero-mcp-server.js +43 -0
  82. package/dist/tools/create/convert-quote-to-invoice.tool.js +46 -0
  83. package/dist/tools/create/create-bank-transaction.tool.js +57 -0
  84. package/dist/tools/create/create-contact.tool.js +56 -0
  85. package/dist/tools/create/create-credit-note.tool.js +53 -0
  86. package/dist/tools/create/create-invoice.tool.js +78 -0
  87. package/dist/tools/create/create-item.tool.js +61 -0
  88. package/dist/tools/create/create-manual-journal.tool.js +116 -0
  89. package/dist/tools/create/create-payment.tool.js +71 -0
  90. package/dist/tools/create/create-payroll-timesheet.tool.js +40 -0
  91. package/dist/tools/create/create-quote.tool.js +57 -0
  92. package/dist/tools/create/create-tracking-category.tool.js +28 -0
  93. package/dist/tools/create/create-tracking-options.tool.js +30 -0
  94. package/dist/tools/create/index.js +35 -0
  95. package/dist/tools/create/upload-invoice-attachment.tool.js +49 -0
  96. package/dist/tools/delete/archive-contact.tool.js +30 -0
  97. package/dist/tools/delete/delete-invoice-attachment.tool.js +28 -0
  98. package/dist/tools/delete/delete-payroll-timesheet.tool.js +28 -0
  99. package/dist/tools/delete/index.js +15 -0
  100. package/dist/tools/get/get-invoice-attachment.tool.js +33 -0
  101. package/dist/tools/get/get-invoice-pdf.tool.js +33 -0
  102. package/dist/tools/get/get-invoice.tool.js +72 -0
  103. package/dist/tools/get/get-payroll-timesheet.tool.js +50 -0
  104. package/dist/tools/get/index.js +17 -0
  105. package/dist/tools/list/index.js +64 -0
  106. package/dist/tools/list/list-accounts.tool.js +39 -0
  107. package/dist/tools/list/list-aged-payables-by-contact.tool.js +51 -0
  108. package/dist/tools/list/list-aged-receivables-by-contact.tool.js +51 -0
  109. package/dist/tools/list/list-bank-transactions.tool.js +66 -0
  110. package/dist/tools/list/list-contact-groups.tool.js +48 -0
  111. package/dist/tools/list/list-contacts.tool.js +80 -0
  112. package/dist/tools/list/list-credit-notes.tool.js +72 -0
  113. package/dist/tools/list/list-invoice-attachments.tool.js +42 -0
  114. package/dist/tools/list/list-invoices.tool.js +98 -0
  115. package/dist/tools/list/list-items.tool.js +50 -0
  116. package/dist/tools/list/list-manual-journals.tool.js +80 -0
  117. package/dist/tools/list/list-organisation-details.tool.js +91 -0
  118. package/dist/tools/list/list-payments.tool.js +91 -0
  119. package/dist/tools/list/list-payroll-employee-leave-balances.tool.js +39 -0
  120. package/dist/tools/list/list-payroll-employee-leave-types.tool.js +57 -0
  121. package/dist/tools/list/list-payroll-employee-leave.tool.js +43 -0
  122. package/dist/tools/list/list-payroll-employees.tool.js +49 -0
  123. package/dist/tools/list/list-payroll-leave-periods.tool.js +45 -0
  124. package/dist/tools/list/list-payroll-leave-types.tool.js +40 -0
  125. package/dist/tools/list/list-payroll-timesheets.tool.js +40 -0
  126. package/dist/tools/list/list-profit-and-loss.tool.js +46 -0
  127. package/dist/tools/list/list-quotes.tool.js +69 -0
  128. package/dist/tools/list/list-report-balance-sheet.tool.js +39 -0
  129. package/dist/tools/list/list-tax-rates.tool.js +49 -0
  130. package/dist/tools/list/list-tracking-categories.tool.js +39 -0
  131. package/dist/tools/list/list-trial-balance.tool.js +42 -0
  132. package/dist/tools/tool-factory.js +24 -0
  133. package/dist/tools/update/approve-payroll-timesheet.tool.js +29 -0
  134. package/dist/tools/update/authorise-invoice.tool.js +42 -0
  135. package/dist/tools/update/index.js +39 -0
  136. package/dist/tools/update/revert-payroll-timesheet.tool.js +29 -0
  137. package/dist/tools/update/update-bank-transaction.tool.js +56 -0
  138. package/dist/tools/update/update-contact.tool.js +69 -0
  139. package/dist/tools/update/update-credit-note.tool.js +56 -0
  140. package/dist/tools/update/update-invoice.tool.js +76 -0
  141. package/dist/tools/update/update-item.tool.js +62 -0
  142. package/dist/tools/update/update-manual-journal-tool.js +89 -0
  143. package/dist/tools/update/update-payroll-timesheet-add-line.tool.js +34 -0
  144. package/dist/tools/update/update-payroll-timesheet-update-line.tool.js +35 -0
  145. package/dist/tools/update/update-quote.tool.js +61 -0
  146. package/dist/tools/update/update-tracking-category.tool.js +30 -0
  147. package/dist/tools/update/update-tracking-options.tool.js +35 -0
  148. package/dist/tools/update/void-invoice.tool.js +33 -0
  149. package/dist/types/list-report-balance-sheet-params.js +1 -0
  150. package/dist/types/timeframeType.js +1 -0
  151. package/dist/types/tool-definition.js +1 -0
  152. package/dist/types/tool-list.js +1 -0
  153. package/dist/types/tool-response.js +1 -0
  154. package/package.json +38 -0
@@ -0,0 +1,49 @@
1
+ import { listXeroTaxRates } from "../../handlers/list-xero-tax-rates.handler.js";
2
+ import { CreateXeroTool } from "../../helpers/create-xero-tool.js";
3
+ 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 () => {
4
+ const response = await listXeroTaxRates();
5
+ if (response.error !== null) {
6
+ return {
7
+ content: [
8
+ {
9
+ type: "text",
10
+ text: `Error listing tax rates: ${response.error}`,
11
+ },
12
+ ],
13
+ };
14
+ }
15
+ const taxRates = response.result;
16
+ return {
17
+ content: [
18
+ {
19
+ type: "text",
20
+ text: `Found ${taxRates?.length || 0} tax rates:`,
21
+ },
22
+ ...(taxRates?.map((taxRate) => ({
23
+ type: "text",
24
+ text: [
25
+ `Tax Rate: ${taxRate.name || "Unnamed"}`,
26
+ `Tax Type: ${taxRate.taxType || "No tax type"}`,
27
+ `Status: ${taxRate.status || "Unknown status"}`,
28
+ `Display Tax Rate: ${taxRate.displayTaxRate || "0.0000"}%`,
29
+ `Effective Rate: ${taxRate.effectiveRate || "0.0000"}%`,
30
+ taxRate.taxComponents?.length
31
+ ? `Tax Components:\n${taxRate.taxComponents
32
+ .map((comp) => ` - ${comp.name}: ${comp.rate}%${comp.isCompound ? " (Compound)" : ""}${comp.isNonRecoverable ? " (Non-recoverable)" : ""}`)
33
+ .join("\n")}`
34
+ : null,
35
+ `Can Apply To:${[
36
+ taxRate.canApplyToAssets ? " Assets" : "",
37
+ taxRate.canApplyToEquity ? " Equity" : "",
38
+ taxRate.canApplyToExpenses ? " Expenses" : "",
39
+ taxRate.canApplyToLiabilities ? " Liabilities" : "",
40
+ taxRate.canApplyToRevenue ? " Revenue" : "",
41
+ ].join("")}`,
42
+ ]
43
+ .filter(Boolean)
44
+ .join("\n"),
45
+ })) || []),
46
+ ],
47
+ };
48
+ });
49
+ export default ListTaxRatesTool;
@@ -0,0 +1,39 @@
1
+ import { z } from "zod";
2
+ import { CreateXeroTool } from "../../helpers/create-xero-tool.js";
3
+ import { listXeroTrackingCategories } from "../../handlers/list-xero-tracking-categories.handler.js";
4
+ import { formatTrackingOption } from "../../helpers/format-tracking-option.js";
5
+ const ListTrackingCategoriesTool = CreateXeroTool("list-tracking-categories", "List all tracking categories in Xero, along with their associated tracking options.", {
6
+ includeArchived: z.boolean().optional()
7
+ .describe("Determines whether or not archived categories will be returned. By default, no archived categories will be returned.")
8
+ }, async ({ includeArchived }) => {
9
+ const response = await listXeroTrackingCategories(includeArchived);
10
+ if (response.isError) {
11
+ return {
12
+ content: [
13
+ {
14
+ type: "text",
15
+ text: `Error listing tracking categories: ${response.error}`
16
+ }
17
+ ]
18
+ };
19
+ }
20
+ const trackingCategories = response.result;
21
+ return {
22
+ content: [
23
+ {
24
+ type: "text",
25
+ text: `Found ${trackingCategories?.length || 0} tracking categories:`
26
+ },
27
+ ...(trackingCategories?.map((category) => ({
28
+ type: "text",
29
+ text: [
30
+ `Tracking Category ID: ${category.trackingCategoryID}`,
31
+ `Name: ${category.name}`,
32
+ `Status: ${category.status}`,
33
+ `Found ${category.options?.length || 0} tracking options:\n${category.options?.map(formatTrackingOption)}`
34
+ ].filter(Boolean).join("\n")
35
+ })) || [])
36
+ ]
37
+ };
38
+ });
39
+ export default ListTrackingCategoriesTool;
@@ -0,0 +1,42 @@
1
+ import { z } from "zod";
2
+ import { listXeroTrialBalance } from "../../handlers/list-xero-trial-balance.handler.js";
3
+ import { CreateXeroTool } from "../../helpers/create-xero-tool.js";
4
+ import { formatUtcDatetime } from "../../helpers/datetime.js";
5
+ const ListTrialBalanceTool = CreateXeroTool("list-trial-balance", "Lists trial balance in Xero. This provides a snapshot of the general ledger, showing debit and credit balances for each account.", {
6
+ date: z.string().optional().describe("Optional date in YYYY-MM-DD format"),
7
+ paymentsOnly: z.boolean().optional().describe("Optional flag to include only accounts with payments"),
8
+ }, async (args) => {
9
+ const response = await listXeroTrialBalance(args?.date, args?.paymentsOnly);
10
+ if (response.error !== null) {
11
+ return {
12
+ content: [
13
+ {
14
+ type: "text",
15
+ text: `Error listing trial balance: ${response.error}`,
16
+ },
17
+ ],
18
+ };
19
+ }
20
+ const trialBalanceReport = response.result;
21
+ return {
22
+ content: [
23
+ {
24
+ type: "text",
25
+ text: `Trial Balance Report: ${trialBalanceReport?.reportName || "Unnamed"}`,
26
+ },
27
+ {
28
+ type: "text",
29
+ text: `Date: ${trialBalanceReport?.reportDate || "Not specified"}`,
30
+ },
31
+ {
32
+ type: "text",
33
+ text: `Updated At: ${trialBalanceReport?.updatedDateUTC ? formatUtcDatetime(trialBalanceReport.updatedDateUTC) : "Unknown"}`,
34
+ },
35
+ {
36
+ type: "text",
37
+ text: JSON.stringify(trialBalanceReport.rows, null, 2),
38
+ },
39
+ ],
40
+ };
41
+ });
42
+ export default ListTrialBalanceTool;
@@ -0,0 +1,24 @@
1
+ import { CoreCreateTools, PayrollCreateTools } from "./create/index.js";
2
+ import { CoreDeleteTools, PayrollDeleteTools } from "./delete/index.js";
3
+ import { CoreGetTools, PayrollGetTools } from "./get/index.js";
4
+ import { CoreListTools, ReportListTools, PayrollListTools } from "./list/index.js";
5
+ import { CoreUpdateTools, PayrollUpdateTools } from "./update/index.js";
6
+ export function ToolFactory(server) {
7
+ const enableReports = process.env.XERO_ENABLE_REPORTS !== "false";
8
+ const enablePayroll = process.env.XERO_ENABLE_PAYROLL === "true";
9
+ const enableReadWrite = process.env.XERO_ENABLE_READWRITE === "true";
10
+ const allTools = [
11
+ ...CoreListTools,
12
+ ...CoreGetTools,
13
+ ...(enableReadWrite ? CoreCreateTools : []),
14
+ ...(enableReadWrite ? CoreUpdateTools : []),
15
+ ...(enableReadWrite ? CoreDeleteTools : []),
16
+ ...(enableReports ? ReportListTools : []),
17
+ ...(enablePayroll ? PayrollListTools : []),
18
+ ...(enablePayroll ? PayrollGetTools : []),
19
+ ...(enablePayroll && enableReadWrite ? PayrollCreateTools : []),
20
+ ...(enablePayroll && enableReadWrite ? PayrollUpdateTools : []),
21
+ ...(enablePayroll && enableReadWrite ? PayrollDeleteTools : []),
22
+ ];
23
+ allTools.map((tool) => tool()).forEach((tool) => server.tool(tool.name, tool.description, tool.schema, tool.handler));
24
+ }
@@ -0,0 +1,29 @@
1
+ import { z } from "zod";
2
+ import { approveXeroPayrollTimesheet, } from "../../handlers/approve-xero-payroll-timesheet.handler.js";
3
+ import { CreateXeroTool } from "../../helpers/create-xero-tool.js";
4
+ const ApprovePayrollTimesheetTool = CreateXeroTool("approve-timesheet", `Approve a payroll timesheet in Xero by its ID.`, {
5
+ timesheetID: z.string().describe("The ID of the timesheet to approve."),
6
+ }, async (params) => {
7
+ const { timesheetID } = params;
8
+ const response = await approveXeroPayrollTimesheet(timesheetID);
9
+ if (response.isError) {
10
+ return {
11
+ content: [
12
+ {
13
+ type: "text",
14
+ text: `Error approving timesheet: ${response.error}`,
15
+ },
16
+ ],
17
+ };
18
+ }
19
+ const timesheet = response.result;
20
+ return {
21
+ content: [
22
+ {
23
+ type: "text",
24
+ text: `Successfully approved timesheet with ID: ${timesheet?.timesheetID}`,
25
+ },
26
+ ],
27
+ };
28
+ });
29
+ export default ApprovePayrollTimesheetTool;
@@ -0,0 +1,42 @@
1
+ import { z } from "zod";
2
+ import { authoriseXeroInvoice } from "../../handlers/authorise-xero-invoice.handler.js";
3
+ import { DeepLinkType, getDeepLink } from "../../helpers/get-deeplink.js";
4
+ import { CreateXeroTool } from "../../helpers/create-xero-tool.js";
5
+ import { Invoice } from "xero-node";
6
+ const AuthoriseInvoiceTool = CreateXeroTool("authorise-invoice", "Approve and authorise a DRAFT or SUBMITTED invoice in Xero. \
7
+ Once authorised, the invoice can be sent to the customer and payments can be recorded against it. \
8
+ A deep link to the invoice in Xero is returned after authorisation.", {
9
+ invoiceId: z.string().describe("The ID of the invoice to authorise."),
10
+ }, async ({ invoiceId }) => {
11
+ const result = await authoriseXeroInvoice(invoiceId);
12
+ if (result.isError) {
13
+ return {
14
+ content: [{ type: "text", text: `Error: ${result.error}` }],
15
+ };
16
+ }
17
+ const invoice = result.result;
18
+ const deepLink = invoice.invoiceID
19
+ ? await getDeepLink(invoice.type === Invoice.TypeEnum.ACCREC
20
+ ? DeepLinkType.INVOICE
21
+ : DeepLinkType.BILL, invoice.invoiceID)
22
+ : null;
23
+ return {
24
+ content: [
25
+ {
26
+ type: "text",
27
+ text: [
28
+ "Invoice authorised successfully.",
29
+ `Invoice ID: ${invoice.invoiceID}`,
30
+ `Invoice Number: ${invoice.invoiceNumber ?? "N/A"}`,
31
+ `Contact: ${invoice.contact?.name ?? "N/A"}`,
32
+ `Total: ${invoice.total}`,
33
+ `Status: ${invoice.status}`,
34
+ deepLink ? `Link to view: ${deepLink}` : null,
35
+ ]
36
+ .filter(Boolean)
37
+ .join("\n"),
38
+ },
39
+ ],
40
+ };
41
+ });
42
+ export default AuthoriseInvoiceTool;
@@ -0,0 +1,39 @@
1
+ import ApprovePayrollTimesheetTool from "./approve-payroll-timesheet.tool.js";
2
+ import RevertPayrollTimesheetTool from "./revert-payroll-timesheet.tool.js";
3
+ import UpdateBankTransactionTool from "./update-bank-transaction.tool.js";
4
+ import UpdateContactTool from "./update-contact.tool.js";
5
+ import UpdateCreditNoteTool from "./update-credit-note.tool.js";
6
+ import UpdateInvoiceTool from "./update-invoice.tool.js";
7
+ import UpdateItemTool from "./update-item.tool.js";
8
+ import AddTimesheetLineTool from "./update-payroll-timesheet-add-line.tool.js";
9
+ import UpdatePayrollTimesheetLineTool from "./update-payroll-timesheet-update-line.tool.js";
10
+ import UpdateManualJournalTool from "./update-manual-journal-tool.js";
11
+ import UpdateQuoteTool from "./update-quote.tool.js";
12
+ import UpdateTrackingCategoryTool from "./update-tracking-category.tool.js";
13
+ import UpdateTrackingOptionsTool from "./update-tracking-options.tool.js";
14
+ import VoidInvoiceTool from "./void-invoice.tool.js";
15
+ import AuthoriseInvoiceTool from "./authorise-invoice.tool.js";
16
+ export const CoreUpdateTools = [
17
+ UpdateContactTool,
18
+ UpdateCreditNoteTool,
19
+ UpdateInvoiceTool,
20
+ UpdateManualJournalTool,
21
+ UpdateQuoteTool,
22
+ UpdateItemTool,
23
+ UpdateBankTransactionTool,
24
+ UpdateTrackingCategoryTool,
25
+ UpdateTrackingOptionsTool,
26
+ VoidInvoiceTool,
27
+ AuthoriseInvoiceTool,
28
+ ];
29
+ export const PayrollUpdateTools = [
30
+ ApprovePayrollTimesheetTool,
31
+ AddTimesheetLineTool,
32
+ UpdatePayrollTimesheetLineTool,
33
+ RevertPayrollTimesheetTool,
34
+ ];
35
+ // Legacy export
36
+ export const UpdateTools = [
37
+ ...CoreUpdateTools,
38
+ ...PayrollUpdateTools,
39
+ ];
@@ -0,0 +1,29 @@
1
+ import { z } from "zod";
2
+ import { revertXeroPayrollTimesheet, } from "../../handlers/revert-xero-payroll-timesheet.handler.js";
3
+ import { CreateXeroTool } from "../../helpers/create-xero-tool.js";
4
+ const RevertPayrollTimesheetTool = CreateXeroTool("revert-timesheet", `Revert a payroll timesheet to draft in Xero by its ID.`, {
5
+ timesheetID: z.string().describe("The ID of the timesheet to revert."),
6
+ }, async (params) => {
7
+ const { timesheetID } = params;
8
+ const response = await revertXeroPayrollTimesheet(timesheetID);
9
+ if (response.isError) {
10
+ return {
11
+ content: [
12
+ {
13
+ type: "text",
14
+ text: `Error reverting timesheet: ${response.error}`,
15
+ },
16
+ ],
17
+ };
18
+ }
19
+ const timesheet = response.result;
20
+ return {
21
+ content: [
22
+ {
23
+ type: "text",
24
+ text: `Successfully reverted timesheet with ID: ${timesheet?.timesheetID} to draft.`,
25
+ },
26
+ ],
27
+ };
28
+ });
29
+ export default RevertPayrollTimesheetTool;
@@ -0,0 +1,56 @@
1
+ import { z } from "zod";
2
+ import { CreateXeroTool } from "../../helpers/create-xero-tool.js";
3
+ import { updateXeroBankTransaction } from "../../handlers/update-xero-bank-transaction.handler.js";
4
+ import { bankTransactionDeepLink } from "../../consts/deeplinks.js";
5
+ const lineItemSchema = z.object({
6
+ description: z.string(),
7
+ quantity: z.number(),
8
+ unitAmount: z.number(),
9
+ accountCode: z.string(),
10
+ taxType: z.string(),
11
+ });
12
+ const UpdateBankTransactionTool = CreateXeroTool("update-bank-transaction", `Update a bank transaction in Xero.
13
+ When a bank transaction is updated, a deep link to the bank transaction in Xero is returned.
14
+ This deep link can be used to view the bank transaction in Xero directly.
15
+ This link should be displayed to the user.`, {
16
+ bankTransactionId: z.string(),
17
+ type: z.enum(["RECEIVE", "SPEND"]).optional(),
18
+ contactId: z.string().optional(),
19
+ lineItems: z.array(lineItemSchema).optional().describe("All line items must be provided. Any line items not provided will be removed. Including existing line items. \
20
+ Do not modify line items that have not been specified by the user"),
21
+ reference: z.string().optional(),
22
+ date: z.string().optional()
23
+ }, async ({ bankTransactionId, type, contactId, lineItems, reference, date }) => {
24
+ const result = await updateXeroBankTransaction(bankTransactionId, type, contactId, lineItems, reference, date);
25
+ if (result.isError) {
26
+ return {
27
+ content: [
28
+ {
29
+ type: "text",
30
+ text: `Error updating bank transaction: ${result.error}`,
31
+ },
32
+ ],
33
+ };
34
+ }
35
+ const bankTransaction = result.result;
36
+ const deepLink = bankTransaction.bankAccount.accountID && bankTransaction.bankTransactionID
37
+ ? bankTransactionDeepLink(bankTransaction.bankAccount.accountID, bankTransaction.bankTransactionID)
38
+ : null;
39
+ return {
40
+ content: [
41
+ {
42
+ type: "text",
43
+ text: [
44
+ "Bank transaction updated successfully:",
45
+ `ID: ${bankTransaction?.bankTransactionID}`,
46
+ `Date: ${bankTransaction?.date}`,
47
+ `Contact: ${bankTransaction?.contact?.name}`,
48
+ `Total: ${bankTransaction?.total}`,
49
+ `Status: ${bankTransaction?.status}`,
50
+ deepLink ? `Link to view: ${deepLink}` : null
51
+ ].filter(Boolean).join("\n"),
52
+ },
53
+ ],
54
+ };
55
+ });
56
+ export default UpdateBankTransactionTool;
@@ -0,0 +1,69 @@
1
+ import { updateXeroContact } from "../../handlers/update-xero-contact.handler.js";
2
+ import { z } from "zod";
3
+ import { DeepLinkType, getDeepLink } from "../../helpers/get-deeplink.js";
4
+ import { ensureError } from "../../helpers/ensure-error.js";
5
+ import { CreateXeroTool } from "../../helpers/create-xero-tool.js";
6
+ const UpdateContactTool = CreateXeroTool("update-contact", "Update a contact in Xero.\
7
+ When a contact is updated, a deep link to the contact in Xero is returned. \
8
+ This deep link can be used to view the contact in Xero directly. \
9
+ This link should be displayed to the user.", {
10
+ contactId: z.string(),
11
+ name: z.string(),
12
+ firstName: z.string().optional(),
13
+ lastName: z.string().optional(),
14
+ email: z.string().email().optional(),
15
+ phone: z.string().optional(),
16
+ address: z
17
+ .object({
18
+ addressLine1: z.string(),
19
+ addressLine2: z.string().optional(),
20
+ city: z.string().optional(),
21
+ region: z.string().optional(),
22
+ postalCode: z.string().optional(),
23
+ country: z.string().optional(),
24
+ })
25
+ .optional(),
26
+ }, async ({ contactId, name, firstName, lastName, email, phone, address, }) => {
27
+ try {
28
+ const response = await updateXeroContact(contactId, name, firstName, lastName, email, phone, address);
29
+ if (response.isError) {
30
+ return {
31
+ content: [
32
+ {
33
+ type: "text",
34
+ text: `Error updating contact: ${response.error}`,
35
+ },
36
+ ],
37
+ };
38
+ }
39
+ const contact = response.result;
40
+ const deepLink = contact.contactID
41
+ ? await getDeepLink(DeepLinkType.CONTACT, contact.contactID)
42
+ : null;
43
+ return {
44
+ content: [
45
+ {
46
+ type: "text",
47
+ text: [
48
+ `Contact updated: ${contact.name} (ID: ${contact.contactID})`,
49
+ deepLink ? `Link to view: ${deepLink}` : null,
50
+ ]
51
+ .filter(Boolean)
52
+ .join("\n"),
53
+ },
54
+ ],
55
+ };
56
+ }
57
+ catch (error) {
58
+ const err = ensureError(error);
59
+ return {
60
+ content: [
61
+ {
62
+ type: "text",
63
+ text: `Error creating contact: ${err.message}`,
64
+ },
65
+ ],
66
+ };
67
+ }
68
+ });
69
+ export default UpdateContactTool;
@@ -0,0 +1,56 @@
1
+ import { z } from "zod";
2
+ import { updateXeroCreditNote } from "../../handlers/update-xero-credit-note.handler.js";
3
+ import { DeepLinkType, getDeepLink } from "../../helpers/get-deeplink.js";
4
+ import { CreateXeroTool } from "../../helpers/create-xero-tool.js";
5
+ const lineItemSchema = z.object({
6
+ description: z.string(),
7
+ quantity: z.number(),
8
+ unitAmount: z.number(),
9
+ accountCode: z.string(),
10
+ taxType: z.string(),
11
+ });
12
+ const UpdateCreditNoteTool = CreateXeroTool("update-credit-note", "Update a credit note in Xero. Only works on draft credit notes.\
13
+ All line items must be provided. Any line items not provided will be removed. Including existing line items.\
14
+ Do not modify line items that have not been specified by the user.\
15
+ When a credit note is updated, a deep link to the credit note in Xero is returned.\
16
+ This deep link can be used to view the credit note in Xero directly.\
17
+ This link should be displayed to the user.", {
18
+ creditNoteId: z.string(),
19
+ lineItems: z.array(lineItemSchema).optional().describe("All line items must be provided. Any line items not provided will be removed. Including existing line items.\
20
+ Do not modify line items that have not been specified by the user"),
21
+ reference: z.string().optional(),
22
+ date: z.string().optional(),
23
+ contactId: z.string().optional(),
24
+ }, async ({ creditNoteId, lineItems, reference, date, contactId, }) => {
25
+ const result = await updateXeroCreditNote(creditNoteId, lineItems, reference, contactId, date);
26
+ if (result.isError) {
27
+ return {
28
+ content: [
29
+ {
30
+ type: "text",
31
+ text: `Error updating credit note: ${result.error}`,
32
+ },
33
+ ],
34
+ };
35
+ }
36
+ const creditNote = result.result;
37
+ const deepLink = creditNote.creditNoteID
38
+ ? await getDeepLink(DeepLinkType.CREDIT_NOTE, creditNote.creditNoteID)
39
+ : null;
40
+ return {
41
+ content: [
42
+ {
43
+ type: "text",
44
+ text: [
45
+ "Credit note updated successfully:",
46
+ `ID: ${creditNote?.creditNoteID}`,
47
+ `Contact: ${creditNote?.contact?.name}`,
48
+ `Total: ${creditNote?.total}`,
49
+ `Status: ${creditNote?.status}`,
50
+ deepLink ? `Link to view: ${deepLink}` : null,
51
+ ].join("\n"),
52
+ },
53
+ ],
54
+ };
55
+ });
56
+ export default UpdateCreditNoteTool;
@@ -0,0 +1,76 @@
1
+ import { z } from "zod";
2
+ import { updateXeroInvoice } from "../../handlers/update-xero-invoice.handler.js";
3
+ import { DeepLinkType, getDeepLink } from "../../helpers/get-deeplink.js";
4
+ import { CreateXeroTool } from "../../helpers/create-xero-tool.js";
5
+ import { Invoice } from "xero-node";
6
+ const trackingSchema = z.object({
7
+ name: z.string().optional().describe("Name of the tracking category (e.g. 'Department'). Use name+option OR trackingCategoryID+trackingOptionID. " +
8
+ "Can be obtained from the list-tracking-categories tool."),
9
+ option: z.string().optional().describe("Name of the tracking option (e.g. 'Sales'). Use with name, or use IDs instead. " +
10
+ "Can be obtained from the list-tracking-categories tool."),
11
+ trackingCategoryID: z.string().optional().describe("UUID of the tracking category. Use with trackingOptionID, or use name+option instead. " +
12
+ "Can be obtained from the list-tracking-categories tool."),
13
+ trackingOptionID: z.string().optional().describe("UUID of the tracking option. Use with trackingCategoryID, or use name+option instead. " +
14
+ "Can be obtained from the list-tracking-categories tool."),
15
+ });
16
+ const lineItemSchema = z.object({
17
+ description: z.string().describe("The description of the line item"),
18
+ quantity: z.number().describe("The quantity of the line item"),
19
+ unitAmount: z.number().describe("The price per unit of the line item"),
20
+ accountCode: z.string().describe("The account code of the line item - can be obtained from the list-accounts tool"),
21
+ taxType: z.string().describe("The tax type of the line item - can be obtained from the list-tax-rates tool"),
22
+ itemCode: z.string().describe("The item code of the line item - can be obtained from the list-items tool \
23
+ If the item was not populated in the original invoice, \
24
+ add without an item code unless the user has told you to add an item code.").optional(),
25
+ tracking: z.array(trackingSchema).describe("Up to 2 tracking categories and options can be added to the line item. \
26
+ Can be obtained from the list-tracking-categories tool. \
27
+ Only use if prompted by the user.").optional(),
28
+ });
29
+ const UpdateInvoiceTool = CreateXeroTool("update-invoice", "Update an invoice in Xero. Only works on draft invoices.\
30
+ All line items must be provided. Any line items not provided will be removed. Including existing line items.\
31
+ Do not modify line items that have not been specified by the user.\
32
+ When an invoice is updated, a deep link to the invoice in Xero is returned. \
33
+ This deep link can be used to view the contact in Xero directly. \
34
+ This link should be displayed to the user.", {
35
+ invoiceId: z.string().describe("The ID of the invoice to update."),
36
+ lineItems: z.array(lineItemSchema).optional().describe("All line items must be provided. Any line items not provided will be removed. Including existing line items. \
37
+ Do not modify line items that have not been specified by the user"),
38
+ reference: z.string().optional().describe("A reference number for the invoice."),
39
+ dueDate: z.string().optional().describe("The due date of the invoice."),
40
+ date: z.string().optional().describe("The date of the invoice."),
41
+ contactId: z.string().optional().describe("The ID of the contact to update the invoice for. \
42
+ Can be obtained from the list-contacts tool."),
43
+ }, async ({ invoiceId, lineItems, reference, dueDate, date, contactId }) => {
44
+ const result = await updateXeroInvoice(invoiceId, lineItems, reference, dueDate, date, contactId);
45
+ if (result.isError) {
46
+ return {
47
+ content: [
48
+ {
49
+ type: "text",
50
+ text: `Error updating invoice: ${result.error}`,
51
+ },
52
+ ],
53
+ };
54
+ }
55
+ const invoice = result.result;
56
+ const deepLink = invoice.invoiceID
57
+ ? await getDeepLink(invoice.type === Invoice.TypeEnum.ACCREC ? DeepLinkType.INVOICE : DeepLinkType.BILL, invoice.invoiceID)
58
+ : null;
59
+ return {
60
+ content: [
61
+ {
62
+ type: "text",
63
+ text: [
64
+ "Invoice updated successfully:",
65
+ `ID: ${invoice?.invoiceID}`,
66
+ `Contact: ${invoice?.contact?.name}`,
67
+ `Type: ${invoice?.type}`,
68
+ `Total: ${invoice?.total}`,
69
+ `Status: ${invoice?.status}`,
70
+ deepLink ? `Link to view: ${deepLink}` : null,
71
+ ].join("\n"),
72
+ },
73
+ ],
74
+ };
75
+ });
76
+ export default UpdateInvoiceTool;
@@ -0,0 +1,62 @@
1
+ import { z } from "zod";
2
+ import { updateXeroItem } from "../../handlers/update-xero-item.handler.js";
3
+ import { CreateXeroTool } from "../../helpers/create-xero-tool.js";
4
+ const purchaseDetailsSchema = z.object({
5
+ unitPrice: z.number().optional(),
6
+ taxType: z.string().optional(),
7
+ accountCode: z.string().optional(),
8
+ });
9
+ const salesDetailsSchema = z.object({
10
+ unitPrice: z.number().optional(),
11
+ taxType: z.string().optional(),
12
+ accountCode: z.string().optional(),
13
+ });
14
+ const UpdateItemTool = CreateXeroTool("update-item", "Update an item in Xero.", {
15
+ itemId: z.string(),
16
+ code: z.string(),
17
+ name: z.string(),
18
+ description: z.string().optional(),
19
+ purchaseDescription: z.string().optional(),
20
+ purchaseDetails: purchaseDetailsSchema.optional(),
21
+ salesDetails: salesDetailsSchema.optional(),
22
+ isTrackedAsInventory: z.boolean().optional(),
23
+ inventoryAssetAccountCode: z.string().optional(),
24
+ }, async ({ itemId, code, name, description, purchaseDescription, purchaseDetails, salesDetails, isTrackedAsInventory, inventoryAssetAccountCode, }) => {
25
+ const result = await updateXeroItem(itemId, {
26
+ code,
27
+ name,
28
+ description,
29
+ purchaseDescription,
30
+ purchaseDetails,
31
+ salesDetails,
32
+ isTrackedAsInventory,
33
+ inventoryAssetAccountCode,
34
+ });
35
+ if (result.isError) {
36
+ return {
37
+ content: [
38
+ {
39
+ type: "text",
40
+ text: `Error updating item: ${result.error}`,
41
+ },
42
+ ],
43
+ };
44
+ }
45
+ const item = result.result;
46
+ return {
47
+ content: [
48
+ {
49
+ type: "text",
50
+ text: [
51
+ "Item updated successfully:",
52
+ `ID: ${item?.itemID}`,
53
+ `Code: ${item?.code}`,
54
+ `Name: ${item?.name}`,
55
+ ]
56
+ .filter(Boolean)
57
+ .join("\n"),
58
+ },
59
+ ],
60
+ };
61
+ });
62
+ export default UpdateItemTool;