@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,71 @@
1
+ import { z } from "zod";
2
+ import { createXeroPayment } from "../../handlers/create-xero-payment.handler.js";
3
+ import { DeepLinkType, getDeepLink } from "../../helpers/get-deeplink.js";
4
+ import { CreateXeroTool } from "../../helpers/create-xero-tool.js";
5
+ const CreatePaymentTool = CreateXeroTool("create-payment", "Create a payment against an invoice in Xero.\
6
+ This tool records a payment transaction against an invoice. \
7
+ You'll need to provide the invoice ID, account ID to make the payment from, and the amount. \
8
+ The amount must be positive and should not exceed the remaining amount due on the invoice. \
9
+ A payment can only be created for an invoice that is status AUTHORIZED \
10
+ A payment can only be created for an invoice that is not fully paid \
11
+ When a payment is created, a deep link to the payment in Xero is returned. \
12
+ This deep link can be used to view the payment in Xero directly. \
13
+ This link should be displayed to the user.", {
14
+ invoiceId: z.string().describe("The ID of the invoice to pay"),
15
+ accountId: z
16
+ .string()
17
+ .describe("The ID of the account the payment is made from"),
18
+ amount: z
19
+ .number()
20
+ .positive()
21
+ .describe("The amount of the payment (must be positive)"),
22
+ date: z
23
+ .string()
24
+ .optional()
25
+ .describe("Optional payment date in YYYY-MM-DD format"),
26
+ reference: z
27
+ .string()
28
+ .optional()
29
+ .describe("Optional payment reference/description"),
30
+ }, async ({ invoiceId, accountId, amount, date, reference }) => {
31
+ const result = await createXeroPayment({
32
+ invoiceId,
33
+ accountId,
34
+ amount,
35
+ date,
36
+ reference,
37
+ });
38
+ if (result.isError) {
39
+ return {
40
+ content: [
41
+ {
42
+ type: "text",
43
+ text: `Error creating payment: ${result.error}`,
44
+ },
45
+ ],
46
+ };
47
+ }
48
+ const payment = result.result;
49
+ const deepLink = payment.paymentID
50
+ ? await getDeepLink(DeepLinkType.PAYMENT, payment.paymentID)
51
+ : null;
52
+ return {
53
+ content: [
54
+ {
55
+ type: "text",
56
+ text: [
57
+ "Invoice created successfully:",
58
+ `ID: ${payment?.paymentID}`,
59
+ `Reference: ${payment?.reference}`,
60
+ `Invoice Number: ${payment?.invoiceNumber}`,
61
+ `Amount: ${payment?.amount}`,
62
+ `Status: ${payment?.status}`,
63
+ deepLink ? `Link to view: ${deepLink}` : null,
64
+ ]
65
+ .filter(Boolean)
66
+ .join("\n"),
67
+ },
68
+ ],
69
+ };
70
+ });
71
+ export default CreatePaymentTool;
@@ -0,0 +1,40 @@
1
+ import { z } from "zod";
2
+ import { createXeroPayrollTimesheet, } from "../../handlers/create-xero-payroll-timesheet.handler.js";
3
+ import { CreateXeroTool } from "../../helpers/create-xero-tool.js";
4
+ const CreatePayrollTimesheetTool = CreateXeroTool("create-timesheet", `Create a new payroll timesheet in Xero.
5
+ This allows you to specify details such as the employee ID, payroll calendar ID, start and end dates, and timesheet lines.`, {
6
+ payrollCalendarID: z.string().describe("The ID of the payroll calendar."),
7
+ employeeID: z.string().describe("The ID of the employee."),
8
+ startDate: z.string().describe("The start date of the timesheet period (YYYY-MM-DD)."),
9
+ endDate: z.string().describe("The end date of the timesheet period (YYYY-MM-DD)."),
10
+ timesheetLines: z
11
+ .array(z.object({
12
+ earningsRateID: z.string().describe("The ID of the earnings rate."),
13
+ numberOfUnits: z.number().describe("The number of units for the timesheet line."),
14
+ date: z.string().describe("The date for the timesheet line (YYYY-MM-DD)."),
15
+ }))
16
+ .optional()
17
+ .describe("The lines of the timesheet."),
18
+ }, async (params) => {
19
+ const response = await createXeroPayrollTimesheet(params);
20
+ if (response.isError) {
21
+ return {
22
+ content: [
23
+ {
24
+ type: "text",
25
+ text: `Error creating timesheet: ${response.error}`,
26
+ },
27
+ ],
28
+ };
29
+ }
30
+ const timesheet = response.result;
31
+ return {
32
+ content: [
33
+ {
34
+ type: "text",
35
+ text: `Successfully created timesheet with ID: ${timesheet?.timesheetID}`,
36
+ },
37
+ ],
38
+ };
39
+ });
40
+ export default CreatePayrollTimesheetTool;
@@ -0,0 +1,57 @@
1
+ import { z } from "zod";
2
+ import { createXeroQuote } from "../../handlers/create-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 CreateQuoteTool = CreateXeroTool("create-quote", "Create a quote in Xero.\
13
+ When a quote is created, a deep link to the quote in Xero is returned. \
14
+ This deep link can be used to view the quote in Xero directly. \
15
+ This link should be displayed to the user.", {
16
+ contactId: z.string(),
17
+ lineItems: z.array(lineItemSchema),
18
+ reference: z.string().optional(),
19
+ quoteNumber: z.string().optional(),
20
+ terms: z.string().optional(),
21
+ title: z.string().optional(),
22
+ summary: z.string().optional(),
23
+ }, async ({ contactId, lineItems, reference, quoteNumber, terms, title, summary, }) => {
24
+ const result = await createXeroQuote(contactId, lineItems, reference, quoteNumber, terms, title, summary);
25
+ if (result.isError) {
26
+ return {
27
+ content: [
28
+ {
29
+ type: "text",
30
+ text: `Error creating quote: ${result.error}`,
31
+ },
32
+ ],
33
+ };
34
+ }
35
+ const quote = result.result;
36
+ const deepLink = quote.quoteID
37
+ ? await getDeepLink(DeepLinkType.QUOTE, quote.quoteID)
38
+ : null;
39
+ return {
40
+ content: [
41
+ {
42
+ type: "text",
43
+ text: [
44
+ "Quote created successfully:",
45
+ `ID: ${quote?.quoteID}`,
46
+ `Contact: ${quote?.contact?.name}`,
47
+ `Total: ${quote?.total}`,
48
+ `Status: ${quote?.status}`,
49
+ deepLink ? `Link to view: ${deepLink}` : null,
50
+ ]
51
+ .filter(Boolean)
52
+ .join("\n"),
53
+ },
54
+ ],
55
+ };
56
+ });
57
+ export default CreateQuoteTool;
@@ -0,0 +1,28 @@
1
+ import { z } from "zod";
2
+ import { CreateXeroTool } from "../../helpers/create-xero-tool.js";
3
+ import { createXeroTrackingCategory } from "../../handlers/create-xero-tracking-category.handler.js";
4
+ const CreateTrackingCategoryTool = CreateXeroTool("create-tracking-category", `Create a tracking category in Xero.`, {
5
+ name: z.string()
6
+ }, async ({ name }) => {
7
+ const response = await createXeroTrackingCategory(name);
8
+ if (response.isError) {
9
+ return {
10
+ content: [
11
+ {
12
+ type: "text",
13
+ text: `Error while creating tracking category: ${response.error}`
14
+ }
15
+ ]
16
+ };
17
+ }
18
+ const trackingCategory = response.result;
19
+ return {
20
+ content: [
21
+ {
22
+ type: "text",
23
+ text: `Created the tracking category "${trackingCategory.name}" (${trackingCategory.trackingCategoryID}).`
24
+ },
25
+ ]
26
+ };
27
+ });
28
+ export default CreateTrackingCategoryTool;
@@ -0,0 +1,30 @@
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 { createXeroTrackingOptions } from "../../handlers/create-xero-tracking-option.handler.js";
5
+ const CreateTrackingOptionsTool = CreateXeroTool("create-tracking-options", `Create tracking options for a tracking category in Xero.`, {
6
+ trackingCategoryId: z.string(),
7
+ optionNames: z.array(z.string()).max(10)
8
+ }, async ({ trackingCategoryId, optionNames }) => {
9
+ const response = await createXeroTrackingOptions(trackingCategoryId, optionNames);
10
+ if (response.isError) {
11
+ return {
12
+ content: [
13
+ {
14
+ type: "text",
15
+ text: `Error while creating tracking options: ${response.error}`
16
+ }
17
+ ]
18
+ };
19
+ }
20
+ const trackingOptions = response.result;
21
+ return {
22
+ content: [
23
+ {
24
+ type: "text",
25
+ text: `${trackingOptions.length || 0} out of ${optionNames.length} tracking options created:\n${trackingOptions.map(formatTrackingOption)}`
26
+ },
27
+ ]
28
+ };
29
+ });
30
+ export default CreateTrackingOptionsTool;
@@ -0,0 +1,24 @@
1
+ import CreateBankTransactionTool from "./create-bank-transaction.tool.js";
2
+ import CreateContactTool from "./create-contact.tool.js";
3
+ import CreateCreditNoteTool from "./create-credit-note.tool.js";
4
+ import CreateInvoiceTool from "./create-invoice.tool.js";
5
+ import CreateItemTool from "./create-item.tool.js";
6
+ import CreateManualJournalTool from "./create-manual-journal.tool.js";
7
+ import CreatePaymentTool from "./create-payment.tool.js";
8
+ import CreatePayrollTimesheetTool from "./create-payroll-timesheet.tool.js";
9
+ import CreateQuoteTool from "./create-quote.tool.js";
10
+ import CreateTrackingCategoryTool from "./create-tracking-category.tool.js";
11
+ import CreateTrackingOptionsTool from "./create-tracking-options.tool.js";
12
+ export const CreateTools = [
13
+ CreateContactTool,
14
+ CreateCreditNoteTool,
15
+ CreateManualJournalTool,
16
+ CreateInvoiceTool,
17
+ CreateQuoteTool,
18
+ CreatePaymentTool,
19
+ CreateItemTool,
20
+ CreateBankTransactionTool,
21
+ CreatePayrollTimesheetTool,
22
+ CreateTrackingCategoryTool,
23
+ CreateTrackingOptionsTool
24
+ ];
@@ -0,0 +1,28 @@
1
+ import { z } from "zod";
2
+ import { deleteXeroPayrollTimesheet, } from "../../handlers/delete-xero-payroll-timesheet.handler.js";
3
+ import { CreateXeroTool } from "../../helpers/create-xero-tool.js";
4
+ const DeletePayrollTimesheetTool = CreateXeroTool("delete-timesheet", `Delete an existing payroll timesheet in Xero by its ID.`, {
5
+ timesheetID: z.string().describe("The ID of the timesheet to delete."),
6
+ }, async (params) => {
7
+ const { timesheetID } = params;
8
+ const response = await deleteXeroPayrollTimesheet(timesheetID);
9
+ if (response.isError) {
10
+ return {
11
+ content: [
12
+ {
13
+ type: "text",
14
+ text: `Error deleting timesheet: ${response.error}`,
15
+ },
16
+ ],
17
+ };
18
+ }
19
+ return {
20
+ content: [
21
+ {
22
+ type: "text",
23
+ text: `Successfully deleted timesheet with ID: ${timesheetID}`,
24
+ },
25
+ ],
26
+ };
27
+ });
28
+ export default DeletePayrollTimesheetTool;
@@ -0,0 +1,4 @@
1
+ import DeletePayrollTimesheetTool from "./delete-payroll-timesheet.tool.js";
2
+ export const DeleteTools = [
3
+ DeletePayrollTimesheetTool
4
+ ];
@@ -0,0 +1,45 @@
1
+ import { z } from "zod";
2
+ import { downloadXeroInvoiceAttachment } from "../../handlers/download-xero-invoice-attachment.handler.js";
3
+ import { CreateXeroTool } from "../../helpers/create-xero-tool.js";
4
+ const GetInvoiceAttachmentTool = CreateXeroTool("get-invoice-attachment-content", `Download the content of a specific invoice attachment from Xero.
5
+ Returns the file content as base64-encoded text along with MIME type and content length.
6
+ Use list-invoice-attachments first to get the exact FileName and MIME type.
7
+ The fileName must match exactly (case-sensitive).
8
+ Requires the accounting.attachments.read scope on the Xero Custom Connection.`, {
9
+ invoiceId: z.string().describe("The Xero Invoice ID (UUID)"),
10
+ fileName: z
11
+ .string()
12
+ .describe("Exact filename from list-invoice-attachments"),
13
+ contentType: z
14
+ .string()
15
+ .describe("MIME type from list-invoice-attachments (e.g. application/pdf, image/png)"),
16
+ }, async ({ invoiceId, fileName, contentType }) => {
17
+ const response = await downloadXeroInvoiceAttachment(invoiceId, fileName, contentType);
18
+ if (response.error !== null) {
19
+ return {
20
+ content: [
21
+ {
22
+ type: "text",
23
+ text: `Error downloading attachment: ${response.error}`,
24
+ },
25
+ ],
26
+ };
27
+ }
28
+ const result = response.result;
29
+ return {
30
+ content: [
31
+ {
32
+ type: "text",
33
+ text: [
34
+ `File Name: ${result.fileName}`,
35
+ `MIME Type: ${result.mimeType}`,
36
+ `Content Length: ${result.contentLength} bytes`,
37
+ `Encoding: base64`,
38
+ `Content:`,
39
+ result.base64,
40
+ ].join("\n"),
41
+ },
42
+ ],
43
+ };
44
+ });
45
+ export default GetInvoiceAttachmentTool;
@@ -0,0 +1,49 @@
1
+ import { z } from "zod";
2
+ import { getXeroPayrollTimesheet, } from "../../handlers/get-xero-payroll-timesheet.handler.js";
3
+ import { CreateXeroTool } from "../../helpers/create-xero-tool.js";
4
+ const GetPayrollTimesheetTool = CreateXeroTool("get-timesheet", `Retrieve a single payroll timesheet from Xero by its ID.
5
+ This provides details such as the timesheet ID, employee ID, start and end dates, total hours, and the last updated date.`, {
6
+ timesheetID: z.string().describe("The ID of the timesheet to retrieve."),
7
+ }, async (params) => {
8
+ const { timesheetID } = params;
9
+ const response = await getXeroPayrollTimesheet(timesheetID);
10
+ if (response.isError) {
11
+ return {
12
+ content: [
13
+ {
14
+ type: "text",
15
+ text: `Error retrieving timesheet: ${response.error}`,
16
+ },
17
+ ],
18
+ };
19
+ }
20
+ const timesheet = response.result;
21
+ if (!timesheet) {
22
+ return {
23
+ content: [
24
+ {
25
+ type: "text",
26
+ text: `No timesheet found with ID: ${timesheetID}`,
27
+ },
28
+ ],
29
+ };
30
+ }
31
+ return {
32
+ content: [
33
+ {
34
+ type: "text",
35
+ text: [
36
+ `Timesheet ID: ${timesheet.timesheetID}`,
37
+ `Employee ID: ${timesheet.employeeID}`,
38
+ `Start Date: ${timesheet.startDate}`,
39
+ `End Date: ${timesheet.endDate}`,
40
+ `Total Hours: ${timesheet.totalHours}`,
41
+ `Last Updated: ${timesheet.updatedDateUTC}`,
42
+ ]
43
+ .filter(Boolean)
44
+ .join("\n"),
45
+ },
46
+ ],
47
+ };
48
+ });
49
+ export default GetPayrollTimesheetTool;
@@ -0,0 +1,6 @@
1
+ import GetPayrollTimesheetTool from "./get-payroll-timesheet.tool.js";
2
+ import GetInvoiceAttachmentTool from "./get-invoice-attachment.tool.js";
3
+ export const GetTools = [
4
+ GetPayrollTimesheetTool,
5
+ GetInvoiceAttachmentTool,
6
+ ];
@@ -0,0 +1,141 @@
1
+ import { z } from "zod";
2
+ import { CreateXeroTool } from "../../helpers/create-xero-tool.js";
3
+ import { addEntityNote, getEntityHistory, } from "../../handlers/history-handler-factory.js";
4
+ import { xeroClient } from "../../clients/xero-client.js";
5
+ const HISTORY_ENTITIES = [
6
+ {
7
+ entity: "invoice",
8
+ idParam: "invoiceID",
9
+ idDescription: "The Xero invoice ID.",
10
+ config: {
11
+ getMethod: xeroClient.accountingApi.getInvoiceHistory,
12
+ createMethod: xeroClient.accountingApi.createInvoiceHistory,
13
+ },
14
+ },
15
+ {
16
+ entity: "contact",
17
+ idParam: "contactID",
18
+ idDescription: "The Xero contact ID.",
19
+ config: {
20
+ getMethod: xeroClient.accountingApi.getContactHistory,
21
+ createMethod: xeroClient.accountingApi.createContactHistory,
22
+ },
23
+ },
24
+ {
25
+ entity: "credit-note",
26
+ idParam: "creditNoteID",
27
+ idDescription: "The Xero credit note ID.",
28
+ config: {
29
+ getMethod: xeroClient.accountingApi.getCreditNoteHistory,
30
+ createMethod: xeroClient.accountingApi.createCreditNoteHistory,
31
+ },
32
+ },
33
+ {
34
+ entity: "bank-transaction",
35
+ idParam: "bankTransactionID",
36
+ idDescription: "The Xero bank transaction ID.",
37
+ config: {
38
+ getMethod: xeroClient.accountingApi.getBankTransactionsHistory,
39
+ createMethod: xeroClient.accountingApi.createBankTransactionHistoryRecord,
40
+ },
41
+ },
42
+ {
43
+ entity: "quote",
44
+ idParam: "quoteID",
45
+ idDescription: "The Xero quote ID.",
46
+ config: {
47
+ getMethod: xeroClient.accountingApi.getQuoteHistory,
48
+ createMethod: xeroClient.accountingApi.createQuoteHistory,
49
+ },
50
+ },
51
+ ];
52
+ function formatHistoryRecord(record) {
53
+ return [
54
+ record.dateUTC ? `Date: ${record.dateUTC}` : null,
55
+ record.user ? `User: ${record.user}` : null,
56
+ record.details ? `Details: ${record.details}` : null,
57
+ record.changes ? `Changes: ${record.changes}` : null,
58
+ ]
59
+ .filter(Boolean)
60
+ .join("\n");
61
+ }
62
+ function createGetHistoryTool(def) {
63
+ return CreateXeroTool(`get-${def.entity}-history`, `Retrieve the history (audit trail) for a specific ${def.entity} in Xero. Returns history records including dates, users, details, and changes.`, {
64
+ [def.idParam]: z.string().describe(def.idDescription),
65
+ }, async (params) => {
66
+ const entityId = params[def.idParam];
67
+ const response = await getEntityHistory(entityId, def.config);
68
+ if (response.isError) {
69
+ return {
70
+ content: [
71
+ {
72
+ type: "text",
73
+ text: `Error retrieving ${def.entity} history: ${response.error}`,
74
+ },
75
+ ],
76
+ };
77
+ }
78
+ const records = response.result;
79
+ if (records.length === 0) {
80
+ return {
81
+ content: [
82
+ {
83
+ type: "text",
84
+ text: `No history found for ${def.entity}: ${entityId}`,
85
+ },
86
+ ],
87
+ };
88
+ }
89
+ const formatted = records.map(formatHistoryRecord).join("\n---\n");
90
+ return {
91
+ content: [
92
+ {
93
+ type: "text",
94
+ text: `History for ${def.entity} ${entityId} (${records.length} record${records.length === 1 ? "" : "s"}):\n\n${formatted}`,
95
+ },
96
+ ],
97
+ };
98
+ });
99
+ }
100
+ function createAddNoteTool(def) {
101
+ return CreateXeroTool(`add-${def.entity}-note`, `Add a note to a specific ${def.entity} in Xero. Notes appear in the entity's history/audit trail. Notes are immutable once created.`, {
102
+ [def.idParam]: z.string().describe(def.idDescription),
103
+ note: z
104
+ .string()
105
+ .describe("The note text to add. This is immutable and cannot be edited or deleted after creation."),
106
+ }, async (params) => {
107
+ const entityId = params[def.idParam];
108
+ const { note } = params;
109
+ const response = await addEntityNote(entityId, note, def.config);
110
+ if (response.isError) {
111
+ return {
112
+ content: [
113
+ {
114
+ type: "text",
115
+ text: `Error adding note to ${def.entity}: ${response.error}`,
116
+ },
117
+ ],
118
+ };
119
+ }
120
+ const record = response.result;
121
+ return {
122
+ content: [
123
+ {
124
+ type: "text",
125
+ text: [
126
+ `Note added to ${def.entity} ${entityId}.`,
127
+ record.dateUTC ? `Date: ${record.dateUTC}` : null,
128
+ record.user ? `User: ${record.user}` : null,
129
+ `Details: ${record.details}`,
130
+ ]
131
+ .filter(Boolean)
132
+ .join("\n"),
133
+ },
134
+ ],
135
+ };
136
+ });
137
+ }
138
+ export const HistoryTools = HISTORY_ENTITIES.flatMap((def) => [
139
+ createGetHistoryTool(def),
140
+ createAddNoteTool(def),
141
+ ]);
@@ -0,0 +1,54 @@
1
+ import ListAccountsTool from "./list-accounts.tool.js";
2
+ import ListAgedPayablesByContact from "./list-aged-payables-by-contact.tool.js";
3
+ import ListAgedReceivablesByContact from "./list-aged-receivables-by-contact.tool.js";
4
+ import ListBankTransactionsTool from "./list-bank-transactions.tool.js";
5
+ import ListContactsTool from "./list-contacts.tool.js";
6
+ import ListCreditNotesTool from "./list-credit-notes.tool.js";
7
+ import ListInvoicesTool from "./list-invoices.tool.js";
8
+ import ListItemsTool from "./list-items.tool.js";
9
+ import ListManualJournalsTool from "./list-manual-journals.tool.js";
10
+ import ListOrganisationDetailsTool from "./list-organisation-details.tool.js";
11
+ import ListPaymentsTool from "./list-payments.tool.js";
12
+ import ListPayrollEmployeeLeaveBalancesTool from "./list-payroll-employee-leave-balances.tool.js";
13
+ import ListPayrollEmployeeLeaveTypesTool from "./list-payroll-employee-leave-types.tool.js";
14
+ import ListPayrollEmployeeLeaveTool from "./list-payroll-employee-leave.tool.js";
15
+ import ListPayrollEmployeesTool from "./list-payroll-employees.tool.js";
16
+ import ListPayrollLeavePeriodsToolTool from "./list-payroll-leave-periods.tool.js";
17
+ import ListPayrollLeaveTypesTool from "./list-payroll-leave-types.tool.js";
18
+ import ListPayrollTimesheetsTool from "./list-payroll-timesheets.tool.js";
19
+ import ListProfitAndLossTool from "./list-profit-and-loss.tool.js";
20
+ import ListQuotesTool from "./list-quotes.tool.js";
21
+ import ListReportBalanceSheetTool from "./list-report-balance-sheet.tool.js";
22
+ import ListTaxRatesTool from "./list-tax-rates.tool.js";
23
+ import ListTrackingCategoriesTool from "./list-tracking-categories.tool.js";
24
+ import ListTrialBalanceTool from "./list-trial-balance.tool.js";
25
+ import ListContactGroupsTool from "./list-contact-groups.tool.js";
26
+ import ListInvoiceAttachmentsTool from "./list-invoice-attachments.tool.js";
27
+ export const ListTools = [
28
+ ListAccountsTool,
29
+ ListContactsTool,
30
+ ListCreditNotesTool,
31
+ ListInvoicesTool,
32
+ ListItemsTool,
33
+ ListManualJournalsTool,
34
+ ListQuotesTool,
35
+ ListTaxRatesTool,
36
+ ListTrialBalanceTool,
37
+ ListPaymentsTool,
38
+ ListProfitAndLossTool,
39
+ ListBankTransactionsTool,
40
+ ListPayrollEmployeesTool,
41
+ ListReportBalanceSheetTool,
42
+ ListOrganisationDetailsTool,
43
+ ListPayrollEmployeeLeaveTool,
44
+ ListPayrollLeavePeriodsToolTool,
45
+ ListPayrollEmployeeLeaveTypesTool,
46
+ ListPayrollEmployeeLeaveBalancesTool,
47
+ ListPayrollLeaveTypesTool,
48
+ ListAgedReceivablesByContact,
49
+ ListAgedPayablesByContact,
50
+ ListPayrollTimesheetsTool,
51
+ ListContactGroupsTool,
52
+ ListTrackingCategoriesTool,
53
+ ListInvoiceAttachmentsTool
54
+ ];
@@ -0,0 +1,39 @@
1
+ import { listXeroAccounts } from "../../handlers/list-xero-accounts.handler.js";
2
+ import { CreateXeroTool } from "../../helpers/create-xero-tool.js";
3
+ const ListAccountsTool = CreateXeroTool("list-accounts", "Lists all accounts in Xero. Use this tool to get the account codes and names to be used when creating invoices in Xero", {}, async () => {
4
+ const response = await listXeroAccounts();
5
+ if (response.error !== null) {
6
+ return {
7
+ content: [
8
+ {
9
+ type: "text",
10
+ text: `Error listing accounts: ${response.error}`,
11
+ },
12
+ ],
13
+ };
14
+ }
15
+ const accounts = response.result;
16
+ return {
17
+ content: [
18
+ {
19
+ type: "text",
20
+ text: `Found ${accounts?.length || 0} accounts:`,
21
+ },
22
+ ...(accounts?.map((account) => ({
23
+ type: "text",
24
+ text: [
25
+ `Account: ${account.name || "Unnamed"}`,
26
+ `Code: ${account.code || "No code"}`,
27
+ `ID: ${account.accountID || "No ID"}`,
28
+ `Type: ${account.type || "Unknown type"}`,
29
+ `Status: ${account.status || "Unknown status"}`,
30
+ account.description ? `Description: ${account.description}` : null,
31
+ account.taxType ? `Tax Type: ${account.taxType}` : null,
32
+ ]
33
+ .filter(Boolean)
34
+ .join("\n"),
35
+ })) || []),
36
+ ],
37
+ };
38
+ });
39
+ export default ListAccountsTool;