@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,89 @@
1
+ import { z } from "zod";
2
+ import { CreateXeroTool } from "../../helpers/create-xero-tool.js";
3
+ import { DeepLinkType, getDeepLink } from "../../helpers/get-deeplink.js";
4
+ import { ensureError } from "../../helpers/ensure-error.js";
5
+ import { updateXeroManualJournal } from "../../handlers/update-xero-manual-journal.handler.js";
6
+ const UpdateManualJournalTool = CreateXeroTool("update-manual-journal", "Update a manual journal in Xero. Only works on draft manual journals.\
7
+ Do not modify line items or parameters that have not been specified by the user.", {
8
+ narration: z
9
+ .string()
10
+ .describe("Description of manual journal being posted"),
11
+ manualJournalID: z.string().describe("ID of the manual journal to update"),
12
+ manualJournalLines: z
13
+ .array(z.object({
14
+ lineAmount: z
15
+ .number()
16
+ .describe("Total for manual journal line. Debits are positive, credits are negative value"),
17
+ accountCode: z.string().describe("Account code for the journal line"),
18
+ description: z
19
+ .string()
20
+ .optional()
21
+ .describe("Optional description for manual journal line"),
22
+ taxType: z
23
+ .string()
24
+ .optional()
25
+ .describe("Optional tax type for the manual journal line"),
26
+ // TODO: TODO: tracking can be added here
27
+ }))
28
+ .describe("The manualJournalLines element must contain at least two individual manualJournalLine sub-elements"),
29
+ date: z.string().optional().describe("Optional date in YYYY-MM-DD format"),
30
+ lineAmountTypes: z
31
+ .enum(["EXCLUSIVE", "INCLUSIVE", "NO_TAX"])
32
+ .optional()
33
+ .describe("Optional line amount types (EXCLUSIVE, INCLUSIVE, NO_TAX), NO_TAX by default"),
34
+ status: z
35
+ .enum(["DRAFT", "POSTED", "DELETED", "VOIDED", "ARCHIVED"])
36
+ .optional()
37
+ .describe("Optional status of the manual journal (DRAFT, POSTED, DELETED, VOIDED, ARCHIVED), DRAFT by default"),
38
+ url: z
39
+ .string()
40
+ .optional()
41
+ .describe("Optional URL link to a source document"),
42
+ showOnCashBasisReports: z
43
+ .boolean()
44
+ .optional()
45
+ .describe("Optional boolean to show on cash basis reports, default is true"),
46
+ }, async (args) => {
47
+ try {
48
+ const response = await updateXeroManualJournal(args.narration, args.manualJournalID, args.manualJournalLines, args.date, args.lineAmountTypes, args.status, args.url, args.showOnCashBasisReports);
49
+ if (response.isError) {
50
+ return {
51
+ content: [
52
+ {
53
+ type: "text",
54
+ text: `Error updating manual journal: ${response.error}`,
55
+ },
56
+ ],
57
+ };
58
+ }
59
+ const manualJournal = response.result;
60
+ const deepLink = manualJournal.manualJournalID
61
+ ? await getDeepLink(DeepLinkType.MANUAL_JOURNAL, manualJournal.manualJournalID)
62
+ : null;
63
+ return {
64
+ content: [
65
+ {
66
+ type: "text",
67
+ text: [
68
+ `Manual journal updated: ${manualJournal.narration} (ID: ${manualJournal.manualJournalID})`,
69
+ deepLink ? `Link to view: ${deepLink}` : null,
70
+ ]
71
+ .filter(Boolean)
72
+ .join("\n"),
73
+ },
74
+ ],
75
+ };
76
+ }
77
+ catch (error) {
78
+ const err = ensureError(error);
79
+ return {
80
+ content: [
81
+ {
82
+ type: "text",
83
+ text: `Error updating manual journal: ${err.message}`,
84
+ },
85
+ ],
86
+ };
87
+ }
88
+ });
89
+ export default UpdateManualJournalTool;
@@ -0,0 +1,34 @@
1
+ import { z } from "zod";
2
+ import { updateXeroPayrollTimesheetAddLine, } from "../../handlers/update-xero-payroll-timesheet-add-line.handler.js";
3
+ import { CreateXeroTool } from "../../helpers/create-xero-tool.js";
4
+ const AddTimesheetLineTool = CreateXeroTool("add-timesheet-line", `Add a new timesheet line to an existing payroll timesheet in Xero.`, {
5
+ timesheetID: z.string().describe("The ID of the timesheet to update."),
6
+ timesheetLine: z.object({
7
+ earningsRateID: z.string().describe("The ID of the earnings rate."),
8
+ numberOfUnits: z.number().describe("The number of units for the timesheet line."),
9
+ date: z.string().describe("The date for the timesheet line (YYYY-MM-DD)."),
10
+ }).describe("The details of the timesheet line to add."),
11
+ }, async (params) => {
12
+ const { timesheetID, timesheetLine } = params;
13
+ const response = await updateXeroPayrollTimesheetAddLine(timesheetID, timesheetLine);
14
+ if (response.isError) {
15
+ return {
16
+ content: [
17
+ {
18
+ type: "text",
19
+ text: `Error adding timesheet line: ${response.error}`,
20
+ },
21
+ ],
22
+ };
23
+ }
24
+ const newLine = response.result;
25
+ return {
26
+ content: [
27
+ {
28
+ type: "text",
29
+ text: `Successfully added timesheet line with date: ${newLine?.date}`,
30
+ },
31
+ ],
32
+ };
33
+ });
34
+ export default AddTimesheetLineTool;
@@ -0,0 +1,35 @@
1
+ import { z } from "zod";
2
+ import { updateXeroPayrollTimesheetUpdateLine, } from "../../handlers/update-xero-payroll-timesheet-update-line.handler.js";
3
+ import { CreateXeroTool } from "../../helpers/create-xero-tool.js";
4
+ const UpdatePayrollTimesheetLineTool = CreateXeroTool("update-timesheet-line", `Update an existing timesheet line in a payroll timesheet in Xero.`, {
5
+ timesheetID: z.string().describe("The ID of the timesheet to update."),
6
+ timesheetLineID: z.string().describe("The ID of the timesheet line to update."),
7
+ timesheetLine: z.object({
8
+ earningsRateID: z.string().describe("The ID of the earnings rate."),
9
+ numberOfUnits: z.number().describe("The number of units for the timesheet line."),
10
+ date: z.string().describe("The date for the timesheet line (YYYY-MM-DD)."),
11
+ }).describe("The details of the timesheet line to update."),
12
+ }, async (params) => {
13
+ const { timesheetID, timesheetLineID, timesheetLine } = params;
14
+ const response = await updateXeroPayrollTimesheetUpdateLine(timesheetID, timesheetLineID, timesheetLine);
15
+ if (response.isError) {
16
+ return {
17
+ content: [
18
+ {
19
+ type: "text",
20
+ text: `Error updating timesheet line: ${response.error}`,
21
+ },
22
+ ],
23
+ };
24
+ }
25
+ const updatedLine = response.result;
26
+ return {
27
+ content: [
28
+ {
29
+ type: "text",
30
+ text: `Successfully updated timesheet line with date: ${updatedLine?.date}`,
31
+ },
32
+ ],
33
+ };
34
+ });
35
+ export default UpdatePayrollTimesheetLineTool;
@@ -0,0 +1,61 @@
1
+ import { z } from "zod";
2
+ import { updateXeroQuote } from "../../handlers/update-xero-quote.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 UpdateQuoteTool = CreateXeroTool("update-quote", "Update a quote in Xero. Only works on draft quotes.\
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 quote is updated, a deep link to the quote in Xero is returned. \
16
+ This deep link can be used to view the quote in Xero directly. \
17
+ This link should be displayed to the user.", {
18
+ quoteId: 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
+ terms: z.string().optional(),
23
+ title: z.string().optional(),
24
+ summary: z.string().optional(),
25
+ quoteNumber: z.string().optional(),
26
+ contactId: z.string().optional(),
27
+ date: z.string().optional(),
28
+ expiryDate: z.string().optional(),
29
+ }, async ({ quoteId, lineItems, reference, terms, title, summary, quoteNumber, contactId, date, expiryDate, }) => {
30
+ const result = await updateXeroQuote(quoteId, lineItems, reference, terms, title, summary, quoteNumber, contactId, date, expiryDate);
31
+ if (result.isError) {
32
+ return {
33
+ content: [
34
+ {
35
+ type: "text",
36
+ text: `Error updating quote: ${result.error}`,
37
+ },
38
+ ],
39
+ };
40
+ }
41
+ const quote = result.result;
42
+ const deepLink = quote.quoteID
43
+ ? await getDeepLink(DeepLinkType.QUOTE, quote.quoteID)
44
+ : null;
45
+ return {
46
+ content: [
47
+ {
48
+ type: "text",
49
+ text: [
50
+ "Quote updated successfully:",
51
+ `ID: ${quote?.quoteID}`,
52
+ `Contact: ${quote?.contact?.name}`,
53
+ `Total: ${quote?.total}`,
54
+ `Status: ${quote?.status}`,
55
+ deepLink ? `Link to view: ${deepLink}` : null,
56
+ ].join("\n"),
57
+ },
58
+ ],
59
+ };
60
+ });
61
+ export default UpdateQuoteTool;
@@ -0,0 +1,30 @@
1
+ import { z } from "zod";
2
+ import { CreateXeroTool } from "../../helpers/create-xero-tool.js";
3
+ import { updateXeroTrackingCategory } from "../../handlers/update-xero-tracking-category.handler.js";
4
+ const UpdateTrackingCategoryTool = CreateXeroTool("update-tracking-category", `Updates an existing tracking category in Xero.`, {
5
+ trackingCategoryId: z.string(),
6
+ name: z.string().optional(),
7
+ status: z.enum(["ACTIVE", "ARCHIVED"]).optional()
8
+ }, async ({ trackingCategoryId, name, status }) => {
9
+ const response = await updateXeroTrackingCategory(trackingCategoryId, name, status);
10
+ if (response.isError) {
11
+ return {
12
+ content: [
13
+ {
14
+ type: "text",
15
+ text: `Error while updating tracking category: ${response.error}`
16
+ }
17
+ ]
18
+ };
19
+ }
20
+ const trackingCategory = response.result;
21
+ return {
22
+ content: [
23
+ {
24
+ type: "text",
25
+ text: `Updated the tracking category "${trackingCategory.name}" (${trackingCategory.trackingCategoryID}).`
26
+ },
27
+ ]
28
+ };
29
+ });
30
+ export default UpdateTrackingCategoryTool;
@@ -0,0 +1,35 @@
1
+ import { z } from "zod";
2
+ import { CreateXeroTool } from "../../helpers/create-xero-tool.js";
3
+ import { formatTrackingOption } from "../../helpers/format-tracking-option.js";
4
+ import { updateXeroTrackingOption } from "../../handlers/update-xero-tracking-options.handler.js";
5
+ const trackingOptionSchema = z.object({
6
+ trackingOptionId: z.string(),
7
+ name: z.string().optional(),
8
+ status: z.enum(["ACTIVE", "ARCHIVED"]).optional()
9
+ });
10
+ const UpdateTrackingOptionsTool = CreateXeroTool("update-tracking-options", `Updates tracking options for a tracking category in Xero.`, {
11
+ trackingCategoryId: z.string(),
12
+ options: z.array(trackingOptionSchema).max(10)
13
+ }, async ({ trackingCategoryId, options }) => {
14
+ const response = await updateXeroTrackingOption(trackingCategoryId, options);
15
+ if (response.isError) {
16
+ return {
17
+ content: [
18
+ {
19
+ type: "text",
20
+ text: `Error while creating tracking options: ${response.error}`
21
+ }
22
+ ]
23
+ };
24
+ }
25
+ const trackingOptions = response.result;
26
+ return {
27
+ content: [
28
+ {
29
+ type: "text",
30
+ text: `${trackingOptions.length || 0} out of ${options.length} tracking options updated:\n${trackingOptions.map(formatTrackingOption)}`
31
+ },
32
+ ]
33
+ };
34
+ });
35
+ export default UpdateTrackingOptionsTool;
@@ -0,0 +1,33 @@
1
+ import { z } from "zod";
2
+ import { voidXeroInvoice } from "../../handlers/void-xero-invoice.handler.js";
3
+ import { CreateXeroTool } from "../../helpers/create-xero-tool.js";
4
+ import { Invoice } from "xero-node";
5
+ const VoidInvoiceTool = CreateXeroTool("void-invoice", "Void or delete an invoice in Xero. \
6
+ DRAFT invoices will be permanently DELETED. \
7
+ SUBMITTED or AUTHORISED invoices will be VOIDED. \
8
+ PAID invoices cannot be voided — a credit note must be used instead. \
9
+ Always confirm with the user before voiding, as this cannot be undone.", {
10
+ invoiceId: z.string().describe("The ID of the invoice to void or delete."),
11
+ }, async ({ invoiceId }) => {
12
+ const result = await voidXeroInvoice(invoiceId);
13
+ if (result.isError) {
14
+ return {
15
+ content: [{ type: "text", text: `Error: ${result.error}` }],
16
+ };
17
+ }
18
+ const invoice = result.result;
19
+ return {
20
+ content: [
21
+ {
22
+ type: "text",
23
+ text: [
24
+ `Invoice ${invoice.status === Invoice.StatusEnum.DELETED ? "deleted" : "voided"} successfully.`,
25
+ `Invoice ID: ${invoice.invoiceID}`,
26
+ `Invoice Number: ${invoice.invoiceNumber ?? "N/A"}`,
27
+ `Status: ${invoice.status}`,
28
+ ].join("\n"),
29
+ },
30
+ ],
31
+ };
32
+ });
33
+ export default VoidInvoiceTool;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
package/package.json ADDED
@@ -0,0 +1,38 @@
1
+ {
2
+ "name": "@teamnetwork-nz/xero-mcp-server",
3
+ "version": "1.6.0",
4
+ "description": "MCP server implementation for Xero integration - TEAMnetwork",
5
+ "license": "MIT",
6
+ "main": "dist/index.js",
7
+ "author": "Daryl Petersen - TEAMnetwork (https://teamnetwork.co.nz)",
8
+ "type": "module",
9
+ "bin": "./dist/index.js",
10
+ "files": [
11
+ "dist"
12
+ ],
13
+ "scripts": {
14
+ "build": "tsc && shx chmod +x dist/*.js",
15
+ "prepare": "npm run build",
16
+ "watch": "tsc --watch",
17
+ "lint:fix": "eslint --fix",
18
+ "lint": "eslint ."
19
+ },
20
+ "dependencies": {
21
+ "@modelcontextprotocol/sdk": "^1.23.4",
22
+ "dotenv": "^16.4.7",
23
+ "openid-client": "^6.8.1",
24
+ "xero-node": "^13.3.0",
25
+ "zod": "3.25"
26
+ },
27
+ "devDependencies": {
28
+ "@eslint/js": "^9.39.1",
29
+ "@types/node": "^22.13.10",
30
+ "eslint": "^9.39.1",
31
+ "eslint-config-prettier": "^10.1.8",
32
+ "globals": "^16.5.0",
33
+ "prettier": "3.7.4",
34
+ "shx": "^0.3.4",
35
+ "typescript": "^5.9.3",
36
+ "typescript-eslint": "^8.48.1"
37
+ }
38
+ }