@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.
Files changed (80) hide show
  1. package/README.md +46 -0
  2. package/dist/clients/xero-client.js +2 -3
  3. package/dist/handlers/create-xero-purchase-order.handler.js +50 -0
  4. package/dist/handlers/email-xero-invoice.handler.js +27 -0
  5. package/dist/handlers/list-xero-bank-summary.handler.js +38 -0
  6. package/dist/handlers/list-xero-budget-summary.handler.js +45 -0
  7. package/dist/handlers/list-xero-executive-summary.handler.js +37 -0
  8. package/dist/handlers/list-xero-purchase-orders.handler.js +29 -0
  9. package/dist/helpers/create-xero-tool.js +32 -1
  10. package/dist/helpers/get-deeplink.js +15 -4
  11. package/dist/helpers/xero-currencies.js +1 -1
  12. package/dist/server/xero-mcp-server.js +2 -1
  13. package/dist/tools/create/create-bank-transaction.tool.js +2 -1
  14. package/dist/tools/create/create-contact.tool.js +4 -3
  15. package/dist/tools/create/create-credit-note.tool.js +1 -0
  16. package/dist/tools/create/create-invoice.tool.js +1 -0
  17. package/dist/tools/create/create-item.tool.js +1 -0
  18. package/dist/tools/create/create-manual-journal.tool.js +4 -3
  19. package/dist/tools/create/create-payment.tool.js +1 -0
  20. package/dist/tools/create/create-payroll-timesheet.tool.js +1 -0
  21. package/dist/tools/create/create-purchase-order.tool.js +67 -0
  22. package/dist/tools/create/create-quote.tool.js +1 -0
  23. package/dist/tools/create/create-tracking-category.tool.js +2 -1
  24. package/dist/tools/create/create-tracking-options.tool.js +2 -1
  25. package/dist/tools/create/index.js +3 -1
  26. package/dist/tools/delete/delete-payroll-timesheet.tool.js +1 -0
  27. package/dist/tools/get/get-invoice-attachment.tool.js +1 -0
  28. package/dist/tools/get/get-payroll-timesheet.tool.js +1 -0
  29. package/dist/tools/history/index.js +2 -0
  30. package/dist/tools/list/index.js +9 -1
  31. package/dist/tools/list/list-accounts.tool.js +1 -0
  32. package/dist/tools/list/list-aged-payables-by-contact.tool.js +1 -0
  33. package/dist/tools/list/list-aged-receivables-by-contact.tool.js +1 -0
  34. package/dist/tools/list/list-bank-summary.tool.js +42 -0
  35. package/dist/tools/list/list-bank-transactions.tool.js +2 -1
  36. package/dist/tools/list/list-budget-summary.tool.js +48 -0
  37. package/dist/tools/list/list-contact-groups.tool.js +1 -0
  38. package/dist/tools/list/list-contacts.tool.js +1 -0
  39. package/dist/tools/list/list-credit-notes.tool.js +1 -0
  40. package/dist/tools/list/list-currencies.tool.js +1 -0
  41. package/dist/tools/list/list-executive-summary.tool.js +37 -0
  42. package/dist/tools/list/list-invoice-attachments.tool.js +1 -0
  43. package/dist/tools/list/list-invoices.tool.js +1 -0
  44. package/dist/tools/list/list-items.tool.js +1 -0
  45. package/dist/tools/list/list-manual-journals.tool.js +1 -0
  46. package/dist/tools/list/list-organisation-details.tool.js +1 -0
  47. package/dist/tools/list/list-payments.tool.js +1 -0
  48. package/dist/tools/list/list-payroll-employee-leave-balances.tool.js +1 -0
  49. package/dist/tools/list/list-payroll-employee-leave-types.tool.js +1 -0
  50. package/dist/tools/list/list-payroll-employee-leave.tool.js +1 -0
  51. package/dist/tools/list/list-payroll-employees.tool.js +1 -0
  52. package/dist/tools/list/list-payroll-leave-periods.tool.js +1 -0
  53. package/dist/tools/list/list-payroll-leave-types.tool.js +1 -0
  54. package/dist/tools/list/list-payroll-timesheets.tool.js +1 -0
  55. package/dist/tools/list/list-profit-and-loss.tool.js +1 -0
  56. package/dist/tools/list/list-purchase-orders.tool.js +98 -0
  57. package/dist/tools/list/list-quotes.tool.js +1 -0
  58. package/dist/tools/list/list-report-balance-sheet.tool.js +1 -0
  59. package/dist/tools/list/list-tax-rates.tool.js +1 -0
  60. package/dist/tools/list/list-tracking-categories.tool.js +2 -1
  61. package/dist/tools/list/list-trial-balance.tool.js +1 -0
  62. package/dist/tools/tool-factory.js +4 -1
  63. package/dist/tools/update/approve-payroll-timesheet.tool.js +1 -0
  64. package/dist/tools/update/email-invoice.tool.js +30 -0
  65. package/dist/tools/update/index.js +3 -1
  66. package/dist/tools/update/revert-payroll-timesheet.tool.js +1 -0
  67. package/dist/tools/update/update-bank-transaction.tool.js +1 -0
  68. package/dist/tools/update/update-contact.tool.js +4 -3
  69. package/dist/tools/update/update-credit-note.tool.js +1 -0
  70. package/dist/tools/update/update-invoice.tool.js +1 -0
  71. package/dist/tools/update/update-item.tool.js +1 -0
  72. package/dist/tools/update/update-manual-journal-tool.js +4 -3
  73. package/dist/tools/update/update-payroll-timesheet-add-line.tool.js +1 -0
  74. package/dist/tools/update/update-payroll-timesheet-update-line.tool.js +1 -0
  75. package/dist/tools/update/update-quote.tool.js +1 -0
  76. package/dist/tools/update/update-tracking-category.tool.js +2 -1
  77. package/dist/tools/update/update-tracking-options.tool.js +2 -1
  78. package/dist/untrusted-content.js +130 -0
  79. package/package.json +2 -2
  80. 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
  ];
@@ -14,6 +14,7 @@ const RevertPayrollTimesheetTool = CreateXeroTool("revert-timesheet", `Revert a
14
14
  text: `Error reverting timesheet: ${response.error}`,
15
15
  },
16
16
  ],
17
+ isError: true,
17
18
  };
18
19
  }
19
20
  const timesheet = response.result;
@@ -30,6 +30,7 @@ const UpdateBankTransactionTool = CreateXeroTool("update-bank-transaction", `Upd
30
30
  text: `Error updating bank transaction: ${result.error}`,
31
31
  },
32
32
  ],
33
+ isError: true,
33
34
  };
34
35
  }
35
36
  const bankTransaction = result.result;
@@ -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 { ensureError } from "../../helpers/ensure-error.js";
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 creating contact: ${err.message}`,
63
+ text: `Error updating contact: ${formatError(error)}`,
64
64
  },
65
65
  ],
66
+ isError: true,
66
67
  };
67
68
  }
68
69
  });
@@ -31,6 +31,7 @@ const UpdateCreditNoteTool = CreateXeroTool("update-credit-note", "Update a cred
31
31
  text: `Error updating credit note: ${result.error}`,
32
32
  },
33
33
  ],
34
+ isError: true,
34
35
  };
35
36
  }
36
37
  const creditNote = result.result;
@@ -47,6 +47,7 @@ const UpdateInvoiceTool = CreateXeroTool("update-invoice", "Update an invoice in
47
47
  text: `Error updating invoice: ${result.error}`,
48
48
  },
49
49
  ],
50
+ isError: true,
50
51
  };
51
52
  }
52
53
  const invoice = result.result;
@@ -40,6 +40,7 @@ const UpdateItemTool = CreateXeroTool("update-item", "Update an item in Xero.",
40
40
  text: `Error updating item: ${result.error}`,
41
41
  },
42
42
  ],
43
+ isError: true,
43
44
  };
44
45
  }
45
46
  const item = result.result;
@@ -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 { ensureError } from "../../helpers/ensure-error.js";
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: ${err.message}`,
83
+ text: `Error updating manual journal: ${formatError(error)}`,
84
84
  },
85
85
  ],
86
+ isError: true,
86
87
  };
87
88
  }
88
89
  });
@@ -19,6 +19,7 @@ const AddTimesheetLineTool = CreateXeroTool("add-timesheet-line", `Add a new tim
19
19
  text: `Error adding timesheet line: ${response.error}`,
20
20
  },
21
21
  ],
22
+ isError: true,
22
23
  };
23
24
  }
24
25
  const newLine = response.result;
@@ -20,6 +20,7 @@ const UpdatePayrollTimesheetLineTool = CreateXeroTool("update-timesheet-line", `
20
20
  text: `Error updating timesheet line: ${response.error}`,
21
21
  },
22
22
  ],
23
+ isError: true,
23
24
  };
24
25
  }
25
26
  const updatedLine = response.result;
@@ -36,6 +36,7 @@ const UpdateQuoteTool = CreateXeroTool("update-quote", "Update a quote in Xero.
36
36
  text: `Error updating quote: ${result.error}`,
37
37
  },
38
38
  ],
39
+ isError: true,
39
40
  };
40
41
  }
41
42
  const quote = result.result;
@@ -14,7 +14,8 @@ const UpdateTrackingCategoryTool = CreateXeroTool("update-tracking-category", `U
14
14
  type: "text",
15
15
  text: `Error while updating tracking category: ${response.error}`
16
16
  }
17
- ]
17
+ ],
18
+ isError: true,
18
19
  };
19
20
  }
20
21
  const trackingCategory = response.result;
@@ -19,7 +19,8 @@ const UpdateTrackingOptionsTool = CreateXeroTool("update-tracking-options", `Upd
19
19
  type: "text",
20
20
  text: `Error while creating tracking options: ${response.error}`
21
21
  }
22
- ]
22
+ ],
23
+ isError: true,
23
24
  };
24
25
  }
25
26
  const trackingOptions = response.result;
@@ -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('&', '&amp;').replaceAll('"', '&quot;').replaceAll('<', '&lt;').replaceAll('>', '&gt;');
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.0.17",
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": "Xero (https://xero.com)",
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
- }