@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.
- package/LICENSE +21 -0
- package/README.md +199 -0
- package/dist/clients/xero-client.js +134 -0
- package/dist/consts/deeplinks.js +24 -0
- package/dist/handlers/approve-xero-payroll-timesheet.handler.js +28 -0
- package/dist/handlers/create-xero-bank-transaction.handler.js +50 -0
- package/dist/handlers/create-xero-contact.handler.js +49 -0
- package/dist/handlers/create-xero-credit-note.handler.js +49 -0
- package/dist/handlers/create-xero-invoice.handler.js +55 -0
- package/dist/handlers/create-xero-item.handler.js +59 -0
- package/dist/handlers/create-xero-manual-journal.handler.js +57 -0
- package/dist/handlers/create-xero-payment.handler.js +49 -0
- package/dist/handlers/create-xero-payroll-timesheet.handler.js +28 -0
- package/dist/handlers/create-xero-quote.handler.js +54 -0
- package/dist/handlers/create-xero-tracking-category.handler.js +35 -0
- package/dist/handlers/create-xero-tracking-option.handler.js +31 -0
- package/dist/handlers/delete-xero-payroll-timesheet.handler.js +28 -0
- package/dist/handlers/download-xero-invoice-attachment.handler.js +26 -0
- package/dist/handlers/get-xero-payroll-timesheet.handler.js +28 -0
- package/dist/handlers/history-handler-factory.js +46 -0
- package/dist/handlers/list-aged-payables-by-contact.handler.js +37 -0
- package/dist/handlers/list-aged-receivables-by-contact.handler.js +37 -0
- package/dist/handlers/list-xero-accounts.handler.js +32 -0
- package/dist/handlers/list-xero-bank-transactions.handler.js +31 -0
- package/dist/handlers/list-xero-contact-groups.handler.js +34 -0
- package/dist/handlers/list-xero-contacts.handler.js +37 -0
- package/dist/handlers/list-xero-credit-notes.handler.js +34 -0
- package/dist/handlers/list-xero-invoice-attachments.handler.js +20 -0
- package/dist/handlers/list-xero-invoices.handler.js +59 -0
- package/dist/handlers/list-xero-items.handler.js +32 -0
- package/dist/handlers/list-xero-manual-journals.handler.js +33 -0
- package/dist/handlers/list-xero-organisation-details.handler.js +32 -0
- package/dist/handlers/list-xero-payments.handler.js +53 -0
- package/dist/handlers/list-xero-payroll-employee-leave-balances.handler.js +42 -0
- package/dist/handlers/list-xero-payroll-employee-leave-types.handler.js +42 -0
- package/dist/handlers/list-xero-payroll-employee-leave.handler.js +44 -0
- package/dist/handlers/list-xero-payroll-employees.handler.js +31 -0
- package/dist/handlers/list-xero-payroll-leave-periods.handler.js +44 -0
- package/dist/handlers/list-xero-payroll-leave-types.handler.js +40 -0
- package/dist/handlers/list-xero-profit-and-loss.handler.js +52 -0
- package/dist/handlers/list-xero-quotes.handler.js +37 -0
- package/dist/handlers/list-xero-report-balance-sheet.handler.js +34 -0
- package/dist/handlers/list-xero-tax-rates.handler.js +30 -0
- package/dist/handlers/list-xero-timesheets.handler.js +29 -0
- package/dist/handlers/list-xero-tracking-categories.handler.js +29 -0
- package/dist/handlers/list-xero-trial-balance.handler.js +42 -0
- package/dist/handlers/revert-xero-payroll-timesheet.handler.js +28 -0
- package/dist/handlers/update-xero-bank-transaction.handler.js +56 -0
- package/dist/handlers/update-xero-contact.handler.js +66 -0
- package/dist/handlers/update-xero-credit-note.handler.js +61 -0
- package/dist/handlers/update-xero-invoice.handler.js +63 -0
- package/dist/handlers/update-xero-item.handler.js +46 -0
- package/dist/handlers/update-xero-manual-journal.handler.js +46 -0
- package/dist/handlers/update-xero-payroll-timesheet-add-line.handler.js +28 -0
- package/dist/handlers/update-xero-payroll-timesheet-update-line.handler.js +28 -0
- package/dist/handlers/update-xero-quote.handler.js +78 -0
- package/dist/handlers/update-xero-tracking-category.handler.js +43 -0
- package/dist/handlers/update-xero-tracking-options.handler.js +51 -0
- package/dist/helpers/create-xero-tool.js +6 -0
- package/dist/helpers/ensure-error.js +13 -0
- package/dist/helpers/format-aged-report-filter.js +8 -0
- package/dist/helpers/format-error.js +57 -0
- package/dist/helpers/format-line-item.js +13 -0
- package/dist/helpers/format-token-error.js +34 -0
- package/dist/helpers/format-tracking-option.js +7 -0
- package/dist/helpers/get-client-headers.js +8 -0
- package/dist/helpers/get-deeplink.js +41 -0
- package/dist/helpers/get-external-link.js +8 -0
- package/dist/helpers/get-package-version.js +20 -0
- package/dist/index.js +16 -0
- package/dist/server/xero-mcp-server.js +14 -0
- package/dist/tools/create/create-bank-transaction.tool.js +57 -0
- package/dist/tools/create/create-contact.tool.js +56 -0
- package/dist/tools/create/create-credit-note.tool.js +53 -0
- package/dist/tools/create/create-invoice.tool.js +76 -0
- package/dist/tools/create/create-item.tool.js +61 -0
- package/dist/tools/create/create-manual-journal.tool.js +116 -0
- package/dist/tools/create/create-payment.tool.js +71 -0
- package/dist/tools/create/create-payroll-timesheet.tool.js +40 -0
- package/dist/tools/create/create-quote.tool.js +57 -0
- package/dist/tools/create/create-tracking-category.tool.js +28 -0
- package/dist/tools/create/create-tracking-options.tool.js +30 -0
- package/dist/tools/create/index.js +24 -0
- package/dist/tools/delete/delete-payroll-timesheet.tool.js +28 -0
- package/dist/tools/delete/index.js +4 -0
- package/dist/tools/get/get-invoice-attachment.tool.js +45 -0
- package/dist/tools/get/get-payroll-timesheet.tool.js +49 -0
- package/dist/tools/get/index.js +6 -0
- package/dist/tools/history/index.js +141 -0
- package/dist/tools/list/index.js +54 -0
- package/dist/tools/list/list-accounts.tool.js +39 -0
- package/dist/tools/list/list-aged-payables-by-contact.tool.js +49 -0
- package/dist/tools/list/list-aged-receivables-by-contact.tool.js +49 -0
- package/dist/tools/list/list-bank-transactions.tool.js +63 -0
- package/dist/tools/list/list-contact-groups.tool.js +48 -0
- package/dist/tools/list/list-contacts.tool.js +70 -0
- package/dist/tools/list/list-credit-notes.tool.js +70 -0
- package/dist/tools/list/list-invoice-attachments.tool.js +42 -0
- package/dist/tools/list/list-invoices.tool.js +141 -0
- package/dist/tools/list/list-items.tool.js +53 -0
- package/dist/tools/list/list-manual-journals.tool.js +83 -0
- package/dist/tools/list/list-organisation-details.tool.js +90 -0
- package/dist/tools/list/list-payments.tool.js +84 -0
- package/dist/tools/list/list-payroll-employee-leave-balances.tool.js +39 -0
- package/dist/tools/list/list-payroll-employee-leave-types.tool.js +57 -0
- package/dist/tools/list/list-payroll-employee-leave.tool.js +42 -0
- package/dist/tools/list/list-payroll-employees.tool.js +48 -0
- package/dist/tools/list/list-payroll-leave-periods.tool.js +45 -0
- package/dist/tools/list/list-payroll-leave-types.tool.js +39 -0
- package/dist/tools/list/list-payroll-timesheets.tool.js +39 -0
- package/dist/tools/list/list-profit-and-loss.tool.js +45 -0
- package/dist/tools/list/list-quotes.tool.js +72 -0
- package/dist/tools/list/list-report-balance-sheet.tool.js +39 -0
- package/dist/tools/list/list-tax-rates.tool.js +49 -0
- package/dist/tools/list/list-tracking-categories.tool.js +39 -0
- package/dist/tools/list/list-trial-balance.tool.js +41 -0
- package/dist/tools/tool-factory.js +24 -0
- package/dist/tools/update/approve-payroll-timesheet.tool.js +29 -0
- package/dist/tools/update/index.js +28 -0
- package/dist/tools/update/revert-payroll-timesheet.tool.js +29 -0
- package/dist/tools/update/update-bank-transaction.tool.js +56 -0
- package/dist/tools/update/update-contact.tool.js +69 -0
- package/dist/tools/update/update-credit-note.tool.js +56 -0
- package/dist/tools/update/update-invoice.tool.js +74 -0
- package/dist/tools/update/update-item.tool.js +62 -0
- package/dist/tools/update/update-manual-journal-tool.js +89 -0
- package/dist/tools/update/update-payroll-timesheet-add-line.tool.js +34 -0
- package/dist/tools/update/update-payroll-timesheet-update-line.tool.js +35 -0
- package/dist/tools/update/update-quote.tool.js +61 -0
- package/dist/tools/update/update-tracking-category.tool.js +30 -0
- package/dist/tools/update/update-tracking-options.tool.js +35 -0
- package/dist/types/list-report-balance-sheet-params.js +1 -0
- package/dist/types/timeframeType.js +1 -0
- package/dist/types/tool-definition.js +1 -0
- package/dist/types/tool-list.js +1 -0
- package/dist/types/tool-response.js +1 -0
- package/package.json +63 -0
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { listXeroManualJournals } from "../../handlers/list-xero-manual-journals.handler.js";
|
|
2
|
+
import { CreateXeroTool } from "../../helpers/create-xero-tool.js";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
const ListManualJournalsTool = CreateXeroTool("list-manual-journals", `List all manual journals from Xero.
|
|
5
|
+
Ask the user if they want to see a specific manual journal or all manual journals before running.
|
|
6
|
+
Can optionally pass in manual journal ID to retrieve a specific journal, or a date to filter journals modified after that date.
|
|
7
|
+
The response presents a complete overview of all manual journals currently registered in your Xero account, with their details.
|
|
8
|
+
Ask the user if they want the next page of manual journals after running this tool if 10 manual journals are returned.
|
|
9
|
+
If they want the next page, call this tool again with the next page number, modified date, and the manual journal ID if one was provided in the previous call.
|
|
10
|
+
|
|
11
|
+
COMMON MISTAKES:
|
|
12
|
+
- Only use the params listed above. Do not invent additional filter or sort params.
|
|
13
|
+
- There is no "search", "query", "filter", "sortBy", "limit", or "offset" param.`, {
|
|
14
|
+
manualJournalId: z
|
|
15
|
+
.string()
|
|
16
|
+
.optional()
|
|
17
|
+
.describe("Optional ID of the manual journal to retrieve"),
|
|
18
|
+
modifiedAfter: z
|
|
19
|
+
.string()
|
|
20
|
+
.optional()
|
|
21
|
+
.describe("Optional date YYYY-MM-DD to filter journals modified after this date"),
|
|
22
|
+
page: z.number().optional().describe("Optional page number for pagination"),
|
|
23
|
+
// TODO: where, order
|
|
24
|
+
}, async (args) => {
|
|
25
|
+
const response = await listXeroManualJournals(args?.page, args?.manualJournalId, args?.modifiedAfter);
|
|
26
|
+
if (response.isError) {
|
|
27
|
+
return {
|
|
28
|
+
content: [
|
|
29
|
+
{
|
|
30
|
+
type: "text",
|
|
31
|
+
text: `Error listing manual journals: ${response.error}`,
|
|
32
|
+
},
|
|
33
|
+
],
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
const manualJournals = response.result;
|
|
37
|
+
return {
|
|
38
|
+
content: [
|
|
39
|
+
{
|
|
40
|
+
type: "text",
|
|
41
|
+
text: `Found ${manualJournals?.length || 0} manual journals:`,
|
|
42
|
+
},
|
|
43
|
+
...(manualJournals?.map((journal) => ({
|
|
44
|
+
type: "text",
|
|
45
|
+
text: [
|
|
46
|
+
`Manual Journal ID: ${journal.manualJournalID}`,
|
|
47
|
+
journal.narration
|
|
48
|
+
? `Description: ${journal.narration}`
|
|
49
|
+
: "No description",
|
|
50
|
+
journal.date ? `Date: ${journal.date}` : null,
|
|
51
|
+
journal.journalLines
|
|
52
|
+
? journal.journalLines.map((line) => [
|
|
53
|
+
`Line Amount: ${line.lineAmount}`,
|
|
54
|
+
line.accountCode
|
|
55
|
+
? `Account Code: ${line.accountCode}`
|
|
56
|
+
: "No account code",
|
|
57
|
+
line.description
|
|
58
|
+
? `Description: ${line.description}`
|
|
59
|
+
: "No description",
|
|
60
|
+
line.taxType ? `Tax Type: ${line.taxType}` : "No tax type",
|
|
61
|
+
`Tax Amount: ${line.taxAmount}`,
|
|
62
|
+
]
|
|
63
|
+
.filter(Boolean)
|
|
64
|
+
.join("\n")).join("\n\n")
|
|
65
|
+
: "No journal lines",
|
|
66
|
+
journal.lineAmountTypes
|
|
67
|
+
? `Line Amount Types: ${journal.lineAmountTypes}`
|
|
68
|
+
: "No line amount types",
|
|
69
|
+
journal.status ? `Status: ${journal.status}` : "No status",
|
|
70
|
+
journal.url ? `URL: ${journal.url}` : "No URL",
|
|
71
|
+
`Show on Cash Basis Reports: ${journal.showOnCashBasisReports}`,
|
|
72
|
+
`Has Attachments: ${journal.hasAttachments}`,
|
|
73
|
+
journal.updatedDateUTC
|
|
74
|
+
? `Last Updated: ${journal.updatedDateUTC.toLocaleDateString()}`
|
|
75
|
+
: "No last updated date",
|
|
76
|
+
]
|
|
77
|
+
.filter(Boolean)
|
|
78
|
+
.join("\n"),
|
|
79
|
+
})) || []),
|
|
80
|
+
],
|
|
81
|
+
};
|
|
82
|
+
});
|
|
83
|
+
export default ListManualJournalsTool;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { listXeroOrganisationDetails } from "../../handlers/list-xero-organisation-details.handler.js";
|
|
2
|
+
import { getExternalLink } from "../../helpers/get-external-link.js";
|
|
3
|
+
import { CreateXeroTool } from "../../helpers/create-xero-tool.js";
|
|
4
|
+
const ListOrganisationDetailsTool = CreateXeroTool("list-organisation-details", "Lists the organisation details from Xero. Use this tool to get information about the current Xero organisation.", {}, async () => {
|
|
5
|
+
const response = await listXeroOrganisationDetails();
|
|
6
|
+
if (response.error !== null) {
|
|
7
|
+
return {
|
|
8
|
+
content: [
|
|
9
|
+
{
|
|
10
|
+
type: "text",
|
|
11
|
+
text: `Error fetching organisation details: ${response.error || "Unknown error"}`,
|
|
12
|
+
},
|
|
13
|
+
],
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
const organisation = response.result;
|
|
17
|
+
if (!organisation) {
|
|
18
|
+
return {
|
|
19
|
+
content: [
|
|
20
|
+
{
|
|
21
|
+
type: "text",
|
|
22
|
+
text: "No organisation details found.",
|
|
23
|
+
},
|
|
24
|
+
],
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
const resolvedExternalLinks = organisation.externalLinks?.map((link, index) => `${index + 1}. ${link.linkType}: ${link.url ? getExternalLink(link.url) : link.url}`) || [];
|
|
28
|
+
const addresses = organisation.addresses?.map((address, index) => {
|
|
29
|
+
return `Address ${index + 1} (${address.addressType || ""}): ${[
|
|
30
|
+
address.addressLine1,
|
|
31
|
+
address.addressLine2,
|
|
32
|
+
address.city,
|
|
33
|
+
address.postalCode,
|
|
34
|
+
address.country,
|
|
35
|
+
]
|
|
36
|
+
.filter(Boolean)
|
|
37
|
+
.join(", ")}`;
|
|
38
|
+
}).join("\n") || "No addresses available.";
|
|
39
|
+
const paymentTerms = organisation.paymentTerms
|
|
40
|
+
? Object.entries(organisation.paymentTerms).map(([key, value], index) => {
|
|
41
|
+
return `${index + 1}. ${key}: ${value}`;
|
|
42
|
+
}).join("\n")
|
|
43
|
+
: "No payment terms available.";
|
|
44
|
+
const phones = organisation.phones?.map((phone, index) => {
|
|
45
|
+
return `Phone ${index + 1}: ${phone.phoneType || "Unknown type"} - ${phone.phoneNumber || "No number"}`;
|
|
46
|
+
}).join("\n") || "No phone numbers available.";
|
|
47
|
+
const organisationDetails = [
|
|
48
|
+
`Name: ${organisation.name} || "No name available."`,
|
|
49
|
+
`Legal Name: ${organisation.legalName} || "No legal name available."`,
|
|
50
|
+
`Pays Tax: ${organisation.paysTax ? "Yes" : "No"}`,
|
|
51
|
+
`Short Code: ${organisation.shortCode} || "No short code available."`,
|
|
52
|
+
`Organisation ID: ${organisation.organisationID} || "No organisation ID available."`,
|
|
53
|
+
`Version: ${organisation.version} || "No version available."`,
|
|
54
|
+
organisation.organisationType ? `Organisation Type: ${organisation.organisationType}` : null,
|
|
55
|
+
`Base Currency: ${organisation.baseCurrency} || "No base currency available."`,
|
|
56
|
+
`Country Code: ${organisation.countryCode} || "No country code available."`,
|
|
57
|
+
`Timezone: ${organisation.timezone} || "No timezone available."`,
|
|
58
|
+
organisation.registrationNumber ? `Registration Number: ${organisation.registrationNumber}` : null,
|
|
59
|
+
organisation.taxNumber ? `Tax Number: ${organisation.taxNumber}` : null,
|
|
60
|
+
organisation.organisationEntityType ? `Organisation Entity Type: ${organisation.organisationEntityType}` : null,
|
|
61
|
+
`Financial Year End Day: ${organisation.financialYearEndDay} || "No financial year end day set."`,
|
|
62
|
+
`Financial Year End Month: ${organisation.financialYearEndMonth} || "No financial year end month set."`,
|
|
63
|
+
`Sales Tax Basis: ${organisation.salesTaxBasis} || "No sales tax basis available."`,
|
|
64
|
+
`Sales Tax Period: ${organisation.salesTaxPeriod} || "No sales tax period available."`,
|
|
65
|
+
organisation.periodLockDate ? `Period Lock Date: ${organisation.periodLockDate}` : null,
|
|
66
|
+
organisation.organisationStatus ? `Organisation Status: ${organisation.organisationStatus}` : null,
|
|
67
|
+
`Created Date: ${organisation.createdDateUTC} || "No created date available."`,
|
|
68
|
+
`Edition: ${organisation.edition} || "No edition available."`,
|
|
69
|
+
`Class: ${organisation._class} || "No class available."`,
|
|
70
|
+
`Is Demo Company: ${organisation.isDemoCompany ? "Yes" : "No"}`,
|
|
71
|
+
organisation.lineOfBusiness ? `Line of Business: ${organisation.lineOfBusiness}` : null,
|
|
72
|
+
`Addresses:\n${addresses}`,
|
|
73
|
+
`Phone Numbers:\n${phones}`,
|
|
74
|
+
`External Links:\n${resolvedExternalLinks.join("\n")}`,
|
|
75
|
+
`Payment Terms:\n${paymentTerms}`,
|
|
76
|
+
].filter(Boolean).join("\n");
|
|
77
|
+
return {
|
|
78
|
+
content: [
|
|
79
|
+
{
|
|
80
|
+
type: "text",
|
|
81
|
+
text: `Organisation Details:`,
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
type: "text",
|
|
85
|
+
text: organisationDetails,
|
|
86
|
+
},
|
|
87
|
+
],
|
|
88
|
+
};
|
|
89
|
+
});
|
|
90
|
+
export default ListOrganisationDetailsTool;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { listXeroPayments } from "../../handlers/list-xero-payments.handler.js";
|
|
3
|
+
import { CreateXeroTool } from "../../helpers/create-xero-tool.js";
|
|
4
|
+
function paymentFormatter(payment) {
|
|
5
|
+
return [
|
|
6
|
+
`Payment ID: ${payment.paymentID || "Unknown"}`,
|
|
7
|
+
`Date: ${payment.date || "Unknown date"}`,
|
|
8
|
+
`Amount: ${payment.amount || 0}`,
|
|
9
|
+
payment.reference ? `Reference: ${payment.reference}` : null,
|
|
10
|
+
payment.status ? `Status: ${payment.status}` : null,
|
|
11
|
+
payment.paymentType ? `Payment Type: ${payment.paymentType}` : null,
|
|
12
|
+
payment.updatedDateUTC ? `Last Updated: ${payment.updatedDateUTC}` : null,
|
|
13
|
+
payment.account?.name
|
|
14
|
+
? `Account: ${payment.account.name} (${payment.account.accountID || "Unknown ID"})`
|
|
15
|
+
: null,
|
|
16
|
+
payment.invoice
|
|
17
|
+
? [
|
|
18
|
+
`Invoice:`,
|
|
19
|
+
` Invoice Number: ${payment.invoice.invoiceNumber || "Unknown"}`,
|
|
20
|
+
` Invoice ID: ${payment.invoice.invoiceID || "Unknown"}`,
|
|
21
|
+
payment.invoice.contact
|
|
22
|
+
? ` Contact: ${payment.invoice.contact.name || "Unknown"} (${payment.invoice.contact.contactID || "Unknown ID"})`
|
|
23
|
+
: null,
|
|
24
|
+
payment.invoice.type ? ` Type: ${payment.invoice.type}` : null,
|
|
25
|
+
payment.invoice.total !== undefined
|
|
26
|
+
? ` Total: ${payment.invoice.total}`
|
|
27
|
+
: null,
|
|
28
|
+
payment.invoice.amountDue !== undefined
|
|
29
|
+
? ` Amount Due: ${payment.invoice.amountDue}`
|
|
30
|
+
: null,
|
|
31
|
+
]
|
|
32
|
+
.filter(Boolean)
|
|
33
|
+
.join("\n")
|
|
34
|
+
: null,
|
|
35
|
+
]
|
|
36
|
+
.filter(Boolean)
|
|
37
|
+
.join("\n");
|
|
38
|
+
}
|
|
39
|
+
const ListPaymentsTool = CreateXeroTool("list-payments", `List payments in Xero.
|
|
40
|
+
This tool shows all payments made against invoices, including payment date, amount, and payment method.
|
|
41
|
+
You can filter payments by invoice number, invoice ID, payment ID, or invoice reference.
|
|
42
|
+
Ask the user if they want to see payments for a specific invoice, contact, payment or reference before running.
|
|
43
|
+
If many payments are returned, ask the user if they want to see the next page.
|
|
44
|
+
|
|
45
|
+
COMMON MISTAKES:
|
|
46
|
+
- Only use the params listed above. Do not invent additional filter or sort params.
|
|
47
|
+
- There is no "search", "query", "filter", "sortBy", "limit", or "offset" param.`, {
|
|
48
|
+
page: z.number().default(1),
|
|
49
|
+
invoiceNumber: z.string().optional(),
|
|
50
|
+
invoiceId: z.string().optional(),
|
|
51
|
+
paymentId: z.string().optional(),
|
|
52
|
+
reference: z.string().optional(),
|
|
53
|
+
}, async ({ page, invoiceNumber, invoiceId, paymentId, reference }) => {
|
|
54
|
+
const response = await listXeroPayments(page, {
|
|
55
|
+
invoiceNumber,
|
|
56
|
+
invoiceId,
|
|
57
|
+
paymentId,
|
|
58
|
+
reference,
|
|
59
|
+
});
|
|
60
|
+
if (response.error !== null) {
|
|
61
|
+
return {
|
|
62
|
+
content: [
|
|
63
|
+
{
|
|
64
|
+
type: "text",
|
|
65
|
+
text: `Error listing payments: ${response.error}`,
|
|
66
|
+
},
|
|
67
|
+
],
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
const payments = response.result;
|
|
71
|
+
return {
|
|
72
|
+
content: [
|
|
73
|
+
{
|
|
74
|
+
type: "text",
|
|
75
|
+
text: `Found ${payments?.length || 0} payments:`,
|
|
76
|
+
},
|
|
77
|
+
...(payments?.map((payment) => ({
|
|
78
|
+
type: "text",
|
|
79
|
+
text: paymentFormatter(payment),
|
|
80
|
+
})) || []),
|
|
81
|
+
],
|
|
82
|
+
};
|
|
83
|
+
});
|
|
84
|
+
export default ListPaymentsTool;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { listXeroPayrollEmployeeLeaveBalances } from "../../handlers/list-xero-payroll-employee-leave-balances.handler.js";
|
|
3
|
+
import { CreateXeroTool } from "../../helpers/create-xero-tool.js";
|
|
4
|
+
const ListPayrollEmployeeLeaveBalancesTool = CreateXeroTool("list-payroll-employee-leave-balances", "List all leave balances for a specific employee in Xero. This shows current leave balances for all leave types available to the employee, including annual, sick, and other leave types.", {
|
|
5
|
+
employeeId: z.string().describe("The Xero employee ID to fetch leave balances for"),
|
|
6
|
+
}, async ({ employeeId }) => {
|
|
7
|
+
const response = await listXeroPayrollEmployeeLeaveBalances(employeeId);
|
|
8
|
+
if (response.isError) {
|
|
9
|
+
return {
|
|
10
|
+
content: [
|
|
11
|
+
{
|
|
12
|
+
type: "text",
|
|
13
|
+
text: `Error listing employee leave balances: ${response.error}`,
|
|
14
|
+
},
|
|
15
|
+
],
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
const leaveBalances = response.result;
|
|
19
|
+
return {
|
|
20
|
+
content: [
|
|
21
|
+
{
|
|
22
|
+
type: "text",
|
|
23
|
+
text: `Found ${leaveBalances?.length || 0} leave balances for employee ${employeeId}:`,
|
|
24
|
+
},
|
|
25
|
+
...(leaveBalances?.map((balance) => ({
|
|
26
|
+
type: "text",
|
|
27
|
+
text: [
|
|
28
|
+
`Leave Type ID: ${balance.leaveTypeID || "Unknown"}`,
|
|
29
|
+
`Name: ${balance.name || "Unnamed"}`,
|
|
30
|
+
balance.typeOfUnits ? `Type Of Units: ${balance.typeOfUnits}` : null,
|
|
31
|
+
balance.balance !== undefined ? `Current Balance: ${balance.balance}` : null,
|
|
32
|
+
]
|
|
33
|
+
.filter(Boolean)
|
|
34
|
+
.join("\n"),
|
|
35
|
+
})) || []),
|
|
36
|
+
],
|
|
37
|
+
};
|
|
38
|
+
});
|
|
39
|
+
export default ListPayrollEmployeeLeaveBalancesTool;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { listXeroPayrollEmployeeLeaveTypes } from "../../handlers/list-xero-payroll-employee-leave-types.handler.js";
|
|
3
|
+
import { CreateXeroTool } from "../../helpers/create-xero-tool.js";
|
|
4
|
+
const ListPayrollEmployeeLeaveTypesTool = CreateXeroTool("list-payroll-employee-leave-types", "List all leave types available for a specific employee in Xero. This shows detailed information about the types of leave an employee can take, including schedule of accrual, leave type name, and entitlement.", {
|
|
5
|
+
employeeId: z
|
|
6
|
+
.string()
|
|
7
|
+
.describe("The Xero employee ID to fetch leave types for"),
|
|
8
|
+
}, async ({ employeeId }) => {
|
|
9
|
+
const response = await listXeroPayrollEmployeeLeaveTypes(employeeId);
|
|
10
|
+
if (response.isError) {
|
|
11
|
+
return {
|
|
12
|
+
content: [
|
|
13
|
+
{
|
|
14
|
+
type: "text",
|
|
15
|
+
text: `Error listing employee leave types: ${response.error}`,
|
|
16
|
+
},
|
|
17
|
+
],
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
const leaveTypes = response.result;
|
|
21
|
+
return {
|
|
22
|
+
content: [
|
|
23
|
+
{
|
|
24
|
+
type: "text",
|
|
25
|
+
text: `Found ${leaveTypes?.length || 0} leave types for employee ${employeeId}:`,
|
|
26
|
+
},
|
|
27
|
+
...(leaveTypes?.map((leaveType) => ({
|
|
28
|
+
type: "text",
|
|
29
|
+
text: [
|
|
30
|
+
`Leave Type ID: ${leaveType.leaveTypeID || "Unknown"}`,
|
|
31
|
+
`Schedule of Accrual: ${leaveType.scheduleOfAccrual || "Unknown"}`,
|
|
32
|
+
leaveType.hoursAccruedAnnually
|
|
33
|
+
? `Hours Accrued Annually: ${leaveType.hoursAccruedAnnually}`
|
|
34
|
+
: null,
|
|
35
|
+
leaveType.maximumToAccrue
|
|
36
|
+
? `Maximum To Accrue: ${leaveType.maximumToAccrue}`
|
|
37
|
+
: null,
|
|
38
|
+
leaveType.openingBalance
|
|
39
|
+
? `Opening Balance: ${leaveType.openingBalance}`
|
|
40
|
+
: null,
|
|
41
|
+
leaveType.rateAccruedHourly
|
|
42
|
+
? `Rate Accrued Hourly: ${leaveType.rateAccruedHourly}`
|
|
43
|
+
: null,
|
|
44
|
+
leaveType.leaveTypeID
|
|
45
|
+
? `Leave Type ID: ${leaveType.leaveTypeID}`
|
|
46
|
+
: null,
|
|
47
|
+
leaveType.scheduleOfAccrualDate
|
|
48
|
+
? `Accrual Date: ${leaveType.scheduleOfAccrualDate}`
|
|
49
|
+
: null,
|
|
50
|
+
]
|
|
51
|
+
.filter(Boolean)
|
|
52
|
+
.join("\n"),
|
|
53
|
+
})) || []),
|
|
54
|
+
],
|
|
55
|
+
};
|
|
56
|
+
});
|
|
57
|
+
export default ListPayrollEmployeeLeaveTypesTool;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { listXeroPayrollEmployeeLeave } from "../../handlers/list-xero-payroll-employee-leave.handler.js";
|
|
3
|
+
import { CreateXeroTool } from "../../helpers/create-xero-tool.js";
|
|
4
|
+
const ListPayrollEmployeeLeaveTool = CreateXeroTool("list-payroll-employee-leave", "List all leave records for a specific employee in Xero. This shows all leave transactions including approved, pending, and processed time off. Provide an employee ID to see their leave history.", {
|
|
5
|
+
employeeId: z.string().describe("The Xero employee ID to fetch leave records for"),
|
|
6
|
+
}, async ({ employeeId }) => {
|
|
7
|
+
const response = await listXeroPayrollEmployeeLeave(employeeId);
|
|
8
|
+
if (response.isError) {
|
|
9
|
+
return {
|
|
10
|
+
content: [
|
|
11
|
+
{
|
|
12
|
+
type: "text",
|
|
13
|
+
text: `Error listing employee leave: ${response.error}`,
|
|
14
|
+
},
|
|
15
|
+
],
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
const leave = response.result;
|
|
19
|
+
return {
|
|
20
|
+
content: [
|
|
21
|
+
{
|
|
22
|
+
type: "text",
|
|
23
|
+
text: `Found ${leave?.length || 0} leave records for employee ${employeeId}:`,
|
|
24
|
+
},
|
|
25
|
+
...(leave?.map((leaveItem) => ({
|
|
26
|
+
type: "text",
|
|
27
|
+
text: [
|
|
28
|
+
`Leave ID: ${leaveItem.leaveID || "Unknown"}`,
|
|
29
|
+
`Leave Type: ${leaveItem.leaveTypeID || "Unknown"}`,
|
|
30
|
+
`Description: ${leaveItem.description || "No description"}`,
|
|
31
|
+
leaveItem.startDate ? `Start Date: ${leaveItem.startDate}` : null,
|
|
32
|
+
leaveItem.endDate ? `End Date: ${leaveItem.endDate}` : null,
|
|
33
|
+
leaveItem.periods ? `Periods: ${leaveItem.periods.length || 0}` : null,
|
|
34
|
+
leaveItem.updatedDateUTC ? `Last Updated: ${leaveItem.updatedDateUTC}` : null,
|
|
35
|
+
]
|
|
36
|
+
.filter(Boolean)
|
|
37
|
+
.join("\n"),
|
|
38
|
+
})) || []),
|
|
39
|
+
],
|
|
40
|
+
};
|
|
41
|
+
});
|
|
42
|
+
export default ListPayrollEmployeeLeaveTool;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { listXeroPayrollEmployees } from "../../handlers/list-xero-payroll-employees.handler.js";
|
|
2
|
+
import { CreateXeroTool } from "../../helpers/create-xero-tool.js";
|
|
3
|
+
const ListPayrollEmployeesTool = CreateXeroTool("list-payroll-employees", `List all payroll employees in Xero.
|
|
4
|
+
This retrieves comprehensive employee details including names, User IDs, dates of birth, email addresses, gender, phone numbers, start dates, engagement types (Permanent, FixedTerm, or Casual), titles, and when records were last updated.
|
|
5
|
+
The response presents a complete overview of all staff currently registered in your Xero payroll, with their personal and employment information. If there are many employees, ask the user if they would like to see more detailed information about specific employees before proceeding.`, {}, async () => {
|
|
6
|
+
const response = await listXeroPayrollEmployees();
|
|
7
|
+
if (response.isError) {
|
|
8
|
+
return {
|
|
9
|
+
content: [
|
|
10
|
+
{
|
|
11
|
+
type: "text",
|
|
12
|
+
text: `Error listing payroll employees: ${response.error}`,
|
|
13
|
+
},
|
|
14
|
+
],
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
const employees = response.result;
|
|
18
|
+
return {
|
|
19
|
+
content: [
|
|
20
|
+
{
|
|
21
|
+
type: "text",
|
|
22
|
+
text: `Found ${employees?.length || 0} payroll employees:`,
|
|
23
|
+
},
|
|
24
|
+
...(employees?.map((employee) => ({
|
|
25
|
+
type: "text",
|
|
26
|
+
text: [
|
|
27
|
+
`Employee: ${employee.employeeID}`,
|
|
28
|
+
employee.email ? `Email: ${employee.email}` : "No email",
|
|
29
|
+
employee.gender ? `Gender: ${employee.gender}` : null,
|
|
30
|
+
employee.phoneNumber ? `Phone: ${employee.phoneNumber}` : null,
|
|
31
|
+
employee.startDate ? `Start Date: ${employee.startDate}` : null,
|
|
32
|
+
employee.engagementType
|
|
33
|
+
? `Engagement Type: ${employee.engagementType}`
|
|
34
|
+
: "No status", // Permanent, FixedTerm, Casual
|
|
35
|
+
employee.title ? `Title: ${employee.title}` : null,
|
|
36
|
+
employee.firstName ? `First Name: ${employee.firstName}` : null,
|
|
37
|
+
employee.lastName ? `Last Name: ${employee.lastName}` : null,
|
|
38
|
+
employee.updatedDateUTC
|
|
39
|
+
? `Last Updated: ${employee.updatedDateUTC}`
|
|
40
|
+
: null,
|
|
41
|
+
]
|
|
42
|
+
.filter(Boolean)
|
|
43
|
+
.join("\n"),
|
|
44
|
+
})) || []),
|
|
45
|
+
],
|
|
46
|
+
};
|
|
47
|
+
});
|
|
48
|
+
export default ListPayrollEmployeesTool;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { listXeroPayrollLeavePeriods } from "../../handlers/list-xero-payroll-leave-periods.handler.js";
|
|
3
|
+
import { CreateXeroTool } from "../../helpers/create-xero-tool.js";
|
|
4
|
+
const ListPayrollLeavePeriodsToolTool = CreateXeroTool("list-payroll-leave-periods", "List all leave periods for a specific employee in Xero. This shows detailed time off periods including start and end dates, period status, payment dates, and leave types. Provide an employee ID to see their leave periods.", {
|
|
5
|
+
employeeId: z.string().describe("The Xero employee ID to fetch leave periods for"),
|
|
6
|
+
startDate: z.string().optional().describe("Optional start date in YYYY-MM-DD format"),
|
|
7
|
+
endDate: z.string().optional().describe("Optional end date in YYYY-MM-DD format"),
|
|
8
|
+
}, async ({ employeeId, startDate, endDate }) => {
|
|
9
|
+
const response = await listXeroPayrollLeavePeriods(employeeId, startDate, endDate);
|
|
10
|
+
if (response.isError) {
|
|
11
|
+
return {
|
|
12
|
+
content: [
|
|
13
|
+
{
|
|
14
|
+
type: "text",
|
|
15
|
+
text: `Error listing employee leave periods: ${response.error}`,
|
|
16
|
+
},
|
|
17
|
+
],
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
const periods = response.result;
|
|
21
|
+
return {
|
|
22
|
+
content: [
|
|
23
|
+
{
|
|
24
|
+
type: "text",
|
|
25
|
+
text: `Found ${periods?.length || 0} leave periods for employee ${employeeId}:`,
|
|
26
|
+
},
|
|
27
|
+
...(periods?.map((period) => ({
|
|
28
|
+
type: "text",
|
|
29
|
+
text: [
|
|
30
|
+
`Period Status: ${period.periodStatus || "Unknown"}`,
|
|
31
|
+
period.periodStartDate ? `Start Date: ${period.periodStartDate}` : null,
|
|
32
|
+
period.periodEndDate ? `End Date: ${period.periodEndDate}` : null,
|
|
33
|
+
period.numberOfUnits ? `Number of Units: ${period.numberOfUnits}` : null,
|
|
34
|
+
period.numberOfUnitsTaken ? `Payment Date: ${period.numberOfUnitsTaken}` : null,
|
|
35
|
+
period.typeOfUnits ? `Payment Date: ${period.typeOfUnits}` : null,
|
|
36
|
+
period.typeOfUnitsTaken ? `Payment Date: ${period.typeOfUnitsTaken}` : null,
|
|
37
|
+
period.periodStatus ? `Period Status: ${period.periodStatus}` : null,
|
|
38
|
+
]
|
|
39
|
+
.filter(Boolean)
|
|
40
|
+
.join("\n"),
|
|
41
|
+
})) || []),
|
|
42
|
+
],
|
|
43
|
+
};
|
|
44
|
+
});
|
|
45
|
+
export default ListPayrollLeavePeriodsToolTool;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { listXeroPayrollLeaveTypes } from "../../handlers/list-xero-payroll-leave-types.handler.js";
|
|
2
|
+
import { CreateXeroTool } from "../../helpers/create-xero-tool.js";
|
|
3
|
+
const ListPayrollLeaveTypesTool = CreateXeroTool("list-payroll-leave-types", "Lists all available leave types in Xero Payroll. This provides information about all the leave categories configured in your Xero system, including statutory and organization-specific leave types.", {}, async () => {
|
|
4
|
+
const response = await listXeroPayrollLeaveTypes();
|
|
5
|
+
if (response.isError) {
|
|
6
|
+
return {
|
|
7
|
+
content: [
|
|
8
|
+
{
|
|
9
|
+
type: "text",
|
|
10
|
+
text: `Error listing payroll leave types: ${response.error}`,
|
|
11
|
+
},
|
|
12
|
+
],
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
const leaveTypes = response.result;
|
|
16
|
+
return {
|
|
17
|
+
content: [
|
|
18
|
+
{
|
|
19
|
+
type: "text",
|
|
20
|
+
text: `Found ${leaveTypes?.length || 0} payroll leave types:`,
|
|
21
|
+
}, ...(leaveTypes?.map((leaveType) => ({
|
|
22
|
+
type: "text",
|
|
23
|
+
text: [
|
|
24
|
+
`Leave Type: ${leaveType.name || "Unnamed"}`,
|
|
25
|
+
`Leave Type ID: ${leaveType.leaveTypeID || "Unknown"}`,
|
|
26
|
+
leaveType.isPaidLeave !== undefined ? `Is Paid Leave: ${leaveType.isPaidLeave ? 'Yes' : 'No'}` : null,
|
|
27
|
+
leaveType.showOnPayslip !== undefined ? `Show On Payslip: ${leaveType.showOnPayslip ? 'Yes' : 'No'}` : null,
|
|
28
|
+
leaveType.isActive !== undefined ? `Is Active: ${leaveType.isActive ? 'Yes' : 'No'}` : null,
|
|
29
|
+
leaveType.typeOfUnits ? `Type Of Units: ${leaveType.typeOfUnits}` : null,
|
|
30
|
+
leaveType.typeOfUnitsToAccrue ? `Type Of Units To Accrue: ${leaveType.typeOfUnitsToAccrue}` : null,
|
|
31
|
+
leaveType.updatedDateUTC ? `Last Updated: ${leaveType.updatedDateUTC}` : null,
|
|
32
|
+
]
|
|
33
|
+
.filter(Boolean)
|
|
34
|
+
.join("\n"),
|
|
35
|
+
})) || []),
|
|
36
|
+
],
|
|
37
|
+
};
|
|
38
|
+
});
|
|
39
|
+
export default ListPayrollLeaveTypesTool;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { listXeroPayrollTimesheets, } from "../../handlers/list-xero-timesheets.handler.js";
|
|
2
|
+
import { CreateXeroTool } from "../../helpers/create-xero-tool.js";
|
|
3
|
+
const ListPayrollTimesheetsTool = CreateXeroTool("list-timesheets", `List all payroll timesheets in Xero.
|
|
4
|
+
This retrieves comprehensive timesheet details including timesheet IDs, employee IDs, start and end dates, total hours, and the last updated date.`, {}, async () => {
|
|
5
|
+
const response = await listXeroPayrollTimesheets();
|
|
6
|
+
if (response.isError) {
|
|
7
|
+
return {
|
|
8
|
+
content: [
|
|
9
|
+
{
|
|
10
|
+
type: "text",
|
|
11
|
+
text: `Error listing timesheets: ${response.error}`,
|
|
12
|
+
},
|
|
13
|
+
],
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
const timesheets = response.result;
|
|
17
|
+
return {
|
|
18
|
+
content: [
|
|
19
|
+
{
|
|
20
|
+
type: "text",
|
|
21
|
+
text: `Found ${timesheets?.length || 0} timesheets:`,
|
|
22
|
+
},
|
|
23
|
+
...(timesheets?.map((timesheet) => ({
|
|
24
|
+
type: "text",
|
|
25
|
+
text: [
|
|
26
|
+
`Timesheet ID: ${timesheet.timesheetID}`,
|
|
27
|
+
`Employee ID: ${timesheet.employeeID}`,
|
|
28
|
+
`Start Date: ${timesheet.startDate}`,
|
|
29
|
+
`End Date: ${timesheet.endDate}`,
|
|
30
|
+
`Total Hours: ${timesheet.totalHours}`,
|
|
31
|
+
`Last Updated: ${timesheet.updatedDateUTC}`,
|
|
32
|
+
]
|
|
33
|
+
.filter(Boolean)
|
|
34
|
+
.join("\n"),
|
|
35
|
+
})) || []),
|
|
36
|
+
],
|
|
37
|
+
};
|
|
38
|
+
});
|
|
39
|
+
export default ListPayrollTimesheetsTool;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { listXeroProfitAndLoss } from "../../handlers/list-xero-profit-and-loss.handler.js";
|
|
3
|
+
import { CreateXeroTool } from "../../helpers/create-xero-tool.js";
|
|
4
|
+
const ListProfitAndLossTool = CreateXeroTool("list-profit-and-loss", "Lists profit and loss report in Xero. This provides a summary of revenue, expenses, and profit or loss over a specified period of time.", {
|
|
5
|
+
fromDate: z.string().optional().describe("Optional start date in YYYY-MM-DD format"),
|
|
6
|
+
toDate: z.string().optional().describe("Optional end date in YYYY-MM-DD format"),
|
|
7
|
+
periods: z.number().optional().describe("Optional number of periods to compare"),
|
|
8
|
+
timeframe: z.enum(["MONTH", "QUARTER", "YEAR"]).optional().describe("Optional timeframe for the report (MONTH, QUARTER, YEAR)"),
|
|
9
|
+
standardLayout: z.boolean().optional().describe("Optional flag to use standard layout"),
|
|
10
|
+
paymentsOnly: z.boolean().optional().describe("Optional flag to include only accounts with payments"),
|
|
11
|
+
}, async (args) => {
|
|
12
|
+
const response = await listXeroProfitAndLoss(args?.fromDate, args?.toDate, args?.periods, args?.timeframe, args?.standardLayout, args?.paymentsOnly);
|
|
13
|
+
if (response.error !== null) {
|
|
14
|
+
return {
|
|
15
|
+
content: [
|
|
16
|
+
{
|
|
17
|
+
type: "text",
|
|
18
|
+
text: `Error listing profit and loss report: ${response.error}`,
|
|
19
|
+
},
|
|
20
|
+
],
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
const profitAndLossReport = response.result;
|
|
24
|
+
return {
|
|
25
|
+
content: [
|
|
26
|
+
{
|
|
27
|
+
type: "text",
|
|
28
|
+
text: `Profit and Loss Report: ${profitAndLossReport?.reportName ?? "Unnamed"}`,
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
type: "text",
|
|
32
|
+
text: `Date Range: ${profitAndLossReport?.reportDate ?? "Not specified"}`,
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
type: "text",
|
|
36
|
+
text: `Updated At: ${profitAndLossReport?.updatedDateUTC ? profitAndLossReport.updatedDateUTC.toISOString() : "Unknown"}`,
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
type: "text",
|
|
40
|
+
text: JSON.stringify(profitAndLossReport.rows, null, 2),
|
|
41
|
+
},
|
|
42
|
+
],
|
|
43
|
+
};
|
|
44
|
+
});
|
|
45
|
+
export default ListProfitAndLossTool;
|