@mindstone/mcp-server-xero 0.0.17 → 0.1.1
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/README.md +46 -0
- package/dist/clients/xero-client.js +2 -3
- package/dist/handlers/create-xero-purchase-order.handler.js +50 -0
- package/dist/handlers/email-xero-invoice.handler.js +27 -0
- package/dist/handlers/list-xero-bank-summary.handler.js +38 -0
- package/dist/handlers/list-xero-budget-summary.handler.js +45 -0
- package/dist/handlers/list-xero-executive-summary.handler.js +37 -0
- package/dist/handlers/list-xero-purchase-orders.handler.js +29 -0
- package/dist/helpers/create-xero-tool.js +32 -1
- package/dist/helpers/get-deeplink.js +15 -4
- package/dist/helpers/xero-currencies.js +1 -1
- package/dist/server/xero-mcp-server.js +2 -1
- package/dist/tools/create/create-bank-transaction.tool.js +2 -1
- package/dist/tools/create/create-contact.tool.js +4 -3
- package/dist/tools/create/create-credit-note.tool.js +1 -0
- package/dist/tools/create/create-invoice.tool.js +1 -0
- package/dist/tools/create/create-item.tool.js +1 -0
- package/dist/tools/create/create-manual-journal.tool.js +4 -3
- package/dist/tools/create/create-payment.tool.js +1 -0
- package/dist/tools/create/create-payroll-timesheet.tool.js +1 -0
- package/dist/tools/create/create-purchase-order.tool.js +67 -0
- package/dist/tools/create/create-quote.tool.js +1 -0
- package/dist/tools/create/create-tracking-category.tool.js +2 -1
- package/dist/tools/create/create-tracking-options.tool.js +2 -1
- package/dist/tools/create/index.js +3 -1
- package/dist/tools/delete/delete-payroll-timesheet.tool.js +1 -0
- package/dist/tools/get/get-invoice-attachment.tool.js +1 -0
- package/dist/tools/get/get-payroll-timesheet.tool.js +1 -0
- package/dist/tools/history/index.js +2 -0
- package/dist/tools/list/index.js +9 -1
- package/dist/tools/list/list-accounts.tool.js +1 -0
- package/dist/tools/list/list-aged-payables-by-contact.tool.js +1 -0
- package/dist/tools/list/list-aged-receivables-by-contact.tool.js +1 -0
- package/dist/tools/list/list-bank-summary.tool.js +42 -0
- package/dist/tools/list/list-bank-transactions.tool.js +2 -1
- package/dist/tools/list/list-budget-summary.tool.js +48 -0
- package/dist/tools/list/list-contact-groups.tool.js +1 -0
- package/dist/tools/list/list-contacts.tool.js +1 -0
- package/dist/tools/list/list-credit-notes.tool.js +1 -0
- package/dist/tools/list/list-currencies.tool.js +1 -0
- package/dist/tools/list/list-executive-summary.tool.js +37 -0
- package/dist/tools/list/list-invoice-attachments.tool.js +1 -0
- package/dist/tools/list/list-invoices.tool.js +1 -0
- package/dist/tools/list/list-items.tool.js +1 -0
- package/dist/tools/list/list-manual-journals.tool.js +1 -0
- package/dist/tools/list/list-organisation-details.tool.js +1 -0
- package/dist/tools/list/list-payments.tool.js +1 -0
- package/dist/tools/list/list-payroll-employee-leave-balances.tool.js +1 -0
- package/dist/tools/list/list-payroll-employee-leave-types.tool.js +1 -0
- package/dist/tools/list/list-payroll-employee-leave.tool.js +1 -0
- package/dist/tools/list/list-payroll-employees.tool.js +1 -0
- package/dist/tools/list/list-payroll-leave-periods.tool.js +1 -0
- package/dist/tools/list/list-payroll-leave-types.tool.js +1 -0
- package/dist/tools/list/list-payroll-timesheets.tool.js +1 -0
- package/dist/tools/list/list-profit-and-loss.tool.js +1 -0
- package/dist/tools/list/list-purchase-orders.tool.js +98 -0
- package/dist/tools/list/list-quotes.tool.js +1 -0
- package/dist/tools/list/list-report-balance-sheet.tool.js +1 -0
- package/dist/tools/list/list-tax-rates.tool.js +1 -0
- package/dist/tools/list/list-tracking-categories.tool.js +2 -1
- package/dist/tools/list/list-trial-balance.tool.js +1 -0
- package/dist/tools/tool-factory.js +4 -1
- package/dist/tools/update/approve-payroll-timesheet.tool.js +1 -0
- package/dist/tools/update/email-invoice.tool.js +30 -0
- package/dist/tools/update/index.js +3 -1
- package/dist/tools/update/revert-payroll-timesheet.tool.js +1 -0
- package/dist/tools/update/update-bank-transaction.tool.js +1 -0
- package/dist/tools/update/update-contact.tool.js +4 -3
- package/dist/tools/update/update-credit-note.tool.js +1 -0
- package/dist/tools/update/update-invoice.tool.js +1 -0
- package/dist/tools/update/update-item.tool.js +1 -0
- package/dist/tools/update/update-manual-journal-tool.js +4 -3
- package/dist/tools/update/update-payroll-timesheet-add-line.tool.js +1 -0
- package/dist/tools/update/update-payroll-timesheet-update-line.tool.js +1 -0
- package/dist/tools/update/update-quote.tool.js +1 -0
- package/dist/tools/update/update-tracking-category.tool.js +2 -1
- package/dist/tools/update/update-tracking-options.tool.js +2 -1
- package/dist/untrusted-content.js +130 -0
- package/package.json +2 -2
- package/dist/helpers/ensure-error.js +0 -13
|
@@ -5,6 +5,7 @@ import CreateInvoiceTool from "./create-invoice.tool.js";
|
|
|
5
5
|
import CreateItemTool from "./create-item.tool.js";
|
|
6
6
|
import CreateManualJournalTool from "./create-manual-journal.tool.js";
|
|
7
7
|
import CreatePaymentTool from "./create-payment.tool.js";
|
|
8
|
+
import CreatePurchaseOrderTool from "./create-purchase-order.tool.js";
|
|
8
9
|
import CreatePayrollTimesheetTool from "./create-payroll-timesheet.tool.js";
|
|
9
10
|
import CreateQuoteTool from "./create-quote.tool.js";
|
|
10
11
|
import CreateTrackingCategoryTool from "./create-tracking-category.tool.js";
|
|
@@ -20,5 +21,6 @@ export const CreateTools = [
|
|
|
20
21
|
CreateBankTransactionTool,
|
|
21
22
|
CreatePayrollTimesheetTool,
|
|
22
23
|
CreateTrackingCategoryTool,
|
|
23
|
-
CreateTrackingOptionsTool
|
|
24
|
+
CreateTrackingOptionsTool,
|
|
25
|
+
CreatePurchaseOrderTool
|
|
24
26
|
];
|
|
@@ -73,6 +73,7 @@ function createGetHistoryTool(def) {
|
|
|
73
73
|
text: `Error retrieving ${def.entity} history: ${response.error}`,
|
|
74
74
|
},
|
|
75
75
|
],
|
|
76
|
+
isError: true,
|
|
76
77
|
};
|
|
77
78
|
}
|
|
78
79
|
const records = response.result;
|
|
@@ -115,6 +116,7 @@ function createAddNoteTool(def) {
|
|
|
115
116
|
text: `Error adding note to ${def.entity}: ${response.error}`,
|
|
116
117
|
},
|
|
117
118
|
],
|
|
119
|
+
isError: true,
|
|
118
120
|
};
|
|
119
121
|
}
|
|
120
122
|
const record = response.result;
|
package/dist/tools/list/index.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import ListAccountsTool from "./list-accounts.tool.js";
|
|
2
2
|
import ListAgedPayablesByContact from "./list-aged-payables-by-contact.tool.js";
|
|
3
3
|
import ListAgedReceivablesByContact from "./list-aged-receivables-by-contact.tool.js";
|
|
4
|
+
import ListBankSummaryTool from "./list-bank-summary.tool.js";
|
|
4
5
|
import ListBankTransactionsTool from "./list-bank-transactions.tool.js";
|
|
6
|
+
import ListBudgetSummaryTool from "./list-budget-summary.tool.js";
|
|
5
7
|
import ListContactsTool from "./list-contacts.tool.js";
|
|
6
8
|
import ListCreditNotesTool from "./list-credit-notes.tool.js";
|
|
7
9
|
import ListCurrenciesTool from "./list-currencies.tool.js";
|
|
@@ -10,6 +12,7 @@ import ListItemsTool from "./list-items.tool.js";
|
|
|
10
12
|
import ListManualJournalsTool from "./list-manual-journals.tool.js";
|
|
11
13
|
import ListOrganisationDetailsTool from "./list-organisation-details.tool.js";
|
|
12
14
|
import ListPaymentsTool from "./list-payments.tool.js";
|
|
15
|
+
import ListPurchaseOrdersTool from "./list-purchase-orders.tool.js";
|
|
13
16
|
import ListPayrollEmployeeLeaveBalancesTool from "./list-payroll-employee-leave-balances.tool.js";
|
|
14
17
|
import ListPayrollEmployeeLeaveTypesTool from "./list-payroll-employee-leave-types.tool.js";
|
|
15
18
|
import ListPayrollEmployeeLeaveTool from "./list-payroll-employee-leave.tool.js";
|
|
@@ -25,6 +28,7 @@ import ListTrackingCategoriesTool from "./list-tracking-categories.tool.js";
|
|
|
25
28
|
import ListTrialBalanceTool from "./list-trial-balance.tool.js";
|
|
26
29
|
import ListContactGroupsTool from "./list-contact-groups.tool.js";
|
|
27
30
|
import ListInvoiceAttachmentsTool from "./list-invoice-attachments.tool.js";
|
|
31
|
+
import ListExecutiveSummaryTool from "./list-executive-summary.tool.js";
|
|
28
32
|
export const ListTools = [
|
|
29
33
|
ListAccountsTool,
|
|
30
34
|
ListContactsTool,
|
|
@@ -52,5 +56,9 @@ export const ListTools = [
|
|
|
52
56
|
ListPayrollTimesheetsTool,
|
|
53
57
|
ListContactGroupsTool,
|
|
54
58
|
ListTrackingCategoriesTool,
|
|
55
|
-
ListInvoiceAttachmentsTool
|
|
59
|
+
ListInvoiceAttachmentsTool,
|
|
60
|
+
ListBankSummaryTool,
|
|
61
|
+
ListBudgetSummaryTool,
|
|
62
|
+
ListExecutiveSummaryTool,
|
|
63
|
+
ListPurchaseOrdersTool
|
|
56
64
|
];
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { listXeroBankSummary } from "../../handlers/list-xero-bank-summary.handler.js";
|
|
3
|
+
import { CreateXeroTool } from "../../helpers/create-xero-tool.js";
|
|
4
|
+
const ListBankSummaryTool = CreateXeroTool("list-bank-summary", "Get the bank summary report from Xero: opening and closing balances plus total money in/out per bank account over a period. Useful for cash-position questions.", {
|
|
5
|
+
fromDate: z
|
|
6
|
+
.string()
|
|
7
|
+
.regex(/^\d{4}-\d{2}-\d{2}$/, "Must be YYYY-MM-DD format")
|
|
8
|
+
.optional()
|
|
9
|
+
.describe("Optional start date of the report period (YYYY-MM-DD)"),
|
|
10
|
+
toDate: z
|
|
11
|
+
.string()
|
|
12
|
+
.regex(/^\d{4}-\d{2}-\d{2}$/, "Must be YYYY-MM-DD format")
|
|
13
|
+
.optional()
|
|
14
|
+
.describe("Optional end date of the report period (YYYY-MM-DD)"),
|
|
15
|
+
}, async ({ fromDate, toDate }) => {
|
|
16
|
+
const response = await listXeroBankSummary(fromDate, toDate);
|
|
17
|
+
if (response.error !== null) {
|
|
18
|
+
return {
|
|
19
|
+
content: [
|
|
20
|
+
{
|
|
21
|
+
type: "text",
|
|
22
|
+
text: `Error getting bank summary report: ${response.error}`,
|
|
23
|
+
},
|
|
24
|
+
],
|
|
25
|
+
isError: true,
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
const report = response.result;
|
|
29
|
+
return {
|
|
30
|
+
content: [
|
|
31
|
+
{
|
|
32
|
+
type: "text",
|
|
33
|
+
text: `Bank Summary Report: ${report?.reportName ?? "Unnamed"}`,
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
type: "text",
|
|
37
|
+
text: JSON.stringify(report.rows, null, 2),
|
|
38
|
+
},
|
|
39
|
+
],
|
|
40
|
+
};
|
|
41
|
+
});
|
|
42
|
+
export default ListBankSummaryTool;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { listXeroBudgetSummary } from "../../handlers/list-xero-budget-summary.handler.js";
|
|
3
|
+
import { CreateXeroTool } from "../../helpers/create-xero-tool.js";
|
|
4
|
+
const ListBudgetSummaryTool = CreateXeroTool("list-budget-summary", "Get the budget summary report from Xero: budgeted vs actual figures per account. Useful for 'are we tracking to budget?' questions. Requires budgets to be set up in the Xero organisation.", {
|
|
5
|
+
date: z
|
|
6
|
+
.string()
|
|
7
|
+
.regex(/^\d{4}-\d{2}-\d{2}$/, "Must be YYYY-MM-DD format")
|
|
8
|
+
.optional()
|
|
9
|
+
.describe("Optional date for the report (YYYY-MM-DD)"),
|
|
10
|
+
periods: z
|
|
11
|
+
.number()
|
|
12
|
+
.int()
|
|
13
|
+
.min(1)
|
|
14
|
+
.max(12)
|
|
15
|
+
.optional()
|
|
16
|
+
.describe("Optional number of periods to compare (1-12)"),
|
|
17
|
+
timeframe: z
|
|
18
|
+
.enum(["MONTH", "QUARTER", "YEAR"])
|
|
19
|
+
.optional()
|
|
20
|
+
.describe("Optional period size to compare (MONTH, QUARTER, YEAR)"),
|
|
21
|
+
}, async ({ date, periods, timeframe }) => {
|
|
22
|
+
const response = await listXeroBudgetSummary(date, periods, timeframe);
|
|
23
|
+
if (response.error !== null) {
|
|
24
|
+
return {
|
|
25
|
+
content: [
|
|
26
|
+
{
|
|
27
|
+
type: "text",
|
|
28
|
+
text: `Error getting budget summary report: ${response.error}`,
|
|
29
|
+
},
|
|
30
|
+
],
|
|
31
|
+
isError: true,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
const report = response.result;
|
|
35
|
+
return {
|
|
36
|
+
content: [
|
|
37
|
+
{
|
|
38
|
+
type: "text",
|
|
39
|
+
text: `Budget Summary Report: ${report?.reportName ?? "Unnamed"}`,
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
type: "text",
|
|
43
|
+
text: JSON.stringify(report.rows, null, 2),
|
|
44
|
+
},
|
|
45
|
+
],
|
|
46
|
+
};
|
|
47
|
+
});
|
|
48
|
+
export default ListBudgetSummaryTool;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { listXeroExecutiveSummary } from "../../handlers/list-xero-executive-summary.handler.js";
|
|
3
|
+
import { CreateXeroTool } from "../../helpers/create-xero-tool.js";
|
|
4
|
+
const ListExecutiveSummaryTool = CreateXeroTool("list-executive-summary", "Get the executive summary report from Xero: a high-level snapshot of key financial metrics (cash, debtors, creditors, revenue, profit) for a date. Useful for 'how is the business doing?' questions.", {
|
|
5
|
+
date: z
|
|
6
|
+
.string()
|
|
7
|
+
.regex(/^\d{4}-\d{2}-\d{2}$/, "Must be YYYY-MM-DD format")
|
|
8
|
+
.optional()
|
|
9
|
+
.describe("Optional date for the report (YYYY-MM-DD)"),
|
|
10
|
+
}, async ({ date }) => {
|
|
11
|
+
const response = await listXeroExecutiveSummary(date);
|
|
12
|
+
if (response.error !== null) {
|
|
13
|
+
return {
|
|
14
|
+
content: [
|
|
15
|
+
{
|
|
16
|
+
type: "text",
|
|
17
|
+
text: `Error getting executive summary report: ${response.error}`,
|
|
18
|
+
},
|
|
19
|
+
],
|
|
20
|
+
isError: true,
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
const report = response.result;
|
|
24
|
+
return {
|
|
25
|
+
content: [
|
|
26
|
+
{
|
|
27
|
+
type: "text",
|
|
28
|
+
text: `Executive Summary Report: ${report?.reportName ?? "Unnamed"}`,
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
type: "text",
|
|
32
|
+
text: JSON.stringify(report.rows, null, 2),
|
|
33
|
+
},
|
|
34
|
+
],
|
|
35
|
+
};
|
|
36
|
+
});
|
|
37
|
+
export default ListExecutiveSummaryTool;
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { listXeroPurchaseOrders } from "../../handlers/list-xero-purchase-orders.handler.js";
|
|
3
|
+
import { CreateXeroTool } from "../../helpers/create-xero-tool.js";
|
|
4
|
+
const ListPurchaseOrdersTool = CreateXeroTool("list-purchase-orders", `List purchase orders in Xero. Returns up to pageSize results per page (default 100, max 100).
|
|
5
|
+
|
|
6
|
+
FILTERING: Use status to filter (DRAFT, SUBMITTED, AUTHORISED, BILLED, DELETED). Use dateFrom/dateTo for date ranges (YYYY-MM-DD).
|
|
7
|
+
|
|
8
|
+
PAGINATION: If results returned equals pageSize, there may be more pages. Call again with page+1.`, {
|
|
9
|
+
page: z
|
|
10
|
+
.number()
|
|
11
|
+
.int()
|
|
12
|
+
.min(1)
|
|
13
|
+
.optional()
|
|
14
|
+
.describe("Page number (1-based). If results equal pageSize, there may be more pages."),
|
|
15
|
+
status: z
|
|
16
|
+
.enum(["DRAFT", "SUBMITTED", "AUTHORISED", "BILLED", "DELETED"])
|
|
17
|
+
.optional()
|
|
18
|
+
.describe("Filter by purchase order status"),
|
|
19
|
+
dateFrom: z
|
|
20
|
+
.string()
|
|
21
|
+
.regex(/^\d{4}-\d{2}-\d{2}$/, "Must be YYYY-MM-DD format")
|
|
22
|
+
.optional()
|
|
23
|
+
.describe("Only purchase orders on or after this date (YYYY-MM-DD)"),
|
|
24
|
+
dateTo: z
|
|
25
|
+
.string()
|
|
26
|
+
.regex(/^\d{4}-\d{2}-\d{2}$/, "Must be YYYY-MM-DD format")
|
|
27
|
+
.optional()
|
|
28
|
+
.describe("Only purchase orders on or before this date (YYYY-MM-DD)"),
|
|
29
|
+
orderBy: z
|
|
30
|
+
.enum(["Date", "DeliveryDate", "PurchaseOrderNumber"])
|
|
31
|
+
.optional()
|
|
32
|
+
.describe("Sort field. Default: Xero's default order"),
|
|
33
|
+
orderDirection: z
|
|
34
|
+
.enum(["ASC", "DESC"])
|
|
35
|
+
.optional()
|
|
36
|
+
.describe("Sort direction. Only applied when orderBy is set"),
|
|
37
|
+
pageSize: z
|
|
38
|
+
.number()
|
|
39
|
+
.int()
|
|
40
|
+
.min(1)
|
|
41
|
+
.max(100)
|
|
42
|
+
.optional()
|
|
43
|
+
.describe("Results per page (default 100, max 100)"),
|
|
44
|
+
}, async ({ page, status, dateFrom, dateTo, orderBy, orderDirection, pageSize }) => {
|
|
45
|
+
const order = orderBy
|
|
46
|
+
? `${orderBy} ${orderDirection ?? "ASC"}`
|
|
47
|
+
: undefined;
|
|
48
|
+
const response = await listXeroPurchaseOrders(page ?? 1, status, dateFrom, dateTo, order, pageSize);
|
|
49
|
+
if (response.error !== null) {
|
|
50
|
+
return {
|
|
51
|
+
content: [
|
|
52
|
+
{
|
|
53
|
+
type: "text",
|
|
54
|
+
text: `Error listing purchase orders: ${response.error}`,
|
|
55
|
+
},
|
|
56
|
+
],
|
|
57
|
+
isError: true,
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
const purchaseOrders = response.result;
|
|
61
|
+
const effectivePageSize = pageSize ?? 100;
|
|
62
|
+
const count = purchaseOrders?.length ?? 0;
|
|
63
|
+
return {
|
|
64
|
+
content: [
|
|
65
|
+
{
|
|
66
|
+
type: "text",
|
|
67
|
+
text: count === effectivePageSize
|
|
68
|
+
? `Found ${count} purchase orders. The number of results equals pageSize (${effectivePageSize}), so there may be more pages.`
|
|
69
|
+
: `Found ${count} purchase orders:`,
|
|
70
|
+
},
|
|
71
|
+
...(purchaseOrders?.map((purchaseOrder) => ({
|
|
72
|
+
type: "text",
|
|
73
|
+
text: [
|
|
74
|
+
`Purchase Order ID: ${purchaseOrder.purchaseOrderID}`,
|
|
75
|
+
`Purchase Order: ${purchaseOrder.purchaseOrderNumber}`,
|
|
76
|
+
purchaseOrder.reference
|
|
77
|
+
? `Reference: ${purchaseOrder.reference}`
|
|
78
|
+
: null,
|
|
79
|
+
`Status: ${purchaseOrder.status || "Unknown"}`,
|
|
80
|
+
purchaseOrder.contact
|
|
81
|
+
? `Contact: ${purchaseOrder.contact.name} (${purchaseOrder.contact.contactID})`
|
|
82
|
+
: null,
|
|
83
|
+
purchaseOrder.date ? `Date: ${purchaseOrder.date}` : null,
|
|
84
|
+
purchaseOrder.deliveryDate
|
|
85
|
+
? `Delivery Date: ${purchaseOrder.deliveryDate}`
|
|
86
|
+
: null,
|
|
87
|
+
purchaseOrder.currencyCode
|
|
88
|
+
? `Currency: ${purchaseOrder.currencyCode}`
|
|
89
|
+
: null,
|
|
90
|
+
`Total: ${purchaseOrder.total || 0}`,
|
|
91
|
+
]
|
|
92
|
+
.filter(Boolean)
|
|
93
|
+
.join("\n"),
|
|
94
|
+
})) || []),
|
|
95
|
+
],
|
|
96
|
+
};
|
|
97
|
+
});
|
|
98
|
+
export default ListPurchaseOrdersTool;
|
|
@@ -18,7 +18,10 @@ export function ToolFactory(server) {
|
|
|
18
18
|
DeleteTools.map((tool) => tool()).forEach((tool) => server.tool(tool.name, tool.description, tool.schema, WRITE_ANNOTATIONS, tool.handler));
|
|
19
19
|
GetTools.map((tool) => tool()).forEach((tool) => server.tool(tool.name, tool.description, tool.schema, READ_ONLY_ANNOTATIONS, tool.handler));
|
|
20
20
|
CreateTools.map((tool) => tool()).forEach((tool) => server.tool(tool.name, tool.description, tool.schema, WRITE_ANNOTATIONS, tool.handler));
|
|
21
|
-
HistoryTools.map((tool) => tool()).forEach((tool) =>
|
|
21
|
+
HistoryTools.map((tool) => tool()).forEach((tool) => {
|
|
22
|
+
const isReadOnly = tool.name.startsWith("get-");
|
|
23
|
+
server.tool(tool.name, tool.description, tool.schema, isReadOnly ? READ_ONLY_ANNOTATIONS : WRITE_ANNOTATIONS, tool.handler);
|
|
24
|
+
});
|
|
22
25
|
ListTools.map((tool) => tool()).forEach((tool) => server.tool(tool.name, tool.description, tool.schema, READ_ONLY_ANNOTATIONS, tool.handler));
|
|
23
26
|
UpdateTools.map((tool) => tool()).forEach((tool) => server.tool(tool.name, tool.description, tool.schema, WRITE_ANNOTATIONS, tool.handler));
|
|
24
27
|
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { emailXeroInvoice } from "../../handlers/email-xero-invoice.handler.js";
|
|
3
|
+
import { CreateXeroTool } from "../../helpers/create-xero-tool.js";
|
|
4
|
+
const EmailInvoiceTool = CreateXeroTool("email-invoice", "Email a copy of an invoice to its related contact via Xero. The invoice must be AUTHORISED — Xero rejects emails for DRAFT or SUBMITTED invoices. Use list-invoices to find the invoice ID.", {
|
|
5
|
+
invoiceId: z
|
|
6
|
+
.string()
|
|
7
|
+
.describe("The Xero invoice ID (UUID) of the AUTHORISED invoice to email"),
|
|
8
|
+
}, async ({ invoiceId }) => {
|
|
9
|
+
const response = await emailXeroInvoice(invoiceId);
|
|
10
|
+
if (response.error !== null) {
|
|
11
|
+
return {
|
|
12
|
+
content: [
|
|
13
|
+
{
|
|
14
|
+
type: "text",
|
|
15
|
+
text: `Error emailing invoice: ${response.error}`,
|
|
16
|
+
},
|
|
17
|
+
],
|
|
18
|
+
isError: true,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
return {
|
|
22
|
+
content: [
|
|
23
|
+
{
|
|
24
|
+
type: "text",
|
|
25
|
+
text: `Invoice ${invoiceId} was emailed to its related contact.`,
|
|
26
|
+
},
|
|
27
|
+
],
|
|
28
|
+
};
|
|
29
|
+
});
|
|
30
|
+
export default EmailInvoiceTool;
|