@mindstone/mcp-server-xero 0.0.15

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 (137) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +199 -0
  3. package/dist/clients/xero-client.js +134 -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/create-xero-bank-transaction.handler.js +50 -0
  7. package/dist/handlers/create-xero-contact.handler.js +49 -0
  8. package/dist/handlers/create-xero-credit-note.handler.js +49 -0
  9. package/dist/handlers/create-xero-invoice.handler.js +55 -0
  10. package/dist/handlers/create-xero-item.handler.js +59 -0
  11. package/dist/handlers/create-xero-manual-journal.handler.js +57 -0
  12. package/dist/handlers/create-xero-payment.handler.js +49 -0
  13. package/dist/handlers/create-xero-payroll-timesheet.handler.js +28 -0
  14. package/dist/handlers/create-xero-quote.handler.js +54 -0
  15. package/dist/handlers/create-xero-tracking-category.handler.js +35 -0
  16. package/dist/handlers/create-xero-tracking-option.handler.js +31 -0
  17. package/dist/handlers/delete-xero-payroll-timesheet.handler.js +28 -0
  18. package/dist/handlers/download-xero-invoice-attachment.handler.js +26 -0
  19. package/dist/handlers/get-xero-payroll-timesheet.handler.js +28 -0
  20. package/dist/handlers/history-handler-factory.js +46 -0
  21. package/dist/handlers/list-aged-payables-by-contact.handler.js +37 -0
  22. package/dist/handlers/list-aged-receivables-by-contact.handler.js +37 -0
  23. package/dist/handlers/list-xero-accounts.handler.js +32 -0
  24. package/dist/handlers/list-xero-bank-transactions.handler.js +31 -0
  25. package/dist/handlers/list-xero-contact-groups.handler.js +34 -0
  26. package/dist/handlers/list-xero-contacts.handler.js +37 -0
  27. package/dist/handlers/list-xero-credit-notes.handler.js +34 -0
  28. package/dist/handlers/list-xero-invoice-attachments.handler.js +20 -0
  29. package/dist/handlers/list-xero-invoices.handler.js +59 -0
  30. package/dist/handlers/list-xero-items.handler.js +32 -0
  31. package/dist/handlers/list-xero-manual-journals.handler.js +33 -0
  32. package/dist/handlers/list-xero-organisation-details.handler.js +32 -0
  33. package/dist/handlers/list-xero-payments.handler.js +53 -0
  34. package/dist/handlers/list-xero-payroll-employee-leave-balances.handler.js +42 -0
  35. package/dist/handlers/list-xero-payroll-employee-leave-types.handler.js +42 -0
  36. package/dist/handlers/list-xero-payroll-employee-leave.handler.js +44 -0
  37. package/dist/handlers/list-xero-payroll-employees.handler.js +31 -0
  38. package/dist/handlers/list-xero-payroll-leave-periods.handler.js +44 -0
  39. package/dist/handlers/list-xero-payroll-leave-types.handler.js +40 -0
  40. package/dist/handlers/list-xero-profit-and-loss.handler.js +52 -0
  41. package/dist/handlers/list-xero-quotes.handler.js +37 -0
  42. package/dist/handlers/list-xero-report-balance-sheet.handler.js +34 -0
  43. package/dist/handlers/list-xero-tax-rates.handler.js +30 -0
  44. package/dist/handlers/list-xero-timesheets.handler.js +29 -0
  45. package/dist/handlers/list-xero-tracking-categories.handler.js +29 -0
  46. package/dist/handlers/list-xero-trial-balance.handler.js +42 -0
  47. package/dist/handlers/revert-xero-payroll-timesheet.handler.js +28 -0
  48. package/dist/handlers/update-xero-bank-transaction.handler.js +56 -0
  49. package/dist/handlers/update-xero-contact.handler.js +66 -0
  50. package/dist/handlers/update-xero-credit-note.handler.js +61 -0
  51. package/dist/handlers/update-xero-invoice.handler.js +63 -0
  52. package/dist/handlers/update-xero-item.handler.js +46 -0
  53. package/dist/handlers/update-xero-manual-journal.handler.js +46 -0
  54. package/dist/handlers/update-xero-payroll-timesheet-add-line.handler.js +28 -0
  55. package/dist/handlers/update-xero-payroll-timesheet-update-line.handler.js +28 -0
  56. package/dist/handlers/update-xero-quote.handler.js +78 -0
  57. package/dist/handlers/update-xero-tracking-category.handler.js +43 -0
  58. package/dist/handlers/update-xero-tracking-options.handler.js +51 -0
  59. package/dist/helpers/create-xero-tool.js +6 -0
  60. package/dist/helpers/ensure-error.js +13 -0
  61. package/dist/helpers/format-aged-report-filter.js +8 -0
  62. package/dist/helpers/format-error.js +57 -0
  63. package/dist/helpers/format-line-item.js +13 -0
  64. package/dist/helpers/format-token-error.js +34 -0
  65. package/dist/helpers/format-tracking-option.js +7 -0
  66. package/dist/helpers/get-client-headers.js +8 -0
  67. package/dist/helpers/get-deeplink.js +41 -0
  68. package/dist/helpers/get-external-link.js +8 -0
  69. package/dist/helpers/get-package-version.js +20 -0
  70. package/dist/index.js +16 -0
  71. package/dist/server/xero-mcp-server.js +14 -0
  72. package/dist/tools/create/create-bank-transaction.tool.js +57 -0
  73. package/dist/tools/create/create-contact.tool.js +56 -0
  74. package/dist/tools/create/create-credit-note.tool.js +53 -0
  75. package/dist/tools/create/create-invoice.tool.js +76 -0
  76. package/dist/tools/create/create-item.tool.js +61 -0
  77. package/dist/tools/create/create-manual-journal.tool.js +116 -0
  78. package/dist/tools/create/create-payment.tool.js +71 -0
  79. package/dist/tools/create/create-payroll-timesheet.tool.js +40 -0
  80. package/dist/tools/create/create-quote.tool.js +57 -0
  81. package/dist/tools/create/create-tracking-category.tool.js +28 -0
  82. package/dist/tools/create/create-tracking-options.tool.js +30 -0
  83. package/dist/tools/create/index.js +24 -0
  84. package/dist/tools/delete/delete-payroll-timesheet.tool.js +28 -0
  85. package/dist/tools/delete/index.js +4 -0
  86. package/dist/tools/get/get-invoice-attachment.tool.js +45 -0
  87. package/dist/tools/get/get-payroll-timesheet.tool.js +49 -0
  88. package/dist/tools/get/index.js +6 -0
  89. package/dist/tools/history/index.js +141 -0
  90. package/dist/tools/list/index.js +54 -0
  91. package/dist/tools/list/list-accounts.tool.js +39 -0
  92. package/dist/tools/list/list-aged-payables-by-contact.tool.js +49 -0
  93. package/dist/tools/list/list-aged-receivables-by-contact.tool.js +49 -0
  94. package/dist/tools/list/list-bank-transactions.tool.js +63 -0
  95. package/dist/tools/list/list-contact-groups.tool.js +48 -0
  96. package/dist/tools/list/list-contacts.tool.js +70 -0
  97. package/dist/tools/list/list-credit-notes.tool.js +70 -0
  98. package/dist/tools/list/list-invoice-attachments.tool.js +42 -0
  99. package/dist/tools/list/list-invoices.tool.js +141 -0
  100. package/dist/tools/list/list-items.tool.js +53 -0
  101. package/dist/tools/list/list-manual-journals.tool.js +83 -0
  102. package/dist/tools/list/list-organisation-details.tool.js +90 -0
  103. package/dist/tools/list/list-payments.tool.js +84 -0
  104. package/dist/tools/list/list-payroll-employee-leave-balances.tool.js +39 -0
  105. package/dist/tools/list/list-payroll-employee-leave-types.tool.js +57 -0
  106. package/dist/tools/list/list-payroll-employee-leave.tool.js +42 -0
  107. package/dist/tools/list/list-payroll-employees.tool.js +48 -0
  108. package/dist/tools/list/list-payroll-leave-periods.tool.js +45 -0
  109. package/dist/tools/list/list-payroll-leave-types.tool.js +39 -0
  110. package/dist/tools/list/list-payroll-timesheets.tool.js +39 -0
  111. package/dist/tools/list/list-profit-and-loss.tool.js +45 -0
  112. package/dist/tools/list/list-quotes.tool.js +72 -0
  113. package/dist/tools/list/list-report-balance-sheet.tool.js +39 -0
  114. package/dist/tools/list/list-tax-rates.tool.js +49 -0
  115. package/dist/tools/list/list-tracking-categories.tool.js +39 -0
  116. package/dist/tools/list/list-trial-balance.tool.js +41 -0
  117. package/dist/tools/tool-factory.js +24 -0
  118. package/dist/tools/update/approve-payroll-timesheet.tool.js +29 -0
  119. package/dist/tools/update/index.js +28 -0
  120. package/dist/tools/update/revert-payroll-timesheet.tool.js +29 -0
  121. package/dist/tools/update/update-bank-transaction.tool.js +56 -0
  122. package/dist/tools/update/update-contact.tool.js +69 -0
  123. package/dist/tools/update/update-credit-note.tool.js +56 -0
  124. package/dist/tools/update/update-invoice.tool.js +74 -0
  125. package/dist/tools/update/update-item.tool.js +62 -0
  126. package/dist/tools/update/update-manual-journal-tool.js +89 -0
  127. package/dist/tools/update/update-payroll-timesheet-add-line.tool.js +34 -0
  128. package/dist/tools/update/update-payroll-timesheet-update-line.tool.js +35 -0
  129. package/dist/tools/update/update-quote.tool.js +61 -0
  130. package/dist/tools/update/update-tracking-category.tool.js +30 -0
  131. package/dist/tools/update/update-tracking-options.tool.js +35 -0
  132. package/dist/types/list-report-balance-sheet-params.js +1 -0
  133. package/dist/types/timeframeType.js +1 -0
  134. package/dist/types/tool-definition.js +1 -0
  135. package/dist/types/tool-list.js +1 -0
  136. package/dist/types/tool-response.js +1 -0
  137. package/package.json +63 -0
@@ -0,0 +1,72 @@
1
+ import { z } from "zod";
2
+ import { listXeroQuotes } from "../../handlers/list-xero-quotes.handler.js";
3
+ import { CreateXeroTool } from "../../helpers/create-xero-tool.js";
4
+ const ListQuotesTool = CreateXeroTool("list-quotes", `List all quotes in Xero.
5
+ Ask the user if they want to see quotes for a specific contact before running.
6
+ Ask the user if they want the next page of quotes after running this tool if 10 quotes are returned.
7
+ If they do, call this tool again with the page number and the contact provided in the previous call.
8
+
9
+ COMMON MISTAKES:
10
+ - Only use the params listed above. Do not invent additional filter or sort params.
11
+ - There is no "search", "query", "filter", "sortBy", "limit", or "offset" param.`, {
12
+ page: z.number(),
13
+ contactId: z.string().optional(),
14
+ quoteNumber: z.string().optional(),
15
+ }, async ({ page, contactId, quoteNumber }) => {
16
+ const response = await listXeroQuotes(page, contactId, quoteNumber);
17
+ if (response.error !== null) {
18
+ return {
19
+ content: [
20
+ {
21
+ type: "text",
22
+ text: `Error listing quotes: ${response.error}`,
23
+ },
24
+ ],
25
+ };
26
+ }
27
+ const quotes = response.result;
28
+ return {
29
+ content: [
30
+ {
31
+ type: "text",
32
+ text: `Found ${quotes?.length || 0} quotes:`,
33
+ },
34
+ ...(quotes?.map((quote) => ({
35
+ type: "text",
36
+ text: [
37
+ `Quote ID: ${quote.quoteID}`,
38
+ `Quote Number: ${quote.quoteNumber}`,
39
+ quote.reference ? `Reference: ${quote.reference}` : null,
40
+ `Status: ${quote.status || "Unknown"}`,
41
+ quote.contact
42
+ ? `Contact: ${quote.contact.name} (${quote.contact.contactID})`
43
+ : null,
44
+ quote.dateString ? `Quote Date: ${quote.dateString}` : null,
45
+ quote.expiryDateString
46
+ ? `Expiry Date: ${quote.expiryDateString}`
47
+ : null,
48
+ quote.title ? `Title: ${quote.title}` : null,
49
+ quote.summary ? `Summary: ${quote.summary}` : null,
50
+ quote.terms ? `Terms: ${quote.terms}` : null,
51
+ quote.lineAmountTypes
52
+ ? `Line Amount Types: ${quote.lineAmountTypes}`
53
+ : null,
54
+ quote.subTotal ? `Sub Total: ${quote.subTotal}` : null,
55
+ quote.totalTax ? `Total Tax: ${quote.totalTax}` : null,
56
+ `Total: ${quote.total || 0}`,
57
+ quote.totalDiscount
58
+ ? `Total Discount: ${quote.totalDiscount}`
59
+ : null,
60
+ quote.currencyCode ? `Currency: ${quote.currencyCode}` : null,
61
+ quote.currencyRate ? `Currency Rate: ${quote.currencyRate}` : null,
62
+ quote.updatedDateUTC
63
+ ? `Last Updated: ${quote.updatedDateUTC}`
64
+ : null,
65
+ ]
66
+ .filter(Boolean)
67
+ .join("\n"),
68
+ })) || []),
69
+ ],
70
+ };
71
+ });
72
+ export default ListQuotesTool;
@@ -0,0 +1,39 @@
1
+ import { z } from "zod";
2
+ import { listXeroReportBalanceSheet } from "../../handlers/list-xero-report-balance-sheet.handler.js";
3
+ import { CreateXeroTool } from "../../helpers/create-xero-tool.js";
4
+ const ListReportBalanceSheetTool = CreateXeroTool("list-report-balance-sheet", "List the Balance Sheet report from Xero.", {
5
+ date: z.string().optional().describe("Optional date in YYYY-MM-DD format"),
6
+ periods: z.number().optional().describe("Optional number of periods to compare"),
7
+ timeframe: z.enum(["MONTH", "QUARTER", "YEAR"]).optional().describe("Optional timeframe for the report (MONTH, QUARTER, YEAR)"),
8
+ trackingOptionID1: z.string().optional().describe("Optional tracking option ID 1"),
9
+ trackingOptionID2: z.string().optional().describe("Optional tracking option ID 2"),
10
+ standardLayout: z.boolean().optional().describe("Optional flag to use standard layout"),
11
+ paymentsOnly: z.boolean().optional().describe("Optional flag to include only accounts with payments"),
12
+ }, async (args) => {
13
+ const response = await listXeroReportBalanceSheet(args);
14
+ // Check if the response contains an error
15
+ if (response.error !== null) {
16
+ return {
17
+ content: [
18
+ {
19
+ type: "text",
20
+ text: `Error listing balance sheet report: ${response.error}`,
21
+ },
22
+ ],
23
+ };
24
+ }
25
+ const balanceSheetReport = response.result;
26
+ return {
27
+ content: [
28
+ {
29
+ type: "text",
30
+ text: `Balance sheet Report: ${balanceSheetReport?.reportName ?? "Unnamed"}`,
31
+ },
32
+ {
33
+ type: "text",
34
+ text: JSON.stringify(balanceSheetReport.rows, null, 2),
35
+ },
36
+ ],
37
+ };
38
+ });
39
+ export default ListReportBalanceSheetTool;
@@ -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,41 @@
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
+ 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.", {
5
+ date: z.string().optional().describe("Optional date in YYYY-MM-DD format"),
6
+ paymentsOnly: z.boolean().optional().describe("Optional flag to include only accounts with payments"),
7
+ }, async (args) => {
8
+ const response = await listXeroTrialBalance(args?.date, args?.paymentsOnly);
9
+ if (response.error !== null) {
10
+ return {
11
+ content: [
12
+ {
13
+ type: "text",
14
+ text: `Error listing trial balance: ${response.error}`,
15
+ },
16
+ ],
17
+ };
18
+ }
19
+ const trialBalanceReport = response.result;
20
+ return {
21
+ content: [
22
+ {
23
+ type: "text",
24
+ text: `Trial Balance Report: ${trialBalanceReport?.reportName || "Unnamed"}`,
25
+ },
26
+ {
27
+ type: "text",
28
+ text: `Date: ${trialBalanceReport?.reportDate || "Not specified"}`,
29
+ },
30
+ {
31
+ type: "text",
32
+ text: `Updated At: ${trialBalanceReport?.updatedDateUTC ? trialBalanceReport.updatedDateUTC.toISOString() : "Unknown"}`,
33
+ },
34
+ {
35
+ type: "text",
36
+ text: JSON.stringify(trialBalanceReport.rows, null, 2),
37
+ },
38
+ ],
39
+ };
40
+ });
41
+ export default ListTrialBalanceTool;
@@ -0,0 +1,24 @@
1
+ import { CreateTools } from "./create/index.js";
2
+ import { DeleteTools } from "./delete/index.js";
3
+ import { GetTools } from "./get/index.js";
4
+ import { HistoryTools } from "./history/index.js";
5
+ import { ListTools } from "./list/index.js";
6
+ import { UpdateTools } from "./update/index.js";
7
+ const READ_ONLY_ANNOTATIONS = {
8
+ readOnlyHint: true,
9
+ destructiveHint: false,
10
+ openWorldHint: true,
11
+ };
12
+ const WRITE_ANNOTATIONS = {
13
+ readOnlyHint: false,
14
+ destructiveHint: true,
15
+ openWorldHint: true,
16
+ };
17
+ export function ToolFactory(server) {
18
+ DeleteTools.map((tool) => tool()).forEach((tool) => server.tool(tool.name, tool.description, tool.schema, WRITE_ANNOTATIONS, tool.handler));
19
+ GetTools.map((tool) => tool()).forEach((tool) => server.tool(tool.name, tool.description, tool.schema, READ_ONLY_ANNOTATIONS, tool.handler));
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));
22
+ ListTools.map((tool) => tool()).forEach((tool) => server.tool(tool.name, tool.description, tool.schema, READ_ONLY_ANNOTATIONS, tool.handler));
23
+ UpdateTools.map((tool) => tool()).forEach((tool) => server.tool(tool.name, tool.description, tool.schema, WRITE_ANNOTATIONS, 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,28 @@
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
+ export const UpdateTools = [
15
+ UpdateContactTool,
16
+ UpdateCreditNoteTool,
17
+ UpdateInvoiceTool,
18
+ UpdateManualJournalTool,
19
+ UpdateQuoteTool,
20
+ UpdateItemTool,
21
+ UpdateBankTransactionTool,
22
+ ApprovePayrollTimesheetTool,
23
+ AddTimesheetLineTool,
24
+ UpdatePayrollTimesheetLineTool,
25
+ RevertPayrollTimesheetTool,
26
+ UpdateTrackingCategoryTool,
27
+ UpdateTrackingOptionsTool
28
+ ];
@@ -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,74 @@
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 { CurrencyCode, Invoice } from "xero-node";
6
+ const trackingSchema = z.object({
7
+ name: z.string().describe("The name of the tracking category. Can be obtained from the list-tracking-categories tool"),
8
+ option: z.string().describe("The name of the tracking option. Can be obtained from the list-tracking-categories tool"),
9
+ trackingCategoryID: z.string().describe("The ID of the tracking category. \
10
+ Can be obtained from the list-tracking-categories tool"),
11
+ });
12
+ const lineItemSchema = z.object({
13
+ description: z.string().describe("The description of the line item"),
14
+ quantity: z.number().describe("The quantity of the line item"),
15
+ unitAmount: z.number().describe("The price per unit of the line item"),
16
+ accountCode: z.string().describe("The account code of the line item - can be obtained from the list-accounts tool"),
17
+ taxType: z.string().describe("The tax type of the line item - can be obtained from the list-tax-rates tool"),
18
+ itemCode: z.string().describe("The item code of the line item - can be obtained from the list-items tool \
19
+ If the item was not populated in the original invoice, \
20
+ add without an item code unless the user has told you to add an item code.").optional(),
21
+ tracking: z.array(trackingSchema).describe("Up to 2 tracking categories and options can be added to the line item. \
22
+ Can be obtained from the list-tracking-categories tool. \
23
+ Only use if prompted by the user.").optional(),
24
+ });
25
+ const UpdateInvoiceTool = CreateXeroTool("update-invoice", "Update an invoice in Xero. Only works on draft invoices.\
26
+ All line items must be provided. Any line items not provided will be removed. Including existing line items.\
27
+ Do not modify line items that have not been specified by the user.\
28
+ When an invoice is updated, a deep link to the invoice in Xero is returned. \
29
+ This deep link can be used to view the contact in Xero directly. \
30
+ This link should be displayed to the user.", {
31
+ invoiceId: z.string().describe("The ID of the invoice to update."),
32
+ lineItems: z.array(lineItemSchema).optional().describe("All line items must be provided. Any line items not provided will be removed. Including existing line items. \
33
+ Do not modify line items that have not been specified by the user"),
34
+ reference: z.string().optional().describe("A reference number for the invoice."),
35
+ dueDate: z.string().optional().describe("The due date of the invoice."),
36
+ date: z.string().optional().describe("The date of the invoice."),
37
+ contactId: z.string().optional().describe("The ID of the contact to update the invoice for. \
38
+ Can be obtained from the list-contacts tool."),
39
+ currencyCode: z.nativeEnum(CurrencyCode).optional().describe("Optional invoice currency, such as USD. Only use a currency enabled in the connected Xero organisation."),
40
+ }, async ({ invoiceId, lineItems, reference, dueDate, date, contactId, currencyCode, }) => {
41
+ const result = await updateXeroInvoice(invoiceId, lineItems, reference, dueDate, date, contactId, currencyCode);
42
+ if (result.isError) {
43
+ return {
44
+ content: [
45
+ {
46
+ type: "text",
47
+ text: `Error updating invoice: ${result.error}`,
48
+ },
49
+ ],
50
+ };
51
+ }
52
+ const invoice = result.result;
53
+ const deepLink = invoice.invoiceID
54
+ ? await getDeepLink(invoice.type === Invoice.TypeEnum.ACCREC ? DeepLinkType.INVOICE : DeepLinkType.BILL, invoice.invoiceID)
55
+ : null;
56
+ return {
57
+ content: [
58
+ {
59
+ type: "text",
60
+ text: [
61
+ "Invoice updated successfully:",
62
+ `ID: ${invoice?.invoiceID}`,
63
+ `Contact: ${invoice?.contact?.name}`,
64
+ `Type: ${invoice?.type}`,
65
+ invoice?.currencyCode ? `Currency: ${invoice.currencyCode}` : null,
66
+ `Total: ${invoice?.total}`,
67
+ `Status: ${invoice?.status}`,
68
+ deepLink ? `Link to view: ${deepLink}` : null,
69
+ ].filter(Boolean).join("\n"),
70
+ },
71
+ ],
72
+ };
73
+ });
74
+ export default UpdateInvoiceTool;