@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
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import ApprovePayrollTimesheetTool from "./approve-payroll-timesheet.tool.js";
|
|
2
|
+
import EmailInvoiceTool from "./email-invoice.tool.js";
|
|
2
3
|
import RevertPayrollTimesheetTool from "./revert-payroll-timesheet.tool.js";
|
|
3
4
|
import UpdateBankTransactionTool from "./update-bank-transaction.tool.js";
|
|
4
5
|
import UpdateContactTool from "./update-contact.tool.js";
|
|
@@ -24,5 +25,6 @@ export const UpdateTools = [
|
|
|
24
25
|
UpdatePayrollTimesheetLineTool,
|
|
25
26
|
RevertPayrollTimesheetTool,
|
|
26
27
|
UpdateTrackingCategoryTool,
|
|
27
|
-
UpdateTrackingOptionsTool
|
|
28
|
+
UpdateTrackingOptionsTool,
|
|
29
|
+
EmailInvoiceTool
|
|
28
30
|
];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { updateXeroContact } from "../../handlers/update-xero-contact.handler.js";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
import { DeepLinkType, getDeepLink } from "../../helpers/get-deeplink.js";
|
|
4
|
-
import {
|
|
4
|
+
import { formatError } from "../../helpers/format-error.js";
|
|
5
5
|
import { CreateXeroTool } from "../../helpers/create-xero-tool.js";
|
|
6
6
|
const UpdateContactTool = CreateXeroTool("update-contact", "Update a contact in Xero.\
|
|
7
7
|
When a contact is updated, a deep link to the contact in Xero is returned. \
|
|
@@ -34,6 +34,7 @@ const UpdateContactTool = CreateXeroTool("update-contact", "Update a contact in
|
|
|
34
34
|
text: `Error updating contact: ${response.error}`,
|
|
35
35
|
},
|
|
36
36
|
],
|
|
37
|
+
isError: true,
|
|
37
38
|
};
|
|
38
39
|
}
|
|
39
40
|
const contact = response.result;
|
|
@@ -55,14 +56,14 @@ const UpdateContactTool = CreateXeroTool("update-contact", "Update a contact in
|
|
|
55
56
|
};
|
|
56
57
|
}
|
|
57
58
|
catch (error) {
|
|
58
|
-
const err = ensureError(error);
|
|
59
59
|
return {
|
|
60
60
|
content: [
|
|
61
61
|
{
|
|
62
62
|
type: "text",
|
|
63
|
-
text: `Error
|
|
63
|
+
text: `Error updating contact: ${formatError(error)}`,
|
|
64
64
|
},
|
|
65
65
|
],
|
|
66
|
+
isError: true,
|
|
66
67
|
};
|
|
67
68
|
}
|
|
68
69
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { CreateXeroTool } from "../../helpers/create-xero-tool.js";
|
|
3
3
|
import { DeepLinkType, getDeepLink } from "../../helpers/get-deeplink.js";
|
|
4
|
-
import {
|
|
4
|
+
import { formatError } from "../../helpers/format-error.js";
|
|
5
5
|
import { updateXeroManualJournal } from "../../handlers/update-xero-manual-journal.handler.js";
|
|
6
6
|
const UpdateManualJournalTool = CreateXeroTool("update-manual-journal", "Update a manual journal in Xero. Only works on draft manual journals.\
|
|
7
7
|
Do not modify line items or parameters that have not been specified by the user.", {
|
|
@@ -54,6 +54,7 @@ const UpdateManualJournalTool = CreateXeroTool("update-manual-journal", "Update
|
|
|
54
54
|
text: `Error updating manual journal: ${response.error}`,
|
|
55
55
|
},
|
|
56
56
|
],
|
|
57
|
+
isError: true,
|
|
57
58
|
};
|
|
58
59
|
}
|
|
59
60
|
const manualJournal = response.result;
|
|
@@ -75,14 +76,14 @@ const UpdateManualJournalTool = CreateXeroTool("update-manual-journal", "Update
|
|
|
75
76
|
};
|
|
76
77
|
}
|
|
77
78
|
catch (error) {
|
|
78
|
-
const err = ensureError(error);
|
|
79
79
|
return {
|
|
80
80
|
content: [
|
|
81
81
|
{
|
|
82
82
|
type: "text",
|
|
83
|
-
text: `Error updating manual journal: ${
|
|
83
|
+
text: `Error updating manual journal: ${formatError(error)}`,
|
|
84
84
|
},
|
|
85
85
|
],
|
|
86
|
+
isError: true,
|
|
86
87
|
};
|
|
87
88
|
}
|
|
88
89
|
});
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AGENTS.md security invariant #6 — content fetched from an external system
|
|
3
|
+
* MUST be wrapped in an `<untrusted-content source="…">…</untrusted-content>`
|
|
4
|
+
* envelope (with close-tag breakout escaping) before it is returned to the
|
|
5
|
+
* LLM, so the model treats third-party / attacker-controllable text as DATA,
|
|
6
|
+
* not as instructions.
|
|
7
|
+
*
|
|
8
|
+
* This is the canonical implementation a new connector ships with. It is a
|
|
9
|
+
* VENDORED copy of the shared reference in `test-harness/src/untrusted-content.ts`
|
|
10
|
+
* — connectors cannot `import` the test-harness at runtime (it is a
|
|
11
|
+
* test/dev-only `file:` dependency that is never published into a connector's
|
|
12
|
+
* `dist/`), so the helper lives in the connector's own runtime source. Keep
|
|
13
|
+
* this byte-for-byte in sync with the shared reference; do NOT weaken the
|
|
14
|
+
* escaping back to a simple `replaceAll` (that family misses whitespace / case
|
|
15
|
+
* close-tag variants like `</untrusted-content >` / `</UNTRUSTED-CONTENT>`).
|
|
16
|
+
*
|
|
17
|
+
* `scripts/check-untrusted-coverage.mjs` greps for a reference to
|
|
18
|
+
* `untrusted-content` in any connector that talks to an external system; this
|
|
19
|
+
* file (and the call sites that import from it) is what satisfies that gate.
|
|
20
|
+
*/
|
|
21
|
+
const UNTRUSTED_CLOSE_TAG_VARIANT = /<\/untrusted-content(?:\s[^>]*)?>/gi;
|
|
22
|
+
const ESCAPED_UNTRUSTED_CLOSE_TAG = '<\\/untrusted-content>';
|
|
23
|
+
const UNTRUSTED_OPEN_TAG_VARIANT = /<untrusted-content(?:\s[^>]*)?>/gi;
|
|
24
|
+
const ESCAPED_UNTRUSTED_OPEN_TAG = '<\\untrusted-content>';
|
|
25
|
+
const UNTRUSTED_ENVELOPE = /^<untrusted-content source="[^"]*">([\s\S]*)<\/untrusted-content>$/;
|
|
26
|
+
function escapeAttr(s) {
|
|
27
|
+
return s.replaceAll('&', '&').replaceAll('"', '"').replaceAll('<', '<').replaceAll('>', '>');
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Rewrite every `</untrusted-content>` and `<untrusted-content …>` variant
|
|
31
|
+
* (case-insensitive, optional whitespace / attributes before `>`) inside `s`
|
|
32
|
+
* to a benign textual form, so an attacker who controls the wrapped content
|
|
33
|
+
* can neither terminate the envelope early nor spoof a nested open tag that a
|
|
34
|
+
* downstream parser could re-read as a fresh envelope. An LLM parsing the
|
|
35
|
+
* markup plausibly accepts attribute-bearing close forms such as
|
|
36
|
+
* `</untrusted-content foo>` — the matcher must cover them too.
|
|
37
|
+
*/
|
|
38
|
+
function escapeTagSentinels(s) {
|
|
39
|
+
return s
|
|
40
|
+
.replace(UNTRUSTED_OPEN_TAG_VARIANT, ESCAPED_UNTRUSTED_OPEN_TAG)
|
|
41
|
+
.replace(UNTRUSTED_CLOSE_TAG_VARIANT, ESCAPED_UNTRUSTED_CLOSE_TAG);
|
|
42
|
+
}
|
|
43
|
+
function unescapeTagSentinels(s) {
|
|
44
|
+
return s
|
|
45
|
+
.replaceAll(ESCAPED_UNTRUSTED_OPEN_TAG, '<untrusted-content>')
|
|
46
|
+
.replaceAll(ESCAPED_UNTRUSTED_CLOSE_TAG, '</untrusted-content>');
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Wrap a single untrusted string in an `<untrusted-content source="…">`
|
|
50
|
+
* envelope, escaping any embedded open/close-tag variant so the envelope can
|
|
51
|
+
* neither be broken out of nor have a spoofed nested envelope planted inside.
|
|
52
|
+
*
|
|
53
|
+
* `undefined` and `null` are passed through untouched so callers can apply the wrapper
|
|
54
|
+
* uniformly to optional fields without branching.
|
|
55
|
+
*
|
|
56
|
+
* Idempotent: when `text` is already a properly-shaped envelope for the SAME
|
|
57
|
+
* `source` (starts with the matching OPEN tag, ends with CLOSE, and contains no
|
|
58
|
+
* internal open/close-tag variants), the original string is returned unchanged so
|
|
59
|
+
* `wrapUntrusted(wrapUntrusted(s, src), src) === wrapUntrusted(s, src)`.
|
|
60
|
+
*/
|
|
61
|
+
export function wrapUntrusted(text, source) {
|
|
62
|
+
if (text === undefined || text === null)
|
|
63
|
+
return undefined;
|
|
64
|
+
const open = `<untrusted-content source="${escapeAttr(source)}">`;
|
|
65
|
+
const close = '</untrusted-content>';
|
|
66
|
+
if (text.startsWith(open) && text.endsWith(close) && text.length >= open.length + close.length) {
|
|
67
|
+
const inner = text.slice(open.length, text.length - close.length);
|
|
68
|
+
const hasVariant = UNTRUSTED_CLOSE_TAG_VARIANT.test(inner) || UNTRUSTED_OPEN_TAG_VARIANT.test(inner);
|
|
69
|
+
UNTRUSTED_CLOSE_TAG_VARIANT.lastIndex = 0; // reset stateful /g regexes
|
|
70
|
+
UNTRUSTED_OPEN_TAG_VARIANT.lastIndex = 0;
|
|
71
|
+
if (!hasVariant) {
|
|
72
|
+
return text;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return `${open}${escapeTagSentinels(text)}${close}`;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Strip one `<untrusted-content>` envelope from `text` if present, returning raw
|
|
79
|
+
* strings unchanged. This is intentionally one-layer and idempotent for already
|
|
80
|
+
* raw input so callers can accept either displayed wrapped content or manually
|
|
81
|
+
* authored content.
|
|
82
|
+
*/
|
|
83
|
+
export function unwrapUntrusted(text) {
|
|
84
|
+
const match = UNTRUSTED_ENVELOPE.exec(text);
|
|
85
|
+
if (!match)
|
|
86
|
+
return text;
|
|
87
|
+
return unescapeTagSentinels(match[1]);
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Recursively wrap every string key and value reachable inside `value` (strings,
|
|
91
|
+
* arrays, plain-object property keys and values) in an `<untrusted-content>` envelope.
|
|
92
|
+
*
|
|
93
|
+
* Use this when a whole response blob is third-party data and you want to
|
|
94
|
+
* envelope it wholesale rather than enumerate fields. Non-string leaves (numbers,
|
|
95
|
+
* booleans, null) pass through unchanged.
|
|
96
|
+
*/
|
|
97
|
+
export function wrapUntrustedJsonStrings(value, source) {
|
|
98
|
+
if (typeof value === 'string') {
|
|
99
|
+
return wrapUntrusted(value, source);
|
|
100
|
+
}
|
|
101
|
+
if (Array.isArray(value)) {
|
|
102
|
+
return value.map((item) => wrapUntrustedJsonStrings(item, source));
|
|
103
|
+
}
|
|
104
|
+
if (value && typeof value === 'object') {
|
|
105
|
+
return Object.fromEntries(Object.entries(value).map(([key, item]) => [
|
|
106
|
+
wrapUntrusted(key, source) ?? key,
|
|
107
|
+
wrapUntrustedJsonStrings(item, source),
|
|
108
|
+
]));
|
|
109
|
+
}
|
|
110
|
+
return value;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Recursively unwrap every string key and value reachable inside `value`.
|
|
114
|
+
* Non-string leaves pass through unchanged.
|
|
115
|
+
*/
|
|
116
|
+
export function unwrapUntrustedJsonStrings(value) {
|
|
117
|
+
if (typeof value === 'string') {
|
|
118
|
+
return unwrapUntrusted(value);
|
|
119
|
+
}
|
|
120
|
+
if (Array.isArray(value)) {
|
|
121
|
+
return value.map((item) => unwrapUntrustedJsonStrings(item));
|
|
122
|
+
}
|
|
123
|
+
if (value && typeof value === 'object') {
|
|
124
|
+
return Object.fromEntries(Object.entries(value).map(([key, item]) => [
|
|
125
|
+
unwrapUntrusted(key),
|
|
126
|
+
unwrapUntrustedJsonStrings(item),
|
|
127
|
+
]));
|
|
128
|
+
}
|
|
129
|
+
return value;
|
|
130
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mindstone/mcp-server-xero",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"mcpName": "io.github.mindstone/mcp-server-xero",
|
|
5
5
|
"description": "Xero MCP server for invoices, contacts, payments, quotes, and financial reports",
|
|
6
6
|
"license": "MIT",
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"directory": "connectors/xero"
|
|
12
12
|
},
|
|
13
13
|
"homepage": "https://github.com/mindstone/mcp-servers/tree/main/connectors/xero",
|
|
14
|
-
"author": "
|
|
14
|
+
"author": "Mindstone <support@mindstone.ai>",
|
|
15
15
|
"type": "module",
|
|
16
16
|
"bin": {
|
|
17
17
|
"mcp-server-xero": "dist/index.js"
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export function ensureError(value) {
|
|
2
|
-
if (value instanceof Error)
|
|
3
|
-
return value;
|
|
4
|
-
let stringified = "[Unable to stringify the thrown value]";
|
|
5
|
-
try {
|
|
6
|
-
stringified = JSON.stringify(value);
|
|
7
|
-
}
|
|
8
|
-
catch {
|
|
9
|
-
/* empty */
|
|
10
|
-
}
|
|
11
|
-
const error = new Error(`Error thrown: ${stringified}`);
|
|
12
|
-
return error;
|
|
13
|
-
}
|