@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.
- package/LICENSE +21 -0
- package/README.md +282 -0
- package/dist/clients/xero-client.js +141 -0
- package/dist/consts/deeplinks.js +24 -0
- package/dist/handlers/approve-xero-payroll-timesheet.handler.js +28 -0
- package/dist/handlers/archive-xero-contact.handler.js +28 -0
- package/dist/handlers/authorise-xero-invoice.handler.js +34 -0
- package/dist/handlers/convert-xero-quote-to-invoice.handler.js +50 -0
- package/dist/handlers/create-xero-bank-transaction.handler.js +51 -0
- package/dist/handlers/create-xero-contact.handler.js +49 -0
- package/dist/handlers/create-xero-credit-note.handler.js +50 -0
- package/dist/handlers/create-xero-invoice.handler.js +53 -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 +50 -0
- package/dist/handlers/create-xero-payroll-timesheet.handler.js +28 -0
- package/dist/handlers/create-xero-quote.handler.js +53 -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-invoice-attachment.handler.js +30 -0
- package/dist/handlers/delete-xero-payroll-timesheet.handler.js +28 -0
- package/dist/handlers/download-xero-invoice-attachment.handler.js +23 -0
- package/dist/handlers/download-xero-invoice-pdf.handler.js +25 -0
- package/dist/handlers/get-xero-invoice.handler.js +19 -0
- package/dist/handlers/get-xero-payroll-timesheet.handler.js +28 -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 +39 -0
- package/dist/handlers/list-xero-contact-groups.handler.js +34 -0
- package/dist/handlers/list-xero-contacts.handler.js +47 -0
- package/dist/handlers/list-xero-credit-notes.handler.js +42 -0
- package/dist/handlers/list-xero-invoice-attachments.handler.js +20 -0
- package/dist/handlers/list-xero-invoices.handler.js +54 -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 +52 -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 +36 -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 +62 -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/handlers/upload-xero-invoice-attachment.handler.js +36 -0
- package/dist/handlers/void-xero-invoice.handler.js +52 -0
- package/dist/helpers/build-where-clause.js +29 -0
- package/dist/helpers/create-xero-tool.js +6 -0
- package/dist/helpers/datetime.js +91 -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 +25 -0
- package/dist/helpers/format-line-item.js +13 -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-download-path.js +16 -0
- package/dist/helpers/get-external-link.js +8 -0
- package/dist/helpers/get-package-version.js +20 -0
- package/dist/index.js +18 -0
- package/dist/resources/register-resources.js +27 -0
- package/dist/server/xero-mcp-server.js +43 -0
- package/dist/tools/create/convert-quote-to-invoice.tool.js +46 -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 +78 -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 +35 -0
- package/dist/tools/create/upload-invoice-attachment.tool.js +49 -0
- package/dist/tools/delete/archive-contact.tool.js +30 -0
- package/dist/tools/delete/delete-invoice-attachment.tool.js +28 -0
- package/dist/tools/delete/delete-payroll-timesheet.tool.js +28 -0
- package/dist/tools/delete/index.js +15 -0
- package/dist/tools/get/get-invoice-attachment.tool.js +33 -0
- package/dist/tools/get/get-invoice-pdf.tool.js +33 -0
- package/dist/tools/get/get-invoice.tool.js +72 -0
- package/dist/tools/get/get-payroll-timesheet.tool.js +50 -0
- package/dist/tools/get/index.js +17 -0
- package/dist/tools/list/index.js +64 -0
- package/dist/tools/list/list-accounts.tool.js +39 -0
- package/dist/tools/list/list-aged-payables-by-contact.tool.js +51 -0
- package/dist/tools/list/list-aged-receivables-by-contact.tool.js +51 -0
- package/dist/tools/list/list-bank-transactions.tool.js +66 -0
- package/dist/tools/list/list-contact-groups.tool.js +48 -0
- package/dist/tools/list/list-contacts.tool.js +80 -0
- package/dist/tools/list/list-credit-notes.tool.js +72 -0
- package/dist/tools/list/list-invoice-attachments.tool.js +42 -0
- package/dist/tools/list/list-invoices.tool.js +98 -0
- package/dist/tools/list/list-items.tool.js +50 -0
- package/dist/tools/list/list-manual-journals.tool.js +80 -0
- package/dist/tools/list/list-organisation-details.tool.js +91 -0
- package/dist/tools/list/list-payments.tool.js +91 -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 +43 -0
- package/dist/tools/list/list-payroll-employees.tool.js +49 -0
- package/dist/tools/list/list-payroll-leave-periods.tool.js +45 -0
- package/dist/tools/list/list-payroll-leave-types.tool.js +40 -0
- package/dist/tools/list/list-payroll-timesheets.tool.js +40 -0
- package/dist/tools/list/list-profit-and-loss.tool.js +46 -0
- package/dist/tools/list/list-quotes.tool.js +69 -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 +42 -0
- package/dist/tools/tool-factory.js +24 -0
- package/dist/tools/update/approve-payroll-timesheet.tool.js +29 -0
- package/dist/tools/update/authorise-invoice.tool.js +42 -0
- package/dist/tools/update/index.js +39 -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 +76 -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/tools/update/void-invoice.tool.js +33 -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 +38 -0
|
@@ -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,35 @@
|
|
|
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
|
+
import ConvertQuoteToInvoiceTool from "./convert-quote-to-invoice.tool.js";
|
|
13
|
+
import UploadInvoiceAttachmentTool from "./upload-invoice-attachment.tool.js";
|
|
14
|
+
export const CoreCreateTools = [
|
|
15
|
+
CreateContactTool,
|
|
16
|
+
CreateCreditNoteTool,
|
|
17
|
+
CreateManualJournalTool,
|
|
18
|
+
CreateInvoiceTool,
|
|
19
|
+
CreateQuoteTool,
|
|
20
|
+
CreatePaymentTool,
|
|
21
|
+
CreateItemTool,
|
|
22
|
+
CreateBankTransactionTool,
|
|
23
|
+
CreateTrackingCategoryTool,
|
|
24
|
+
CreateTrackingOptionsTool,
|
|
25
|
+
ConvertQuoteToInvoiceTool,
|
|
26
|
+
UploadInvoiceAttachmentTool,
|
|
27
|
+
];
|
|
28
|
+
export const PayrollCreateTools = [
|
|
29
|
+
CreatePayrollTimesheetTool,
|
|
30
|
+
];
|
|
31
|
+
// Legacy export
|
|
32
|
+
export const CreateTools = [
|
|
33
|
+
...CoreCreateTools,
|
|
34
|
+
...PayrollCreateTools,
|
|
35
|
+
];
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { uploadXeroInvoiceAttachment } from "../../handlers/upload-xero-invoice-attachment.handler.js";
|
|
3
|
+
import { CreateXeroTool } from "../../helpers/create-xero-tool.js";
|
|
4
|
+
const UploadInvoiceAttachmentTool = CreateXeroTool("upload-invoice-attachment", "Upload a local file as an attachment to a Xero invoice (debtor or creditor). \
|
|
5
|
+
The file must exist on the local filesystem. \
|
|
6
|
+
Optionally set includeOnline to true to make the attachment visible \
|
|
7
|
+
in the Xero online invoice portal that is sent to customers. \
|
|
8
|
+
Useful for attaching externally-generated PDFs (e.g. from Crystal Reports) to invoices.", {
|
|
9
|
+
invoiceId: z.string().describe("The Xero ID of the invoice to attach the file to."),
|
|
10
|
+
filePath: z
|
|
11
|
+
.string()
|
|
12
|
+
.describe("Absolute path to the local file to upload (e.g. C:/Users/you/Documents/invoice.pdf)."),
|
|
13
|
+
fileName: z
|
|
14
|
+
.string()
|
|
15
|
+
.optional()
|
|
16
|
+
.describe("Filename to use in Xero. Defaults to the basename of filePath if not provided."),
|
|
17
|
+
includeOnline: z
|
|
18
|
+
.boolean()
|
|
19
|
+
.optional()
|
|
20
|
+
.default(false)
|
|
21
|
+
.describe("If true, the attachment will be visible to the customer in the Xero online invoice. Defaults to false."),
|
|
22
|
+
}, async ({ invoiceId, filePath, fileName, includeOnline }) => {
|
|
23
|
+
const result = await uploadXeroInvoiceAttachment(invoiceId, filePath, fileName, includeOnline);
|
|
24
|
+
if (result.isError) {
|
|
25
|
+
return {
|
|
26
|
+
content: [{ type: "text", text: `Error: ${result.error}` }],
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
const attachment = result.result;
|
|
30
|
+
return {
|
|
31
|
+
content: [
|
|
32
|
+
{
|
|
33
|
+
type: "text",
|
|
34
|
+
text: [
|
|
35
|
+
"Attachment uploaded successfully.",
|
|
36
|
+
`Filename: ${attachment.fileName}`,
|
|
37
|
+
`Attachment ID: ${attachment.attachmentID}`,
|
|
38
|
+
attachment.contentLength
|
|
39
|
+
? `Size: ${Math.round((attachment.contentLength / 1024) * 10) / 10} KB`
|
|
40
|
+
: null,
|
|
41
|
+
includeOnline ? "Visible in online invoice: Yes" : null,
|
|
42
|
+
]
|
|
43
|
+
.filter(Boolean)
|
|
44
|
+
.join("\n"),
|
|
45
|
+
},
|
|
46
|
+
],
|
|
47
|
+
};
|
|
48
|
+
});
|
|
49
|
+
export default UploadInvoiceAttachmentTool;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { archiveXeroContact } from "../../handlers/archive-xero-contact.handler.js";
|
|
3
|
+
import { CreateXeroTool } from "../../helpers/create-xero-tool.js";
|
|
4
|
+
const ArchiveContactTool = CreateXeroTool("archive-contact", "Archive a contact in Xero. Xero does not support permanently deleting contacts. \
|
|
5
|
+
Archiving hides the contact from active lists but preserves their transaction history. \
|
|
6
|
+
Always confirm with the user before archiving.", {
|
|
7
|
+
contactId: z.string().describe("The ID of the contact to archive."),
|
|
8
|
+
}, async ({ contactId }) => {
|
|
9
|
+
const result = await archiveXeroContact(contactId);
|
|
10
|
+
if (result.isError) {
|
|
11
|
+
return {
|
|
12
|
+
content: [{ type: "text", text: `Error: ${result.error}` }],
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
const contact = result.result;
|
|
16
|
+
return {
|
|
17
|
+
content: [
|
|
18
|
+
{
|
|
19
|
+
type: "text",
|
|
20
|
+
text: [
|
|
21
|
+
"Contact archived successfully.",
|
|
22
|
+
`Contact ID: ${contact.contactID}`,
|
|
23
|
+
`Name: ${contact.name}`,
|
|
24
|
+
`Status: ${contact.contactStatus}`,
|
|
25
|
+
].join("\n"),
|
|
26
|
+
},
|
|
27
|
+
],
|
|
28
|
+
};
|
|
29
|
+
});
|
|
30
|
+
export default ArchiveContactTool;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { deleteXeroInvoiceAttachment } from "../../handlers/delete-xero-invoice-attachment.handler.js";
|
|
3
|
+
import { CreateXeroTool } from "../../helpers/create-xero-tool.js";
|
|
4
|
+
const DeleteInvoiceAttachmentTool = CreateXeroTool("delete-invoice-attachment", "Delete a file attachment from a Xero invoice by its attachment ID. \
|
|
5
|
+
Use list-invoice-attachments to find the attachment ID. \
|
|
6
|
+
This only removes the attached file — it does not affect the invoice itself \
|
|
7
|
+
or the Xero-generated invoice PDF.", {
|
|
8
|
+
invoiceId: z.string().describe("The Xero ID of the invoice."),
|
|
9
|
+
attachmentId: z
|
|
10
|
+
.string()
|
|
11
|
+
.describe("The ID of the attachment to delete (from list-invoice-attachments)."),
|
|
12
|
+
}, async ({ invoiceId, attachmentId }) => {
|
|
13
|
+
const result = await deleteXeroInvoiceAttachment(invoiceId, attachmentId);
|
|
14
|
+
if (result.isError) {
|
|
15
|
+
return {
|
|
16
|
+
content: [{ type: "text", text: `Error: ${result.error}` }],
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
return {
|
|
20
|
+
content: [
|
|
21
|
+
{
|
|
22
|
+
type: "text",
|
|
23
|
+
text: `Attachment ${attachmentId} deleted successfully from invoice ${invoiceId}.`,
|
|
24
|
+
},
|
|
25
|
+
],
|
|
26
|
+
};
|
|
27
|
+
});
|
|
28
|
+
export default DeleteInvoiceAttachmentTool;
|
|
@@ -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,15 @@
|
|
|
1
|
+
import DeletePayrollTimesheetTool from "./delete-payroll-timesheet.tool.js";
|
|
2
|
+
import ArchiveContactTool from "./archive-contact.tool.js";
|
|
3
|
+
import DeleteInvoiceAttachmentTool from "./delete-invoice-attachment.tool.js";
|
|
4
|
+
export const CoreDeleteTools = [
|
|
5
|
+
ArchiveContactTool,
|
|
6
|
+
DeleteInvoiceAttachmentTool,
|
|
7
|
+
];
|
|
8
|
+
export const PayrollDeleteTools = [
|
|
9
|
+
DeletePayrollTimesheetTool,
|
|
10
|
+
];
|
|
11
|
+
// Legacy export
|
|
12
|
+
export const DeleteTools = [
|
|
13
|
+
...CoreDeleteTools,
|
|
14
|
+
...PayrollDeleteTools,
|
|
15
|
+
];
|
|
@@ -0,0 +1,33 @@
|
|
|
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", "Download a specific attachment from a Xero invoice and save it to the local download directory. \
|
|
5
|
+
Use list-invoice-attachments first to get the filename and content type. \
|
|
6
|
+
Returns the full local file path of the saved file.", {
|
|
7
|
+
invoiceId: z.string().describe("The Xero ID of the invoice."),
|
|
8
|
+
fileName: z.string().describe("The filename of the attachment (from list-invoice-attachments)."),
|
|
9
|
+
contentType: z
|
|
10
|
+
.string()
|
|
11
|
+
.optional()
|
|
12
|
+
.default("application/octet-stream")
|
|
13
|
+
.describe("The MIME type of the file (e.g. application/pdf, image/png). Defaults to application/octet-stream."),
|
|
14
|
+
}, async ({ invoiceId, fileName, contentType }) => {
|
|
15
|
+
const result = await downloadXeroInvoiceAttachment(invoiceId, fileName, contentType);
|
|
16
|
+
if (result.isError) {
|
|
17
|
+
return {
|
|
18
|
+
content: [{ type: "text", text: `Error: ${result.error}` }],
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
return {
|
|
22
|
+
content: [
|
|
23
|
+
{
|
|
24
|
+
type: "text",
|
|
25
|
+
text: [
|
|
26
|
+
"Attachment downloaded successfully.",
|
|
27
|
+
`Saved to: ${result.result}`,
|
|
28
|
+
].join("\n"),
|
|
29
|
+
},
|
|
30
|
+
],
|
|
31
|
+
};
|
|
32
|
+
});
|
|
33
|
+
export default GetInvoiceAttachmentTool;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { downloadXeroInvoicePdf } from "../../handlers/download-xero-invoice-pdf.handler.js";
|
|
3
|
+
import { CreateXeroTool } from "../../helpers/create-xero-tool.js";
|
|
4
|
+
const GetInvoicePdfTool = CreateXeroTool("get-invoice-pdf", "Download the Xero-generated PDF for an invoice and save it to the local download directory. \
|
|
5
|
+
The PDF is rendered by Xero using the organisation's active branding/invoice template — \
|
|
6
|
+
this is the same PDF you would get from 'Print PDF' in the Xero web application. \
|
|
7
|
+
To attach a custom externally-generated PDF (e.g. from Crystal Reports) to an invoice instead, \
|
|
8
|
+
use upload-invoice-attachment.", {
|
|
9
|
+
invoiceId: z.string().describe("The Xero ID of the invoice to download as PDF."),
|
|
10
|
+
fileName: z
|
|
11
|
+
.string()
|
|
12
|
+
.optional()
|
|
13
|
+
.describe("Filename to save as (e.g. INV-0042.pdf). Defaults to invoice-{invoiceId}.pdf if not provided."),
|
|
14
|
+
}, async ({ invoiceId, fileName }) => {
|
|
15
|
+
const result = await downloadXeroInvoicePdf(invoiceId, fileName);
|
|
16
|
+
if (result.isError) {
|
|
17
|
+
return {
|
|
18
|
+
content: [{ type: "text", text: `Error: ${result.error}` }],
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
return {
|
|
22
|
+
content: [
|
|
23
|
+
{
|
|
24
|
+
type: "text",
|
|
25
|
+
text: [
|
|
26
|
+
"Invoice PDF downloaded successfully.",
|
|
27
|
+
`Saved to: ${result.result}`,
|
|
28
|
+
].join("\n"),
|
|
29
|
+
},
|
|
30
|
+
],
|
|
31
|
+
};
|
|
32
|
+
});
|
|
33
|
+
export default GetInvoicePdfTool;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { getXeroInvoice } from "../../handlers/get-xero-invoice.handler.js";
|
|
3
|
+
import { DeepLinkType, getDeepLink } from "../../helpers/get-deeplink.js";
|
|
4
|
+
import { CreateXeroTool } from "../../helpers/create-xero-tool.js";
|
|
5
|
+
import { formatLineItem } from "../../helpers/format-line-item.js";
|
|
6
|
+
import { formatUtcDatetime } from "../../helpers/datetime.js";
|
|
7
|
+
import { Invoice } from "xero-node";
|
|
8
|
+
const GetInvoiceTool = CreateXeroTool("get-invoice", "Get full details of a single invoice in Xero by its ID, including all line items. \
|
|
9
|
+
Use list-invoices first to find the invoice ID if you only have an invoice number. \
|
|
10
|
+
A deep link to the invoice in Xero is also returned.", {
|
|
11
|
+
invoiceId: z.string().describe("The Xero ID of the invoice to retrieve."),
|
|
12
|
+
}, async ({ invoiceId }) => {
|
|
13
|
+
const result = await getXeroInvoice(invoiceId);
|
|
14
|
+
if (result.isError) {
|
|
15
|
+
return {
|
|
16
|
+
content: [{ type: "text", text: `Error: ${result.error}` }],
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
const invoice = result.result;
|
|
20
|
+
const deepLink = invoice.invoiceID
|
|
21
|
+
? await getDeepLink(invoice.type === Invoice.TypeEnum.ACCREC
|
|
22
|
+
? DeepLinkType.INVOICE
|
|
23
|
+
: DeepLinkType.BILL, invoice.invoiceID)
|
|
24
|
+
: null;
|
|
25
|
+
return {
|
|
26
|
+
content: [
|
|
27
|
+
{
|
|
28
|
+
type: "text",
|
|
29
|
+
text: [
|
|
30
|
+
`Invoice ID: ${invoice.invoiceID}`,
|
|
31
|
+
`Invoice Number: ${invoice.invoiceNumber ?? "N/A"}`,
|
|
32
|
+
invoice.reference ? `Reference: ${invoice.reference}` : null,
|
|
33
|
+
`Type: ${invoice.type}`,
|
|
34
|
+
`Status: ${invoice.status}`,
|
|
35
|
+
invoice.contact
|
|
36
|
+
? `Contact: ${invoice.contact.name} (${invoice.contact.contactID})`
|
|
37
|
+
: null,
|
|
38
|
+
invoice.date ? `Date: ${invoice.date}` : null,
|
|
39
|
+
invoice.dueDate ? `Due Date: ${invoice.dueDate}` : null,
|
|
40
|
+
invoice.lineAmountTypes
|
|
41
|
+
? `Line Amount Types: ${invoice.lineAmountTypes}`
|
|
42
|
+
: null,
|
|
43
|
+
invoice.subTotal ? `Sub Total: ${invoice.subTotal}` : null,
|
|
44
|
+
invoice.totalTax ? `Total Tax: ${invoice.totalTax}` : null,
|
|
45
|
+
`Total: ${invoice.total ?? 0}`,
|
|
46
|
+
invoice.totalDiscount
|
|
47
|
+
? `Total Discount: ${invoice.totalDiscount}`
|
|
48
|
+
: null,
|
|
49
|
+
invoice.currencyCode ? `Currency: ${invoice.currencyCode}` : null,
|
|
50
|
+
invoice.amountDue ? `Amount Due: ${invoice.amountDue}` : null,
|
|
51
|
+
invoice.amountPaid ? `Amount Paid: ${invoice.amountPaid}` : null,
|
|
52
|
+
invoice.amountCredited
|
|
53
|
+
? `Amount Credited: ${invoice.amountCredited}`
|
|
54
|
+
: null,
|
|
55
|
+
invoice.fullyPaidOnDate
|
|
56
|
+
? `Fully Paid On: ${invoice.fullyPaidOnDate}`
|
|
57
|
+
: null,
|
|
58
|
+
invoice.updatedDateUTC
|
|
59
|
+
? `Last Updated: ${formatUtcDatetime(invoice.updatedDateUTC)}`
|
|
60
|
+
: null,
|
|
61
|
+
invoice.lineItems?.length
|
|
62
|
+
? `\nLine Items:\n${invoice.lineItems.map(formatLineItem).join("\n")}`
|
|
63
|
+
: null,
|
|
64
|
+
deepLink ? `\nLink to view: ${deepLink}` : null,
|
|
65
|
+
]
|
|
66
|
+
.filter(Boolean)
|
|
67
|
+
.join("\n"),
|
|
68
|
+
},
|
|
69
|
+
],
|
|
70
|
+
};
|
|
71
|
+
});
|
|
72
|
+
export default GetInvoiceTool;
|
|
@@ -0,0 +1,50 @@
|
|
|
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
|
+
import { formatUtcDatetime } from "../../helpers/datetime.js";
|
|
5
|
+
const GetPayrollTimesheetTool = CreateXeroTool("get-timesheet", `Retrieve a single payroll timesheet from Xero by its ID.
|
|
6
|
+
This provides details such as the timesheet ID, employee ID, start and end dates, total hours, and the last updated date.`, {
|
|
7
|
+
timesheetID: z.string().describe("The ID of the timesheet to retrieve."),
|
|
8
|
+
}, async (params) => {
|
|
9
|
+
const { timesheetID } = params;
|
|
10
|
+
const response = await getXeroPayrollTimesheet(timesheetID);
|
|
11
|
+
if (response.isError) {
|
|
12
|
+
return {
|
|
13
|
+
content: [
|
|
14
|
+
{
|
|
15
|
+
type: "text",
|
|
16
|
+
text: `Error retrieving timesheet: ${response.error}`,
|
|
17
|
+
},
|
|
18
|
+
],
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
const timesheet = response.result;
|
|
22
|
+
if (!timesheet) {
|
|
23
|
+
return {
|
|
24
|
+
content: [
|
|
25
|
+
{
|
|
26
|
+
type: "text",
|
|
27
|
+
text: `No timesheet found with ID: ${timesheetID}`,
|
|
28
|
+
},
|
|
29
|
+
],
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
return {
|
|
33
|
+
content: [
|
|
34
|
+
{
|
|
35
|
+
type: "text",
|
|
36
|
+
text: [
|
|
37
|
+
`Timesheet ID: ${timesheet.timesheetID}`,
|
|
38
|
+
`Employee ID: ${timesheet.employeeID}`,
|
|
39
|
+
`Start Date: ${timesheet.startDate}`,
|
|
40
|
+
`End Date: ${timesheet.endDate}`,
|
|
41
|
+
`Total Hours: ${timesheet.totalHours}`,
|
|
42
|
+
`Last Updated: ${formatUtcDatetime(timesheet.updatedDateUTC)}`,
|
|
43
|
+
]
|
|
44
|
+
.filter(Boolean)
|
|
45
|
+
.join("\n"),
|
|
46
|
+
},
|
|
47
|
+
],
|
|
48
|
+
};
|
|
49
|
+
});
|
|
50
|
+
export default GetPayrollTimesheetTool;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import GetPayrollTimesheetTool from "./get-payroll-timesheet.tool.js";
|
|
2
|
+
import GetInvoiceTool from "./get-invoice.tool.js";
|
|
3
|
+
import GetInvoiceAttachmentTool from "./get-invoice-attachment.tool.js";
|
|
4
|
+
import GetInvoicePdfTool from "./get-invoice-pdf.tool.js";
|
|
5
|
+
export const CoreGetTools = [
|
|
6
|
+
GetInvoiceTool,
|
|
7
|
+
GetInvoiceAttachmentTool,
|
|
8
|
+
GetInvoicePdfTool,
|
|
9
|
+
];
|
|
10
|
+
export const PayrollGetTools = [
|
|
11
|
+
GetPayrollTimesheetTool,
|
|
12
|
+
];
|
|
13
|
+
// Legacy export
|
|
14
|
+
export const GetTools = [
|
|
15
|
+
...CoreGetTools,
|
|
16
|
+
...PayrollGetTools,
|
|
17
|
+
];
|
|
@@ -0,0 +1,64 @@
|
|
|
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 CoreListTools = [
|
|
28
|
+
ListAccountsTool,
|
|
29
|
+
ListContactsTool,
|
|
30
|
+
ListCreditNotesTool,
|
|
31
|
+
ListInvoicesTool,
|
|
32
|
+
ListItemsTool,
|
|
33
|
+
ListManualJournalsTool,
|
|
34
|
+
ListQuotesTool,
|
|
35
|
+
ListTaxRatesTool,
|
|
36
|
+
ListPaymentsTool,
|
|
37
|
+
ListBankTransactionsTool,
|
|
38
|
+
ListOrganisationDetailsTool,
|
|
39
|
+
ListContactGroupsTool,
|
|
40
|
+
ListTrackingCategoriesTool,
|
|
41
|
+
ListInvoiceAttachmentsTool,
|
|
42
|
+
];
|
|
43
|
+
export const ReportListTools = [
|
|
44
|
+
ListTrialBalanceTool,
|
|
45
|
+
ListProfitAndLossTool,
|
|
46
|
+
ListReportBalanceSheetTool,
|
|
47
|
+
ListAgedReceivablesByContact,
|
|
48
|
+
ListAgedPayablesByContact,
|
|
49
|
+
];
|
|
50
|
+
export const PayrollListTools = [
|
|
51
|
+
ListPayrollEmployeesTool,
|
|
52
|
+
ListPayrollEmployeeLeaveTool,
|
|
53
|
+
ListPayrollLeavePeriodsToolTool,
|
|
54
|
+
ListPayrollEmployeeLeaveTypesTool,
|
|
55
|
+
ListPayrollEmployeeLeaveBalancesTool,
|
|
56
|
+
ListPayrollLeaveTypesTool,
|
|
57
|
+
ListPayrollTimesheetsTool,
|
|
58
|
+
];
|
|
59
|
+
// Legacy export — kept for backwards compatibility; tool-factory now uses the named exports above
|
|
60
|
+
export const ListTools = [
|
|
61
|
+
...CoreListTools,
|
|
62
|
+
...ReportListTools,
|
|
63
|
+
...PayrollListTools,
|
|
64
|
+
];
|
|
@@ -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;
|