@teamnetwork-nz/xero-mcp-server 1.15.1 → 1.15.2

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 CHANGED
@@ -156,8 +156,8 @@ Date inputs to the Xero API (invoice dates, fromDate, toDate, etc.) are `YYYY-MM
156
156
  ### Invoices
157
157
  | Tool | Description |
158
158
  |---|---|
159
- | `list-invoices` | List invoices with optional filters: status, contact, invoice number, date range |
160
- | `xero_search_transactions` | Structured search by invoice number, reference, supplier/contact, date, amount, status and type |
159
+ | `list-invoices` | List invoices and filter direction with `type=ACCREC` (AR sales invoices) or `type=ACCPAY` (AP purchase bills) |
160
+ | `xero_search_transactions` | Structured invoice/bill search; set `type=ACCREC` for AR or `type=ACCPAY` for AP, because contact filters do not infer direction |
161
161
  | `xero_batch_invoice_lookup` | Native exact lookup for up to 100 invoice numbers with per-input duplicate/unmatched results |
162
162
  | `xero_lookup_invoice` | Scalar exact invoice-number lookup for clients affected by Hermes array coercion |
163
163
  | `get-invoice` | Get full details of a single invoice including all line items |
@@ -186,8 +186,8 @@ Date inputs to the Xero API (invoice dates, fromDate, toDate, etc.) are `YYYY-MM
186
186
  ### Contacts
187
187
  | Tool | Description |
188
188
  |---|---|
189
- | `list-contacts` | List contacts with optional search term |
190
- | `xero_find_contact` | Resolve a contact by ID, name, contact/account number, email or tax number without silently choosing ambiguous matches |
189
+ | `list-contacts` | List contacts; `contactRole=customer` filters AR customers and `contactRole=supplier` filters AP suppliers; omit it to include unclassified contacts |
190
+ | `xero_find_contact` | Resolve a contact without silently choosing ambiguous matches; `role` is optional because contacts may be customer, supplier, both, or `Unknown` |
191
191
  | `create-contact` | Create a new contact |
192
192
  | `update-contact` | Update an existing contact |
193
193
  | `archive-contact` | Archive a contact (Xero does not support hard deletion) |
@@ -260,6 +260,24 @@ Attachment filenames are non-authoritative and may contain amounts that differ f
260
260
  bill's gross total. Use Xero invoice `SubTotal`, `TotalTax`, and `Total` fields for financial
261
261
  reconciliation, and retrieve binary attachment content only when explicitly needed.
262
262
 
263
+ ### AP and AR filtering
264
+
265
+ Invoice direction is explicit. `ACCREC` means Accounts Receivable sales invoices (money owed
266
+ to you by customers); `ACCPAY` means Accounts Payable purchase bills (money you owe suppliers).
267
+ Use the `type` filter on `list-invoices`, `xero_search_transactions`, and exact invoice lookup
268
+ tools whenever direction matters. Omitting `type` searches both. A `supplier` or `contactId`
269
+ filter identifies the contact on the transaction but does not automatically select `ACCPAY`.
270
+
271
+ Contact role is related but separate. `customer` means Xero's `IsCustomer` flag is true and
272
+ `supplier` means `IsSupplier` is true. A contact can be a customer, supplier, both, or neither
273
+ (`Type: Unknown`). Omit `role`/`contactRole` when unclassified contacts must remain searchable.
274
+ These role filters do not filter invoice direction; combine contact resolution with an explicit
275
+ invoice `type` for an AP- or AR-specific workflow.
276
+
277
+ `xero_search_transactions` searches invoices and bills. Bank transactions are a separate Xero
278
+ resource accessed with `list-bank-transactions`, using `RECEIVE` and `SPEND` transaction types
279
+ rather than `ACCREC` and `ACCPAY`.
280
+
263
281
  ### Payroll *(requires `XERO_ENABLE_PAYROLL=true`)*
264
282
  | Tool | Description |
265
283
  |---|---|
@@ -18,7 +18,9 @@ export function filterContactMatches(contacts, params) {
18
18
  (!params.email || matches(contact.emailAddress, params.email, exact)) &&
19
19
  (!params.taxNumber || matches(contact.taxNumber, params.taxNumber, exact)));
20
20
  }
21
- function compactContact(contact) {
21
+ export function compactContact(contact) {
22
+ const isCustomer = contact.isCustomer ?? false;
23
+ const isSupplier = contact.isSupplier ?? false;
22
24
  return {
23
25
  contactId: contact.contactID ?? "",
24
26
  name: contact.name ?? null,
@@ -27,8 +29,15 @@ function compactContact(contact) {
27
29
  email: contact.emailAddress ?? null,
28
30
  taxNumber: contact.taxNumber ?? null,
29
31
  status: contact.contactStatus ? String(contact.contactStatus) : null,
30
- isCustomer: contact.isCustomer ?? false,
31
- isSupplier: contact.isSupplier ?? false,
32
+ isCustomer,
33
+ isSupplier,
34
+ type: isCustomer && isSupplier
35
+ ? "Customer, Supplier"
36
+ : isCustomer
37
+ ? "Customer"
38
+ : isSupplier
39
+ ? "Supplier"
40
+ : "Unknown",
32
41
  };
33
42
  }
34
43
  export async function findXeroContact(params) {
@@ -48,7 +57,7 @@ export async function findXeroContact(params) {
48
57
  const filtered = filterContactMatches(raw, params);
49
58
  const truncated = raw.length > params.pageSize || filtered.length > params.pageSize;
50
59
  const matchesFound = filtered.slice(0, params.pageSize).map(compactContact);
51
- return successfulLookup(matchesFound, params.matchMode === "exact", {
60
+ const result = successfulLookup(matchesFound, params.matchMode === "exact", {
52
61
  page: params.page,
53
62
  pageSize: params.pageSize,
54
63
  returned: matchesFound.length,
@@ -56,8 +65,20 @@ export async function findXeroContact(params) {
56
65
  nextPage: truncated ? params.page + 1 : null,
57
66
  complete: !truncated,
58
67
  });
68
+ const notFound = result.matchStatus === "NOT_FOUND";
69
+ return {
70
+ ...result,
71
+ notFoundReason: notFound ? "NO_IDENTIFIER_MATCH" : null,
72
+ hint: notFound
73
+ ? "No contact matched the supplied identifier(s). This does not prove the contact does not exist: the searched field may be blank or stored differently in Xero. Try a known name with matchMode=contains and omit role to search all contact types."
74
+ : null,
75
+ };
59
76
  }
60
77
  catch (error) {
61
- return failedLookup(formatError(error));
78
+ return {
79
+ ...failedLookup(formatError(error)),
80
+ notFoundReason: null,
81
+ hint: null,
82
+ };
62
83
  }
63
84
  }
@@ -4,6 +4,6 @@ import { CreateXeroTool } from "../../helpers/create-xero-tool.js";
4
4
  import { jsonToolResponse } from "../../types/lookup-result.js";
5
5
  const BatchInvoiceLookupTool = CreateXeroTool("xero_batch_invoice_lookup", "Look up multiple exact Xero InvoiceNumber values in one batch request. Accepts an array of strings, preserves numeric-looking invoice numbers as strings, and reports exact matches, duplicates, and unmatched values for each input.", {
6
6
  invoiceNumbers: z.array(z.string().min(1)).min(1).max(100),
7
- type: z.enum(["ACCREC", "ACCPAY"]).optional(),
7
+ type: z.enum(["ACCREC", "ACCPAY"]).optional().describe("ACCREC = AR sales/customer invoices; ACCPAY = AP purchase/supplier bills. Omit to search both."),
8
8
  }, async ({ invoiceNumbers, type }) => jsonToolResponse(await batchXeroInvoiceLookup(invoiceNumbers, type)));
9
9
  export default BatchInvoiceLookupTool;
@@ -3,15 +3,15 @@ import { findXeroContact } from "../../handlers/find-xero-contact.handler.js";
3
3
  import { CreateXeroTool } from "../../helpers/create-xero-tool.js";
4
4
  import { failedLookup, jsonToolResponse } from "../../types/lookup-result.js";
5
5
  import { STRUCTURED_PAGE_GUIDANCE } from "../../helpers/pagination-guidance.js";
6
- const FindContactTool = CreateXeroTool("xero_find_contact", "Resolve a Xero customer or supplier using supported identifiers. Ambiguous matches are returned explicitly and never selected automatically.", {
6
+ const FindContactTool = CreateXeroTool("xero_find_contact", "Resolve a Xero contact using one or more supported identifiers. role is optional: role=customer filters IsCustomer=true for AR workflows; role=supplier filters IsSupplier=true for AP workflows. These are contact classifications, not invoice-direction filters: a contact may be a customer, supplier, both, or Type: Unknown. Omit role to search every classification, including Unknown. Name matching is case-insensitive: use matchMode=contains when you have a partial name (for example, 'Servers Australia' can match 'Servers Australia Pty Ltd'), or exact when you require the complete name. Ambiguous matches are returned explicitly and never selected automatically. NOT_FOUND means no contact matched the supplied identifier(s), not that the contact cannot exist; the searched field may be blank in Xero.", {
7
7
  contactId: z.string().uuid().optional(),
8
- name: z.string().min(1).optional(),
8
+ name: z.string().min(1).optional().describe("Contact name. Matching is case-insensitive; use matchMode=contains for a partial name."),
9
9
  contactNumber: z.string().min(1).optional(),
10
10
  accountNumber: z.string().min(1).optional(),
11
11
  email: z.string().email().optional(),
12
12
  taxNumber: z.string().min(1).optional().describe("GST/VAT/ABN/NZBN tax identifier as stored by Xero."),
13
- role: z.enum(["customer", "supplier"]).optional(),
14
- matchMode: z.enum(["exact", "contains"]).default("exact"),
13
+ role: z.enum(["customer", "supplier"]).optional().describe("Contact classification: customer = IsCustomer=true (AR), supplier = IsSupplier=true (AP). Contacts may be both or neither. This does not filter invoice direction. Omit to include Type: Unknown."),
14
+ matchMode: z.enum(["exact", "contains"]).default("exact").describe("Case-insensitive matching mode. Use contains for a partial name; exact requires the complete field value."),
15
15
  page: z.number().int().min(1).default(1).describe(`Page number for paginated matches. ${STRUCTURED_PAGE_GUIDANCE}`),
16
16
  pageSize: z.number().int().min(1).max(50).default(10).describe(`Maximum matches returned on this page (1-50, default 10). ${STRUCTURED_PAGE_GUIDANCE}`),
17
17
  }, async (params) => {
@@ -5,18 +5,18 @@ import { z } from "zod";
5
5
  import { formatUtcDatetime } from "../../helpers/datetime.js";
6
6
  const ListContactsTool = CreateXeroTool("list-contacts", "List contacts from Xero. " +
7
7
  "Use searchTerm for name/email lookup — do NOT list all contacts and scan them. " +
8
- "Use contactRole to restrict to customers (AR workflows) or suppliers (AP workflows). " +
8
+ "Use contactRole to restrict to customers (IsCustomer=true, AR workflows) or suppliers (IsSupplier=true, AP workflows). This is a contact classification, not an invoice-direction filter; contacts may be customer, supplier, both, or neither. Omit contactRole to include Type: Unknown. " +
9
9
  "Common patterns: " +
10
10
  "find a customer by name → searchTerm=<name>, contactRole=customer; " +
11
11
  "all active suppliers → contactRole=supplier, status=ACTIVE; " +
12
12
  "recently updated contacts → fromDate=<date>. " +
13
13
  "Each contact in the response includes: name, contactID, firstName, lastName, emailAddress, " +
14
- "accountNumber (user-defined), taxNumber (NZBN/ABN/VAT), isCustomer/isSupplier flags, " +
14
+ "accountNumber (user-defined), taxNumber (NZBN/ABN/VAT), and Type derived from the isCustomer/isSupplier flags (Customer, Supplier, both, or Unknown). Type: Unknown means the contact is not classified as either role, not that it does not exist. " +
15
15
  "phones (type + number, short form), addresses (type + line1/city/region/postcode/country, short form), " +
16
16
  "AR/AP tax types, defaultCurrency, contactStatus, contactGroups, and lastUpdated.", {
17
17
  page: z.number().optional().describe(`Page number for pagination (starts at 1). ${PAGE_NUMBER_GUIDANCE}`),
18
18
  searchTerm: z.string().optional().describe("Case-insensitive search across Name, FirstName, LastName, ContactNumber, EmailAddress. Use this instead of listing all contacts."),
19
- contactRole: z.enum(["customer", "supplier"]).optional().describe("Filter to customers only (IsCustomer==true) or suppliers only (IsSupplier==true). Use customer for AR work, supplier for AP work."),
19
+ contactRole: z.enum(["customer", "supplier"]).optional().describe("Contact classification filter: customer = IsCustomer==true (AR), supplier = IsSupplier==true (AP). Contacts can be both or neither. This does not filter invoices; omit it to include Type: Unknown."),
20
20
  fromDate: z.string().optional().describe("Return contacts updated on or after this date (YYYY-MM-DD)."),
21
21
  toDate: z.string().optional().describe("Return contacts updated on or before this date (YYYY-MM-DD)."),
22
22
  status: z.enum(["ACTIVE", "ARCHIVED"]).optional().describe("Filter by contact status. Defaults to ACTIVE (excludes archived contacts). Pass ARCHIVED only if you specifically need deactivated contacts."),
@@ -4,6 +4,6 @@ import { CreateXeroTool } from "../../helpers/create-xero-tool.js";
4
4
  import { jsonToolResponse } from "../../types/lookup-result.js";
5
5
  const LookupInvoiceTool = CreateXeroTool("xero_lookup_invoice", "Look up one Xero invoice or purchase bill by its exact InvoiceNumber value and report exact, duplicate, or unmatched results.", {
6
6
  invoiceNumber: z.string().min(1),
7
- type: z.enum(["ACCREC", "ACCPAY"]).optional(),
7
+ type: z.enum(["ACCREC", "ACCPAY"]).optional().describe("ACCREC = AR sales/customer invoices; ACCPAY = AP purchase/supplier bills. Omit to search both."),
8
8
  }, async ({ invoiceNumber, type }) => jsonToolResponse(await batchXeroInvoiceLookup([invoiceNumber], type)));
9
9
  export default LookupInvoiceTool;
@@ -3,18 +3,18 @@ import { searchXeroTransactions } from "../../handlers/search-xero-transactions.
3
3
  import { CreateXeroTool } from "../../helpers/create-xero-tool.js";
4
4
  import { jsonToolResponse } from "../../types/lookup-result.js";
5
5
  import { STRUCTURED_PAGE_GUIDANCE } from "../../helpers/pagination-guidance.js";
6
- const SearchTransactionsTool = CreateXeroTool("xero_search_transactions", "Search Xero sales invoices and purchase bills by invoice number, reference, contact, date, amount, status, or type. Uses Xero server-side filters where available, verifies the requested match mode, and returns compact match, ambiguity, pagination, and error metadata.", {
6
+ const SearchTransactionsTool = CreateXeroTool("xero_search_transactions", "Search Xero sales invoices and purchase bills by invoice number, reference, contact, date, amount, status, or type. Set type=ACCREC for Accounts Receivable sales invoices (money owed to you) or type=ACCPAY for Accounts Payable purchase bills (money you owe); omitting type searches both. The supplier and contactId filters identify the contact but do not imply ACCPAY or ACCREC, so set type whenever direction matters. This tool searches invoices/bills, not bank transactions. Uses Xero server-side filters where available, verifies the requested match mode, and returns compact match, ambiguity, pagination, and error metadata.", {
7
7
  invoiceNumber: z.string().min(1).optional(),
8
8
  reference: z.string().min(1).optional(),
9
- contactId: z.string().uuid().optional(),
10
- supplier: z.string().min(1).optional().describe("Contact/supplier name."),
9
+ contactId: z.string().uuid().optional().describe("Contact on the invoice or bill. Does not imply ACCREC or ACCPAY; set type separately."),
10
+ supplier: z.string().min(1).optional().describe("Contact name on an invoice or bill. Despite the parameter name, this can match either AR or AP and does not imply ACCPAY; set type separately."),
11
11
  fromDate: z.string().regex(/^\d{4}-\d{2}-\d{2}$/).optional(),
12
12
  toDate: z.string().regex(/^\d{4}-\d{2}-\d{2}$/).optional(),
13
13
  amount: z.number().nonnegative().optional().describe("Exact invoice total."),
14
14
  minAmount: z.number().nonnegative().optional(),
15
15
  maxAmount: z.number().nonnegative().optional(),
16
16
  statuses: z.array(z.enum(["DRAFT", "SUBMITTED", "AUTHORISED", "PAID", "VOIDED", "DELETED"])).min(1).optional(),
17
- type: z.enum(["ACCREC", "ACCPAY"]).optional(),
17
+ type: z.enum(["ACCREC", "ACCPAY"]).optional().describe("ACCREC = AR sales/customer invoices; ACCPAY = AP purchase/supplier bills. Omit only when both directions are wanted."),
18
18
  matchMode: z.enum(["exact", "contains", "candidate"]).default("exact"),
19
19
  page: z.number().int().min(1).default(1).describe(`Page number for paginated matches. ${STRUCTURED_PAGE_GUIDANCE}`),
20
20
  pageSize: z.number().int().min(1).max(100).default(25).describe(`Maximum matches returned on this page (1-100, default 25). ${STRUCTURED_PAGE_GUIDANCE}`),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@teamnetwork-nz/xero-mcp-server",
3
- "version": "1.15.1",
3
+ "version": "1.15.2",
4
4
  "description": "MCP server implementation for Xero integration - TEAMnetwork",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",