@teamnetwork-nz/xero-mcp-server 1.16.1 → 1.17.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/README.md CHANGED
@@ -1,434 +1,481 @@
1
- # TEAMnetwork Xero MCP Server
2
-
3
- Tools accept optional `outputFormat: "json"` to return valid JSON text. The option is removed locally and is never sent to the Xero API.
4
-
5
- ## Streamable HTTP
6
-
7
- Set `XERO_TRANSPORT=http` to serve stateless MCP at `/mcp`. It binds to `127.0.0.1` by default; remote binding requires `XERO_HTTP_BEARER_TOKEN` and `XERO_HTTP_ALLOWED_HOSTS`. Optional controls include `XERO_HTTP_PORT`, `XERO_HTTP_ALLOWED_ORIGINS`, and `XERO_HTTP_MAX_BODY_BYTES`. A health endpoint is available at `/health`.
8
-
9
- A [Model Context Protocol (MCP)](https://modelcontextprotocol.io/) server for Xero, maintained by [TEAMnetwork](https://teamnetwork.co.nz). Forked and extended from the [official Xero MCP Server](https://github.com/XeroAPI/xero-mcp-server).
10
-
11
- Provides AI agents and MCP-compatible clients (e.g. Claude Desktop) with tools to read and write Xero accounting data, manage invoice attachments, and download invoice PDFs.
12
-
13
- ## Features
14
-
15
- - **Invoices** - create, list, structured search, native batch lookup, settlement/history inspection, update, authorise, void, get full detail, download as PDF
16
- - **Contacts** - create, list, identifier-based resolution, update, archive
17
- - **Quotes** — create, list, update, convert to invoice
18
- - **Payments & Credit Notes** — create, list, update
19
- - **Bank Transactions & Manual Journals** — create, list, update
20
- - **Accounts, Items, Tax Rates, Tracking** — list, create, update
21
- - **Financial Reports** — Trial Balance, Profit & Loss, Balance Sheet, Aged Payables/Receivables
22
- - **Invoice Attachments** — list, upload (e.g. Crystal Reports PDFs), download, delete
23
- - **Payroll** — employees, leave, timesheets *(optional, off by default)*
24
- - **Modular scopes** — only request the Xero API permissions your use case needs
25
-
26
- ## Prerequisites
27
-
28
- - Node.js v18 or higher
29
- - A Xero developer account with API credentials
30
-
31
- ## Docs and Links
32
-
33
- - [Xero Public API Documentation](https://developer.xero.com/documentation/api/)
34
- - [Xero API Explorer](https://api-explorer.xero.com/)
35
- - [Xero-Node SDK Docs](https://xeroapi.github.io/xero-node/accounting)
36
- - [MCP Protocol Specification](https://modelcontextprotocol.io/)
37
-
38
- ---
39
-
40
- ## Setup
41
-
42
- ### 1. Create a Xero Developer App
43
-
44
- Set up a **Custom Connection** following Xero's guide:
45
- https://developer.xero.com/documentation/guides/oauth2/custom-connections/
46
-
47
- When configuring scopes in your Xero app, include the scopes for the feature groups you plan to use (see [Feature Groups](#feature-groups) below). At minimum you need:
48
-
49
- ```
50
- accounting.transactions
51
- accounting.contacts
52
- accounting.settings
53
- accounting.attachments
54
- accounting.journals.read
55
- ```
56
-
57
- ### 2. Authentication
58
-
59
- There are two authentication modes:
60
-
61
- #### Custom Connections (recommended)
62
-
63
- Uses a Client ID and Secret tied to a specific Xero organisation. Best for Claude Desktop and single-org setups.
64
-
65
- ```json
66
- {
67
- "mcpServers": {
68
- "xero": {
69
- "command": "npx",
70
- "args": ["-y", "tn-xero-mcp-server@latest"],
71
- "env": {
72
- "XERO_CLIENT_ID": "your_client_id_here",
73
- "XERO_CLIENT_SECRET": "your_client_secret_here"
74
- }
75
- }
76
- }
77
- }
78
- ```
79
-
80
- #### Bearer Token
81
-
82
- Use when your MCP client handles the OAuth flow (e.g. PKCE). The bearer token takes precedence over Client ID/Secret if both are set.
83
-
84
- ```json
85
- {
86
- "mcpServers": {
87
- "xero": {
88
- "command": "npx",
89
- "args": ["-y", "tn-xero-mcp-server@latest"],
90
- "env": {
91
- "XERO_CLIENT_BEARER_TOKEN": "your_bearer_token"
92
- }
93
- }
94
- }
95
- }
96
- ```
97
-
98
- When obtaining a bearer token, request the scopes matching your enabled feature groups. See [Feature Groups](#feature-groups) for the full scope list.
99
-
100
- ---
101
-
102
- ## Feature Groups
103
-
104
- Scopes and tools are controlled by environment variables. This means you only provision the Xero API permissions your setup actually needs.
105
-
106
- | Variable | Default | Scopes requested | Tools enabled |
107
- |---|---|---|---|
108
- | *(core — always on)* | — | `accounting.transactions` `accounting.contacts` `accounting.settings` `accounting.attachments` `accounting.journals.read` | All invoicing, contact, payment, attachment, PDF & journal tools |
109
- | `XERO_ENABLE_REPORTS` | `true` | `accounting.reports.read` | Trial Balance, P&L, Balance Sheet, Aged Payables/Receivables |
110
- | `XERO_ENABLE_PAYROLL` | `false` | `payroll.settings` `payroll.employees` `payroll.timesheets` | All payroll tools |
111
- | `XERO_READWRITE` | `false` | No additional scopes | Create, update, and delete tools |
112
-
113
- > **Note:** To use payroll tools, your Xero region must be **NZ** or **UK**, and your Xero app must have the payroll scopes provisioned.
114
-
115
- `XERO_ENABLE_READWRITE=true` remains a deprecated compatibility alias for one release. `XERO_READWRITE` takes precedence when both are set.
116
-
117
- ### Full configuration example
118
-
119
- ```json
120
- {
121
- "mcpServers": {
122
- "xero": {
123
- "command": "npx",
124
- "args": ["-y", "tn-xero-mcp-server@latest"],
125
- "env": {
126
- "XERO_CLIENT_ID": "your_client_id_here",
127
- "XERO_CLIENT_SECRET": "your_client_secret_here",
128
- "XERO_ENABLE_REPORTS": "true",
129
- "XERO_ENABLE_PAYROLL": "false",
130
- "XERO_READWRITE": "false",
131
- "XERO_DOWNLOAD_PATH": "C:/Users/you/Downloads/Xero"
132
- }
133
- }
134
- }
135
- }
136
- ```
137
-
138
- ### `XERO_DOWNLOAD_PATH`
139
-
140
- The local directory where downloaded invoice PDFs and attachments are saved.
141
- Defaults to `~/Downloads` if not set.
142
-
143
- ### `DATETIMEFORMAT`
144
-
145
- Controls which timezone is used when computing "today" defaults and displaying UTC timestamps from the API.
146
-
147
- | Value | Behaviour |
148
- |---|---|
149
- | unset or `local` *(default)* | Use the system's local timezone (`Intl.DateTimeFormat` auto-detection) |
150
- | IANA name e.g. `Pacific/Auckland` | Use this explicit timezone |
151
-
152
- Date inputs to the Xero API (invoice dates, fromDate, toDate, etc.) are `YYYY-MM-DD` strings interpreted by Xero in the organisation's own timezone — no conversion is applied to those. The `DATETIMEFORMAT` setting affects "today" defaults and the display of UTC timestamps returned by the API (e.g. `UpdatedDateUTC`).
153
-
154
- ---
155
-
156
- ## Available Tools
157
-
158
- ### Invoices
159
- | Tool | Description |
160
- |---|---|
161
- | `list-invoices` | List invoices and filter direction with `type=ACCREC` (AR sales invoices) or `type=ACCPAY` (AP purchase bills) |
162
- | `xero_search_transactions` | Structured invoice/bill search; set `type=ACCREC` for AR or `type=ACCPAY` for AP, because contact filters do not infer direction |
163
- | `xero_batch_invoice_lookup` | Native exact lookup for up to 100 invoice numbers with per-input duplicate/unmatched results |
164
- | `xero_lookup_invoice` | Scalar exact invoice-number lookup for clients affected by Hermes array coercion |
165
- | `get-invoice` | Get full details of a single invoice including all line items |
166
- | `xero_get_bill_settlement` | Trace payments, credits, prepayments, overpayments and the outstanding balance |
167
- | `xero_get_invoice_history` | Retrieve Xero-recorded invoice/bill history events (not a complete field-level audit trail) |
168
- | `create-invoice` | Create a new draft invoice (AR or AP) |
169
- | `update-invoice` | Update a draft invoice |
170
- | `authorise-invoice` | Promote a DRAFT or SUBMITTED invoice to AUTHORISED |
171
- | `void-invoice` | Void an AUTHORISED invoice, or delete a DRAFT invoice |
172
- | `get-invoice-pdf` | Download the Xero-generated invoice PDF to local disk |
173
- | `list-invoice-attachments` | List all file attachments on an invoice |
174
- | `xero_list_bill_attachments` | Return compact structured attachment metadata without binary content |
175
- | `upload-invoice-attachment` | Upload a local file (e.g. Crystal Reports PDF) as an invoice attachment |
176
- | `get-invoice-attachment` | Download an invoice attachment to local disk |
177
- | `xero_get_bill_attachment` | Explicit metadata-verified attachment download with a configurable size limit |
178
- | `delete-invoice-attachment` | Delete an attachment from an invoice |
179
-
180
- ### Quotes
181
- | Tool | Description |
182
- |---|---|
183
- | `list-quotes` | List quotes |
184
- | `create-quote` | Create a new quote |
185
- | `update-quote` | Update an existing quote |
186
- | `convert-quote-to-invoice` | Convert a quote into a draft invoice, copying all line items |
187
-
188
- ### Contacts
189
- | Tool | Description |
190
- |---|---|
191
- | `list-contacts` | List contacts; `contactRole=customer` filters AR customers and `contactRole=supplier` filters AP suppliers; omit it to include unclassified contacts |
192
- | `xero_find_contact` | Resolve a contact without silently choosing ambiguous matches; `role` is optional because contacts may be customer, supplier, both, or `Unknown` |
193
- | `create-contact` | Create a new contact |
194
- | `update-contact` | Update an existing contact |
195
- | `archive-contact` | Archive a contact (Xero does not support hard deletion) |
196
- | `list-contact-groups` | List contact groups |
197
-
198
- ### Payments & Credit Notes
199
- | Tool | Description |
200
- |---|---|
201
- | `list-payments` | List payments |
202
- | `create-payment` | Record a payment against an invoice |
203
- | `list-overpayments` | List overpayments (not returned by `list-payments`) |
204
- | `list-prepayments` | List prepayments (not returned by `list-payments`) |
205
- | `list-credit-notes` | List credit notes |
206
- | `create-credit-note` | Create a credit note |
207
- | `update-credit-note` | Update a draft credit note |
208
-
209
- ### Bank & Journals
210
- | Tool | Description |
211
- |---|---|
212
- | `list-bank-transactions` | List bank transactions |
213
- | `create-bank-transaction` | Create a bank transaction |
214
- | `update-bank-transaction` | Update a bank transaction |
215
- | `list-report-bank-summary` | Opening/closing balance and cash in/out per bank account (Xero's Bank Summary report) |
216
- | `list-manual-journals` | List manual journals |
217
- | `create-manual-journal` | Create a manual journal |
218
- | `update-manual-journal` | Update a manual journal |
219
- | `list-journals` | List the underlying GL posting stream (double-entry journal lines per account) |
220
-
221
- ### Settings & Configuration
222
- | Tool | Description |
223
- |---|---|
224
- | `list-accounts` | List chart of accounts |
225
- | `list-tax-rates` | List tax rates |
226
- | `list-items` | List inventory items |
227
- | `create-item` | Create an inventory item |
228
- | `update-item` | Update an inventory item |
229
- | `list-tracking-categories` | List tracking categories and options |
230
- | `create-tracking-category` | Create a tracking category |
231
- | `update-tracking-category` | Update a tracking category |
232
- | `update-tracking-options` | Update tracking options |
233
- | `create-tracking-option` | Create a tracking option |
234
- | `list-organisation-details` | Get organisation details |
235
-
236
- ### Financial Reports *(requires `XERO_ENABLE_REPORTS=true`)*
237
- | Tool | Description |
238
- |---|---|
239
- | `list-trial-balance` | Trial balance report |
240
- | `list-profit-and-loss` | Profit and loss report |
241
- | `list-report-balance-sheet` | Balance sheet report |
242
- | `list-aged-receivables-by-contact` | Aged receivables for a contact |
243
- | `list-aged-payables-by-contact` | Aged payables for a contact |
244
-
245
- `list-profit-and-loss` enforces a single-calendar-month base range and returns
246
- comparison-column metadata containing each label, MCP-derived date window, MTD flag,
247
- `source: MCP_DERIVED`, and `verifiedCallShape: true`. Multi-month base ranges are rejected
248
- because Xero can return misleading rolling totals. Comparison calls with `periods>=1` also
249
- require the current calendar month as the base; completed-month comparisons are rejected.
250
- For N completed monthly columns, request the current month with `periods=N` and ignore
251
- the first MTD column, or make N separate calls with `periods=0`.
252
-
253
- ### Pagination
254
-
255
- For tools with `page` and `pageSize`, `Found N` is the count for the current page, not a
256
- total. To retrieve the complete filtered result set, increment `page` until a page contains
257
- fewer records than `pageSize`. `xero_search_transactions` and `xero_find_contact` expose
258
- `pagination.complete`, `pagination.truncated`, and `pagination.nextPage` instead. Xero does
259
- not expose a configurable page size for `list-quotes`; continue until it returns an empty page.
260
-
261
- Attachment filenames are non-authoritative and may contain amounts that differ from the
262
- bill's gross total. Use Xero invoice `SubTotal`, `TotalTax`, and `Total` fields for financial
263
- reconciliation, and retrieve binary attachment content only when explicitly needed.
264
-
265
- ### AP and AR filtering
266
-
267
- Invoice direction is explicit. `ACCREC` means Accounts Receivable sales invoices (money owed
268
- to you by customers); `ACCPAY` means Accounts Payable purchase bills (money you owe suppliers).
269
- Use the `type` filter on `list-invoices`, `xero_search_transactions`, and exact invoice lookup
270
- tools whenever direction matters. Omitting `type` searches both. A `supplier` or `contactId`
271
- filter identifies the contact on the transaction but does not automatically select `ACCPAY`.
272
-
273
- Contact role is related but separate. `customer` means Xero's `IsCustomer` flag is true and
274
- `supplier` means `IsSupplier` is true. A contact can be a customer, supplier, both, or neither
275
- (`Type: Unknown`). Omit `role`/`contactRole` when unclassified contacts must remain searchable.
276
- These role filters do not filter invoice direction; combine contact resolution with an explicit
277
- invoice `type` for an AP- or AR-specific workflow.
278
-
279
- `xero_search_transactions` searches invoices and bills. Bank transactions are a separate Xero
280
- resource accessed with `list-bank-transactions`, using `RECEIVE` and `SPEND` transaction types
281
- rather than `ACCREC` and `ACCPAY`.
282
-
283
- ### Payroll *(requires `XERO_ENABLE_PAYROLL=true`)*
284
- | Tool | Description |
285
- |---|---|
286
- | `list-payroll-employees` | List payroll employees |
287
- | `list-payroll-employee-leave` | List an employee's leave records |
288
- | `list-payroll-employee-leave-balances` | List an employee's leave balances |
289
- | `list-payroll-employee-leave-types` | List leave types for an employee |
290
- | `list-payroll-leave-periods` | List leave periods for an employee |
291
- | `list-payroll-leave-types` | List all available leave types |
292
- | `list-timesheets` | List timesheets |
293
- | `create-payroll-timesheet` | Create a timesheet |
294
- | `add-payroll-timesheet-line` | Add a line to a timesheet |
295
- | `update-payroll-timesheet-line` | Update a timesheet line |
296
- | `approve-payroll-timesheet` | Approve a timesheet |
297
- | `revert-payroll-timesheet` | Revert an approved timesheet |
298
- | `delete-timesheet` | Delete a timesheet |
299
- | `get-payroll-timesheet` | Get a timesheet by ID |
300
-
301
- ---
302
-
303
- ## Agent guidance
304
-
305
- The server supplies MCP `instructions` that are automatically delivered to the calling agent at session start. These cover:
306
-
307
- - **Datetime handling** — `YYYY-MM-DD` date inputs, local-timezone "today" defaults, UTC timestamp display
308
- - **Efficiency rules** — filter server-side first; never page through all records to find specific items
309
- - **Xero terminology** — ACCREC/ACCPAY, AUTHORISED, IsReconciled explained
310
- - **Read-only mode** — detecting and communicating when write tools are absent
311
- - **API limitations** — reconciliation, aged reports, rate limits, page size guidance
312
-
313
- For a full query playbook, see the MCP resource `xero://guidance/agent-playbook` (or `AGENTS.md` for local reference).
314
-
315
- ### Structured lookup contracts
316
-
317
- The `xero_*` lookup tools return compact JSON with a consistent `matchStatus`
318
- (`EXACT`, `MULTIPLE`, `CANDIDATES`, `NOT_FOUND`, or `ERROR`), an explicit
319
- `ambiguous` flag, pagination completeness/continuation metadata where relevant,
320
- and structured errors. Xero and external identifiers remain strings; money values
321
- are returned as decimal strings with their currency code.
322
-
323
- For TEAMlink purchase bills, live API verification confirmed that the convention
324
- `<supplier-invoice-number> / <TEAMlink-orderId>` is stored in Xero's
325
- `InvoiceNumber` field (for example `SYNTHETIC-BILL / TEST-REFERENCE`), while `Reference` is empty.
326
- Exact and batch searches therefore use Xero's native `InvoiceNumbers` filter. The
327
- separate `reference` search remains available for records that use that field.
328
-
329
- `xero_batch_invoice_lookup.invoiceNumbers` is a native JSON string array. Numeric-
330
- looking identifiers are intentionally not coerced to numbers. The reported Hermes
331
- `coerce_tool_args` defect is outside this repository and must also be corrected in
332
- the Hermes runtime if that client still rewrites valid JSON arrays before sending
333
- the MCP request. Until then, use scalar `xero_lookup_invoice` for exact single-value
334
- lookups or `xero_search_transactions` for broader matching.
335
-
336
- ## For Developers
337
-
338
- ### Local development setup
339
-
340
- ```bash
341
- git clone https://github.com/your-org/tn-xero-mcp-server.git
342
- cd tn-xero-mcp-server
343
- npm install
344
- cp .env.example .env
345
- # Edit .env with your credentials
346
- npm run build
347
- ```
348
-
349
- ### Linking to Claude Desktop for development
350
-
351
- In your `claude_desktop_config.json`, point directly at the built file:
352
-
353
- ```json
354
- {
355
- "mcpServers": {
356
- "xero": {
357
- "command": "node",
358
- "args": ["C:/path/to\\Xero-MCP\\dist\\index.js"],
359
- "env": {
360
- "XERO_CLIENT_ID": "your_client_id_here",
361
- "XERO_CLIENT_SECRET": "your_client_secret_here",
362
- "XERO_ENABLE_PAYROLL": "false",
363
- "XERO_DOWNLOAD_PATH": "C:\\Users\\you\\Downloads\\Xero"
364
- }
365
- }
366
- }
367
- }
368
- ```
369
-
370
- > **Windows note:** Backslashes in `args` paths must be escaped as `\\`.
371
-
372
- ### Publishing updates
373
-
374
- ```bash
375
- npm run build
376
- npm publish
377
- ```
378
-
379
- ---
380
-
381
- ## License
382
-
383
- MIT
384
-
385
- ## Security
386
-
387
- Do not commit your `.env` file or any credentials to version control. The `.gitignore` excludes `.env` by default.
388
-
389
- <!-- BEGIN MCP configuration reference -->
390
- ## Environment variable reference
391
-
392
- The server automatically loads `.env` from its working directory; environment variables already set by the client take precedence.
393
-
394
- Copy `.env.example` for variable names and safe placeholders. Replace required placeholders privately. Optional variables should be omitted unless needed; an empty value may override a default. Never commit credentials, real identities, device profiles, exports, or logs.
395
-
396
- | Variable | Required | Default | Purpose and accepted values |
397
- |---|---|---|---|
398
- | `DATETIMEFORMAT` | No | `local` | Output date setting: local or an IANA timezone; shared by SSLStore and Xero. |
399
- | `XERO_CLIENT_BEARER_TOKEN` | Alternative | `unset` | Existing access token; use instead of a client ID/secret pair. Renew externally when expired. |
400
- | `XERO_CLIENT_ID` | Alternative | `unset` | Custom Connection client ID; must be set together with XERO_CLIENT_SECRET. |
401
- | `XERO_CLIENT_SECRET` | Alternative | `unset` | Custom Connection client secret; must be set together with XERO_CLIENT_ID. |
402
- | `XERO_DOWNLOAD_PATH` | No | `user Downloads directory` | Download destination; choose a private directory outside source control. |
403
- | `XERO_ENABLE_PAYROLL` | No | `false` | Literal true registers payroll tools; requires appropriate scopes. |
404
- | `XERO_ENABLE_READWRITE` | Deprecated | `unset` | Compatibility alias for XERO_READWRITE; canonical variable wins. |
405
- | `XERO_ENABLE_REPORTS` | No | `true` | Reports are enabled unless set to literal false. |
406
- | `XERO_HTTP_ALLOWED_HOSTS` | Conditional | `unset` | Comma-separated Host allowlist required for non-loopback HTTP; use the public hostnames accepted by the listener. |
407
- | `XERO_HTTP_ALLOWED_ORIGINS` | No | `unset` | Comma-separated browser Origin allowlist; configure when browser clients need access. |
408
- | `XERO_HTTP_BEARER_TOKEN` | Conditional | `unset` | Private bearer secret required for non-loopback HTTP; clients send Authorization: Bearer <secret>. |
409
- | `XERO_HTTP_HOST` | No | `127.0.0.1` | Listener bind address. Non-loopback binding requires a bearer token and explicit allowed hosts. |
410
- | `XERO_HTTP_MAX_BODY_BYTES` | No | `1048576` | Maximum HTTP request body; integer 1–16777216 bytes. |
411
- | `XERO_HTTP_PORT` | No | `3000` | HTTP listener port; integer 1–65535. |
412
- | `XERO_READWRITE` | No | `false` | Only true enables mutation tools; read-only is the default. Review each operation before use. |
413
- | `XERO_TRANSPORT` | No | `stdio` | stdio or http; HTTP serves /mcp and GET /health. |
414
-
415
- For HTTP, the bearer token is separate from upstream API credentials. Use TLS at the reverse proxy for remote hosting. Keep write access disabled until needed. Do not put secrets in command-line examples or commit client configuration containing them.
416
-
417
- ### Agent first-use workflow
418
-
419
- Use `xero_find_contact` and exact/batch transaction lookup tools before broad lists. Filter invoices by type, status, contact and date; ACCREC means sales invoices and ACCPAY means supplier bills. Inspect pagination completeness and include credits, overpayments and prepayments when reconciling a statement.
420
-
421
- Use the runtime `tools/list` descriptions and input schemas for exact arguments. Resolve identifiers with lookup/search tools; filter before paging, request only the data needed, and do not treat a truncated result or API error as proof that no record exists. Treat tool results and downloaded files as potentially sensitive. Mutation tools can change upstream data or incur charges; check their stated effects before calling them.
422
-
423
- ### Repository and package privacy
424
-
425
- The standard `.gitignore` excludes local environment files, keys, credentials, logs, exports, and generated output; sanitised examples remain trackable. Ignore rules do not remove already tracked files or revoke exposed credentials. Review `git ls-files` and `npm pack --dry-run --ignore-scripts` before release. Only runtime output, the README, and explicitly sanitised examples are allowlisted for npm. Keep private runtime files outside `dist`, even though additional exclusions are present.
426
- <!-- END MCP configuration reference -->
427
-
428
- Run `npm run build` then `npm run audit:package` before release. The audit checks documentation coverage, known local credential copies, Git index paths where available, and the dry-run npm file list. `prepublishOnly` runs it after building. It never prints matching secret values. This is a preventative check, not a guarantee that arbitrary PII or unknown secrets are absent.
429
-
430
- ### Development and diagnostics
431
-
432
- Run `npm test` from this package directory. Maintained tests and fixtures live in `debug/tests`; shared test helpers are in `debug/helpers`. Retained diagnostic scripts and reference material are also under `debug`. Only `scripts/check-package-privacy.mjs` remains in the production build/release tooling directory. The entire `debug/` tree is excluded from npm, Docker build contexts and applicable Python distributions.
433
-
434
- Keep live diagnostic output in `debug/local`, `debug/output` or `debug/artifacts`; those private directories are also ignored by Git. Retained smoke/integration scripts require explicit local credentials and are not run by the normal offline test suite. Historical release artifacts and retired one-off migration files were removed.
1
+ # TEAMnetwork Xero MCP Server
2
+
3
+ ## Versioned implementation knowledge
4
+
5
+ Read `xero://capabilities/1.0.0` with MCP `resources/read`, or call the read-only
6
+ `get_capabilities` tool with `{}`. Both publish the same contract version,
7
+ documentation version, package version, content hash, local field meanings,
8
+ limitations, and the exact enabled runtime input schemas. Mutation/report/payroll
9
+ tool availability follows the configured profile. Cross-system meanings of
10
+ user-defined references belong to the shared knowledge service, not this server.
11
+
12
+ The detailed `xero://guidance/agent-playbook` resource is embedded from AGENTS.md
13
+ at build time, so it is present in published packages without requiring a
14
+ repository checkout. Run `npm run build` after editing AGENTS.md. No credentials
15
+ or customer records are included in these resources. Facades must explicitly
16
+ preserve or remap their URIs/tool names and apply authorization.
17
+
18
+ Tools accept optional `outputFormat: "json"` to return valid JSON text. The option is removed locally and is never sent to the Xero API.
19
+
20
+ ## Streamable HTTP
21
+
22
+ Set `XERO_TRANSPORT=http` to serve stateless MCP at `/mcp`. It binds to `127.0.0.1` by default; remote binding requires `XERO_HTTP_BEARER_TOKEN` and `XERO_HTTP_ALLOWED_HOSTS`. Optional controls include `XERO_HTTP_PORT`, `XERO_HTTP_ALLOWED_ORIGINS`, and `XERO_HTTP_MAX_BODY_BYTES`. A health endpoint is available at `/health`.
23
+
24
+ A [Model Context Protocol (MCP)](https://modelcontextprotocol.io/) server for Xero, maintained by [TEAMnetwork](https://teamnetwork.co.nz). Forked and extended from the [official Xero MCP Server](https://github.com/XeroAPI/xero-mcp-server).
25
+
26
+ Provides AI agents and MCP-compatible clients (e.g. Claude Desktop) with tools to read and write Xero accounting data, manage invoice attachments, and download invoice PDFs.
27
+
28
+ ## Features
29
+
30
+ - **Invoices** - create, list, structured search, native batch lookup, settlement/history inspection, update, authorise, void, get full detail, download as PDF
31
+ - **Contacts** - create, list, identifier-based resolution, update, archive
32
+ - **Quotes** — create, list, update, convert to invoice
33
+ - **Payments & Credit Notes** — create, list, update
34
+ - **Bank Transactions & Manual Journals** — create, list, update
35
+ - **Accounts, Items, Tax Rates, Tracking** — list, create, update
36
+ - **Financial Reports** — Trial Balance, Profit & Loss, Balance Sheet, Aged Payables/Receivables
37
+ - **Invoice Attachments** — list, upload (e.g. Crystal Reports PDFs), download, delete
38
+ - **Payroll** — employees, leave, timesheets *(optional, off by default)*
39
+ - **Modular scopes** — only request the Xero API permissions your use case needs
40
+
41
+ ## Prerequisites
42
+
43
+ - Node.js v18 or higher
44
+ - A Xero developer account with API credentials
45
+
46
+ ## Docs and Links
47
+
48
+ - [Xero Public API Documentation](https://developer.xero.com/documentation/api/)
49
+ - [Xero API Explorer](https://api-explorer.xero.com/)
50
+ - [Xero-Node SDK Docs](https://xeroapi.github.io/xero-node/accounting)
51
+ - [MCP Protocol Specification](https://modelcontextprotocol.io/)
52
+
53
+ ---
54
+
55
+ ## Setup
56
+
57
+ ### 1. Create a Xero Developer App
58
+
59
+ Set up a **Custom Connection** following Xero's guide:
60
+ https://developer.xero.com/documentation/guides/oauth2/custom-connections/
61
+
62
+ When configuring scopes in your Xero app, include the scopes for the feature groups you plan to use (see [Feature Groups](#feature-groups) below). At minimum you need:
63
+
64
+ ```
65
+ accounting.transactions
66
+ accounting.contacts
67
+ accounting.settings
68
+ accounting.attachments
69
+ accounting.journals.read
70
+ ```
71
+
72
+ ### 2. Authentication
73
+
74
+ There are two authentication modes:
75
+
76
+ #### Custom Connections (recommended)
77
+
78
+ Uses a Client ID and Secret tied to a specific Xero organisation. Best for Claude Desktop and single-org setups.
79
+
80
+ ```json
81
+ {
82
+ "mcpServers": {
83
+ "xero": {
84
+ "command": "npx",
85
+ "args": ["-y", "tn-xero-mcp-server@latest"],
86
+ "env": {
87
+ "XERO_CLIENT_ID": "your_client_id_here",
88
+ "XERO_CLIENT_SECRET": "your_client_secret_here"
89
+ }
90
+ }
91
+ }
92
+ }
93
+ ```
94
+
95
+ #### Bearer Token
96
+
97
+ Use when your MCP client handles the OAuth flow (e.g. PKCE). The bearer token takes precedence over Client ID/Secret if both are set.
98
+
99
+ ```json
100
+ {
101
+ "mcpServers": {
102
+ "xero": {
103
+ "command": "npx",
104
+ "args": ["-y", "tn-xero-mcp-server@latest"],
105
+ "env": {
106
+ "XERO_CLIENT_BEARER_TOKEN": "your_bearer_token"
107
+ }
108
+ }
109
+ }
110
+ }
111
+ ```
112
+
113
+ When obtaining a bearer token, request the scopes matching your enabled feature groups. See [Feature Groups](#feature-groups) for the full scope list.
114
+
115
+ ---
116
+
117
+ ## Feature Groups
118
+
119
+ Scopes and tools are controlled by environment variables. This means you only provision the Xero API permissions your setup actually needs.
120
+
121
+ | Variable | Default | Scopes requested | Tools enabled |
122
+ |---|---|---|---|
123
+ | *(core — always on)* | — | `accounting.transactions` `accounting.contacts` `accounting.settings` `accounting.attachments` `accounting.journals.read` | All invoicing, contact, payment, attachment, PDF & journal tools |
124
+ | `XERO_ENABLE_REPORTS` | `true` | `accounting.reports.read` | Trial Balance, P&L, Balance Sheet, Aged Payables/Receivables |
125
+ | `XERO_ENABLE_PAYROLL` | `false` | `payroll.settings` `payroll.employees` `payroll.timesheets` | All payroll tools |
126
+ | `XERO_READWRITE` | `false` | No additional scopes | Create, update, and delete tools |
127
+
128
+ > **Note:** To use payroll tools, your Xero region must be **NZ** or **UK**, and your Xero app must have the payroll scopes provisioned.
129
+
130
+ `XERO_ENABLE_READWRITE=true` remains a deprecated compatibility alias for one release. `XERO_READWRITE` takes precedence when both are set.
131
+
132
+ ### Full configuration example
133
+
134
+ ```json
135
+ {
136
+ "mcpServers": {
137
+ "xero": {
138
+ "command": "npx",
139
+ "args": ["-y", "tn-xero-mcp-server@latest"],
140
+ "env": {
141
+ "XERO_CLIENT_ID": "your_client_id_here",
142
+ "XERO_CLIENT_SECRET": "your_client_secret_here",
143
+ "XERO_ENABLE_REPORTS": "true",
144
+ "XERO_ENABLE_PAYROLL": "false",
145
+ "XERO_READWRITE": "false",
146
+ "XERO_DOWNLOAD_PATH": "C:/Users/you/Downloads/Xero"
147
+ }
148
+ }
149
+ }
150
+ }
151
+ ```
152
+
153
+ ### `XERO_DOWNLOAD_PATH`
154
+
155
+ The local directory where downloaded invoice PDFs and attachments are saved.
156
+ Defaults to `~/Downloads` if not set.
157
+
158
+ ### `DATETIMEFORMAT`
159
+
160
+ Controls which timezone is used when computing "today" defaults and displaying UTC timestamps from the API.
161
+
162
+ | Value | Behaviour |
163
+ |---|---|
164
+ | unset or `local` *(default)* | Use the system's local timezone (`Intl.DateTimeFormat` auto-detection) |
165
+ | IANA name e.g. `Pacific/Auckland` | Use this explicit timezone |
166
+
167
+ Date inputs to the Xero API (invoice dates, fromDate, toDate, etc.) are `YYYY-MM-DD` strings interpreted by Xero in the organisation's own timezone — no conversion is applied to those. The `DATETIMEFORMAT` setting affects "today" defaults and the display of UTC timestamps returned by the API (e.g. `UpdatedDateUTC`).
168
+
169
+ ---
170
+
171
+ ## Available Tools
172
+
173
+ ### Invoices
174
+ | Tool | Description |
175
+ |---|---|
176
+ | `list-invoices` | List invoices and filter direction with `type=ACCREC` (AR sales invoices) or `type=ACCPAY` (AP purchase bills) |
177
+ | `xero_search_transactions` | Structured invoice/bill search; set `type=ACCREC` for AR or `type=ACCPAY` for AP, because contact filters do not infer direction |
178
+ | `xero_batch_invoice_lookup` | Native exact lookup for up to 100 invoice numbers with per-input duplicate/unmatched results |
179
+ | `xero_lookup_invoice` | Scalar exact invoice-number lookup for clients affected by Hermes array coercion |
180
+ | `get-invoice` | Get full details of a single invoice including all line items |
181
+ | `xero_get_bill_settlement` | Trace payments, credits, prepayments, overpayments and the outstanding balance |
182
+ | `xero_get_invoice_history` | Retrieve Xero-recorded invoice/bill history events (not a complete field-level audit trail) |
183
+ | `create-invoice` | Create a new draft invoice (AR or AP) |
184
+ | `update-invoice` | Update a draft invoice |
185
+ | `authorise-invoice` | Promote a DRAFT or SUBMITTED invoice to AUTHORISED |
186
+ | `void-invoice` | Void an AUTHORISED invoice, or delete a DRAFT invoice |
187
+ | `get-invoice-pdf` | Download the Xero-generated invoice PDF to local disk |
188
+ | `list-invoice-attachments` | List all file attachments on an invoice |
189
+ | `xero_list_bill_attachments` | Return compact structured attachment metadata without binary content |
190
+ | `upload-invoice-attachment` | Upload a local file (e.g. Crystal Reports PDF) as an invoice attachment |
191
+ | `get-invoice-attachment` | Download an invoice attachment to local disk |
192
+ | `xero_get_bill_attachment` | Explicit metadata-verified attachment download with a configurable size limit |
193
+ | `delete-invoice-attachment` | Delete an attachment from an invoice |
194
+
195
+ ### Quotes
196
+ | Tool | Description |
197
+ |---|---|
198
+ | `list-quotes` | List quotes |
199
+ | `create-quote` | Create a new quote |
200
+ | `update-quote` | Update an existing quote |
201
+ | `convert-quote-to-invoice` | Convert a quote into a draft invoice, copying all line items |
202
+
203
+ ### Contacts
204
+ | Tool | Description |
205
+ |---|---|
206
+ | `list-contacts` | List contacts; `contactRole=customer` filters AR customers and `contactRole=supplier` filters AP suppliers; omit it to include unclassified contacts |
207
+ | `xero_find_contact` | Resolve a contact without silently choosing ambiguous matches; `role` is optional because contacts may be customer, supplier, both, or `Unknown` |
208
+ | `create-contact` | Create a new contact |
209
+ | `update-contact` | Update an existing contact |
210
+ | `archive-contact` | Archive a contact (Xero does not support hard deletion) |
211
+ | `list-contact-groups` | List contact groups |
212
+
213
+ ### Payments & Credit Notes
214
+ | Tool | Description |
215
+ |---|---|
216
+ | `list-payments` | List payments |
217
+ | `create-payment` | Record a payment against an invoice |
218
+ | `list-overpayments` | List overpayments (not returned by `list-payments`) |
219
+ | `list-prepayments` | List prepayments (not returned by `list-payments`) |
220
+ | `list-credit-notes` | List credit notes |
221
+ | `create-credit-note` | Create a credit note |
222
+ | `update-credit-note` | Update a draft credit note |
223
+
224
+ ### Bank & Journals
225
+ | Tool | Description |
226
+ |---|---|
227
+ | `list-bank-transactions` | List bank transactions |
228
+ | `create-bank-transaction` | Create a bank transaction |
229
+ | `update-bank-transaction` | Update a bank transaction |
230
+ | `list-report-bank-summary` | Opening/closing balance and cash in/out per bank account (Xero's Bank Summary report) |
231
+ | `list-manual-journals` | List manual journals |
232
+ | `create-manual-journal` | Create a manual journal |
233
+ | `update-manual-journal` | Update a manual journal |
234
+ | `list-journals` | List the underlying GL posting stream (double-entry journal lines per account) |
235
+
236
+ ### Settings & Configuration
237
+ | Tool | Description |
238
+ |---|---|
239
+ | `list-accounts` | List chart of accounts |
240
+ | `list-tax-rates` | List tax rates |
241
+ | `list-items` | List inventory items |
242
+ | `create-item` | Create an inventory item |
243
+ | `update-item` | Update an inventory item |
244
+ | `list-tracking-categories` | List tracking categories and options |
245
+ | `create-tracking-category` | Create a tracking category |
246
+ | `update-tracking-category` | Update a tracking category |
247
+ | `update-tracking-options` | Update tracking options |
248
+ | `create-tracking-option` | Create a tracking option |
249
+ | `list-organisation-details` | Get organisation details |
250
+
251
+ ### Financial Reports *(requires `XERO_ENABLE_REPORTS=true`)*
252
+ | Tool | Description |
253
+ |---|---|
254
+ | `list-trial-balance` | Trial balance report |
255
+ | `list-profit-and-loss` | Profit and loss report |
256
+ | `list-report-balance-sheet` | Balance sheet report |
257
+ | `list-aged-receivables-by-contact` | Aged receivables for a contact |
258
+ | `list-aged-payables-by-contact` | Aged payables for a contact |
259
+
260
+ `list-profit-and-loss` enforces a single-calendar-month base range and returns
261
+ comparison-column metadata containing each label, MCP-derived date window, MTD flag,
262
+ `source: MCP_DERIVED`, and `verifiedCallShape: true`. Multi-month base ranges are rejected
263
+ because Xero can return misleading rolling totals. Comparison calls with `periods>=1` also
264
+ require the current calendar month as the base; completed-month comparisons are rejected.
265
+ For N completed monthly columns, request the current month with `periods=N` and ignore
266
+ the first MTD column, or make N separate calls with `periods=0`.
267
+
268
+ ### Pagination
269
+
270
+ For tools with `page` and `pageSize`, `Found N` is the count for the current page, not a
271
+ total. To retrieve the complete filtered result set, increment `page` until a page contains
272
+ fewer records than `pageSize`. `xero_search_transactions` and `xero_find_contact` expose
273
+ `pagination.complete`, `pagination.truncated`, and `pagination.nextPage` instead. Xero does
274
+ not expose a configurable page size for `list-quotes`; continue until it returns an empty page.
275
+
276
+ Attachment filenames are non-authoritative and may contain amounts that differ from the
277
+ bill's gross total. Use Xero invoice `SubTotal`, `TotalTax`, and `Total` fields for financial
278
+ reconciliation, and retrieve binary attachment content only when explicitly needed.
279
+
280
+ ### AP and AR filtering
281
+
282
+ Invoice direction is explicit. `ACCREC` means Accounts Receivable sales invoices (money owed
283
+ to you by customers); `ACCPAY` means Accounts Payable purchase bills (money you owe suppliers).
284
+ Use the `type` filter on `list-invoices`, `xero_search_transactions`, and exact invoice lookup
285
+ tools whenever direction matters. Omitting `type` searches both. A `supplier` or `contactId`
286
+ filter identifies the contact on the transaction but does not automatically select `ACCPAY`.
287
+
288
+ Contact role is related but separate. `customer` means Xero's `IsCustomer` flag is true and
289
+ `supplier` means `IsSupplier` is true. A contact can be a customer, supplier, both, or neither
290
+ (`Type: Unknown`). Omit `role`/`contactRole` when unclassified contacts must remain searchable.
291
+ These role filters do not filter invoice direction; combine contact resolution with an explicit
292
+ invoice `type` for an AP- or AR-specific workflow.
293
+
294
+ `xero_search_transactions` searches invoices and bills. Bank transactions are a separate Xero
295
+ resource accessed with `list-bank-transactions`, using `RECEIVE` and `SPEND` transaction types
296
+ rather than `ACCREC` and `ACCPAY`.
297
+
298
+ ### Payroll *(requires `XERO_ENABLE_PAYROLL=true`)*
299
+ | Tool | Description |
300
+ |---|---|
301
+ | `list-payroll-employees` | List payroll employees |
302
+ | `list-payroll-employee-leave` | List an employee's leave records |
303
+ | `list-payroll-employee-leave-balances` | List an employee's leave balances |
304
+ | `list-payroll-employee-leave-types` | List leave types for an employee |
305
+ | `list-payroll-leave-periods` | List leave periods for an employee |
306
+ | `list-payroll-leave-types` | List all available leave types |
307
+ | `list-timesheets` | List timesheets |
308
+ | `create-payroll-timesheet` | Create a timesheet |
309
+ | `add-payroll-timesheet-line` | Add a line to a timesheet |
310
+ | `update-payroll-timesheet-line` | Update a timesheet line |
311
+ | `approve-payroll-timesheet` | Approve a timesheet |
312
+ | `revert-payroll-timesheet` | Revert an approved timesheet |
313
+ | `delete-timesheet` | Delete a timesheet |
314
+ | `get-payroll-timesheet` | Get a timesheet by ID |
315
+
316
+ ---
317
+
318
+ ## Agent guidance
319
+
320
+ The server supplies MCP `instructions` that are automatically delivered to the calling agent at session start. These cover:
321
+
322
+ - **Datetime handling** — `YYYY-MM-DD` date inputs, local-timezone "today" defaults, UTC timestamp display
323
+ - **Efficiency rules** — filter server-side first; never page through all records to find specific items
324
+ - **Xero terminology** — ACCREC/ACCPAY, AUTHORISED, IsReconciled explained
325
+ - **Read-only mode** — detecting and communicating when write tools are absent
326
+ - **API limitations** — reconciliation, aged reports, rate limits, page size guidance
327
+
328
+ For a full query playbook, see the MCP resource `xero://guidance/agent-playbook` (or `AGENTS.md` for local reference).
329
+
330
+ ### Structured lookup contracts
331
+
332
+ The `xero_*` lookup tools return compact JSON with a consistent `matchStatus`
333
+ (`EXACT`, `MULTIPLE`, `CANDIDATES`, `NOT_FOUND`, or `ERROR`), an explicit
334
+ `ambiguous` flag, pagination completeness/continuation metadata where relevant,
335
+ and structured errors. Xero and external identifiers remain strings; money values
336
+ are returned as decimal strings with their currency code.
337
+
338
+ For TEAMlink purchase bills, live API verification confirmed that the convention
339
+ `<supplier-invoice-number> / <TEAMlink-orderId>` is stored in Xero's
340
+ `InvoiceNumber` field (for example `SYNTHETIC-BILL / TEST-REFERENCE`), while `Reference` is empty.
341
+ Exact and batch searches therefore use Xero's native `InvoiceNumbers` filter. The
342
+ separate `reference` search remains available for records that use that field.
343
+
344
+ `xero_batch_invoice_lookup.invoiceNumbers` is a native JSON string array. Numeric-
345
+ looking identifiers are intentionally not coerced to numbers. The reported Hermes
346
+ `coerce_tool_args` defect is outside this repository and must also be corrected in
347
+ the Hermes runtime if that client still rewrites valid JSON arrays before sending
348
+ the MCP request. Until then, use scalar `xero_lookup_invoice` for exact single-value
349
+ lookups or `xero_search_transactions` for broader matching.
350
+
351
+ ## For Developers
352
+
353
+ ### Local development setup
354
+
355
+ ```bash
356
+ git clone https://github.com/your-org/tn-xero-mcp-server.git
357
+ cd tn-xero-mcp-server
358
+ npm install
359
+ cp .env.example .env
360
+ # Edit .env with your credentials
361
+ npm run build
362
+ ```
363
+
364
+ ### Linking to Claude Desktop for development
365
+
366
+ In your `claude_desktop_config.json`, point directly at the built file:
367
+
368
+ ```json
369
+ {
370
+ "mcpServers": {
371
+ "xero": {
372
+ "command": "node",
373
+ "args": ["C:/path/to\\Xero-MCP\\dist\\index.js"],
374
+ "env": {
375
+ "XERO_CLIENT_ID": "your_client_id_here",
376
+ "XERO_CLIENT_SECRET": "your_client_secret_here",
377
+ "XERO_ENABLE_PAYROLL": "false",
378
+ "XERO_DOWNLOAD_PATH": "C:\\Users\\you\\Downloads\\Xero"
379
+ }
380
+ }
381
+ }
382
+ }
383
+ ```
384
+
385
+ > **Windows note:** Backslashes in `args` paths must be escaped as `\\`.
386
+
387
+ ### Publishing updates
388
+
389
+ ```bash
390
+ npm run build
391
+ npm publish
392
+ ```
393
+
394
+ ---
395
+
396
+ ## License
397
+
398
+ MIT
399
+
400
+ ## Security
401
+
402
+ Do not commit your `.env` file or any credentials to version control. The `.gitignore` excludes `.env` by default.
403
+
404
+ <!-- BEGIN MCP configuration reference -->
405
+ ## Environment variable reference
406
+
407
+ The server automatically loads `.env` from its working directory; environment variables already set by the client take precedence.
408
+
409
+ Copy `.env.example` for variable names and safe placeholders. Replace required placeholders privately. Optional variables should be omitted unless needed; an empty value may override a default. Never commit credentials, real identities, device profiles, exports, or logs.
410
+
411
+ | Variable | Required | Default | Purpose and accepted values |
412
+ |---|---|---|---|
413
+ | `DATETIMEFORMAT` | No | `local` | Output date setting: local or an IANA timezone; shared by SSLStore and Xero. |
414
+ | `XERO_CLIENT_BEARER_TOKEN` | Alternative | `unset` | Existing access token; use instead of a client ID/secret pair. Renew externally when expired. |
415
+ | `XERO_CLIENT_ID` | Alternative | `unset` | Custom Connection client ID; must be set together with XERO_CLIENT_SECRET. |
416
+ | `XERO_CLIENT_SECRET` | Alternative | `unset` | Custom Connection client secret; must be set together with XERO_CLIENT_ID. |
417
+ | `XERO_DOWNLOAD_PATH` | No | `user Downloads directory` | Download destination; choose a private directory outside source control. |
418
+ | `XERO_ENABLE_PAYROLL` | No | `false` | Literal true registers payroll tools; requires appropriate scopes. |
419
+ | `XERO_ENABLE_READWRITE` | Deprecated | `unset` | Compatibility alias for XERO_READWRITE; canonical variable wins. |
420
+ | `XERO_ENABLE_REPORTS` | No | `true` | Reports are enabled unless set to literal false. |
421
+ | `XERO_HTTP_ALLOWED_HOSTS` | Conditional | `unset` | Comma-separated Host allowlist required for non-loopback HTTP; use the public hostnames accepted by the listener. |
422
+ | `XERO_HTTP_ALLOWED_ORIGINS` | No | `unset` | Comma-separated browser Origin allowlist; configure when browser clients need access. |
423
+ | `XERO_HTTP_BEARER_TOKEN` | Conditional | `unset` | Private bearer secret required for non-loopback HTTP; clients send Authorization: Bearer <secret>. |
424
+ | `XERO_HTTP_HOST` | No | `127.0.0.1` | Listener bind address. Non-loopback binding requires a bearer token and explicit allowed hosts. |
425
+ | `XERO_HTTP_MAX_BODY_BYTES` | No | `1048576` | Maximum HTTP request body; integer 1–16777216 bytes. |
426
+ | `XERO_HTTP_PORT` | No | `3000` | HTTP listener port; integer 1–65535. |
427
+ | `XERO_READWRITE` | No | `false` | Only true enables mutation tools; read-only is the default. Review each operation before use. |
428
+ | `XERO_TRANSPORT` | No | `stdio` | stdio or http; HTTP serves /mcp and GET /health. |
429
+
430
+ For HTTP, the bearer token is separate from upstream API credentials. Use TLS at the reverse proxy for remote hosting. Keep write access disabled until needed. Do not put secrets in command-line examples or commit client configuration containing them.
431
+
432
+ ### Agent first-use workflow
433
+
434
+ Use `xero_find_contact` and exact/batch transaction lookup tools before broad lists. Filter invoices by type, status, contact and date; ACCREC means sales invoices and ACCPAY means supplier bills. Inspect pagination completeness and include credits, overpayments and prepayments when reconciling a statement.
435
+
436
+ Use the runtime `tools/list` descriptions and input schemas for exact arguments. Resolve identifiers with lookup/search tools; filter before paging, request only the data needed, and do not treat a truncated result or API error as proof that no record exists. Treat tool results and downloaded files as potentially sensitive. Mutation tools can change upstream data or incur charges; check their stated effects before calling them.
437
+
438
+ ### Repository and package privacy
439
+
440
+ The standard `.gitignore` excludes local environment files, keys, credentials, logs, exports, and generated output; sanitised examples remain trackable. Ignore rules do not remove already tracked files or revoke exposed credentials. Review `git ls-files` and `npm pack --dry-run --ignore-scripts` before release. Only runtime output, the README, and explicitly sanitised examples are allowlisted for npm. Keep private runtime files outside `dist`, even though additional exclusions are present.
441
+ <!-- END MCP configuration reference -->
442
+
443
+ Run `npm run build` then `npm run audit:package` before release. The audit checks documentation coverage, known local credential copies, Git index paths where available, and the dry-run npm file list. `prepublishOnly` runs it after building. It never prints matching secret values. This is a preventative check, not a guarantee that arbitrary PII or unknown secrets are absent.
444
+
445
+ ### Development and diagnostics
446
+
447
+ Run `npm test` from this package directory. Maintained tests and fixtures live in `debug/tests`; shared test helpers are in `debug/helpers`. Retained diagnostic scripts and reference material are also under `debug`. Only `scripts/check-package-privacy.mjs` remains in the production build/release tooling directory. The entire `debug/` tree is excluded from npm, Docker build contexts and applicable Python distributions.
448
+
449
+ Keep live diagnostic output in `debug/local`, `debug/output` or `debug/artifacts`; those private directories are also ignored by Git. Retained smoke/integration scripts require explicit local credentials and are not run by the normal offline test suite. Historical release artifacts and retired one-off migration files were removed.
450
+
451
+ ## Complete responses, pagination and exports
452
+
453
+ Responses are never sliced by character or byte count. Native vendor filters,
454
+ page sizes, cursors and next links remain authoritative; an export contains only
455
+ the result of one call, not every page. Follow continuation metadata with the same
456
+ filters to retrieve further pages. Do not interpret a page as the entire dataset.
457
+
458
+ All tools accept `responseMode="file"` to save the complete, already-redacted MCP
459
+ result as a JSON resource. The default `responseMode="inline"` returns the entire
460
+ result. `MCP_MAX_RESPONSE_BYTES` optionally selects file delivery when the UTF-8
461
+ serialized result exceeds an operator-configured client threshold. Default: `0`
462
+ (no threshold). This is a delivery threshold, not a hard maximum on the final
463
+ envelope, and does not discard records. Invalid values fail server initialization.
464
+
465
+ Responses include `_meta.response`: `inlineComplete`, `truncated` (false when no
466
+ data was discarded for delivery), `datasetComplete` (null unless explicitly known
467
+ from the source), and `originalBytes`. Existing vendor pagination is preserved. sourceTruncated and sourcePagination expose known source truncation and continuation signals even when the result is delivered as a file.
468
+ For file delivery, `structuredContent` and text describe the export, its byte size,
469
+ SHA-256, expiry and resource URI. Use MCP `resources/read` on the supplied
470
+ `mcp-export://response/...` URI to retrieve the original MCP result as valid JSON.
471
+ No records or JSON fragments are returned as a misleading preview. Export is also
472
+ available for formatted text and binary MCP content, encoded in the result JSON.
473
+
474
+ Exports are scoped to the current server instance/session and expire after 24
475
+ hours. They are stored in a private temporary subdirectory of `MCP_EXPORT_DIR`
476
+ (default: OS temporary directory); files use owner-only permissions where
477
+ supported. Expired files are removed on subsequent export/read activity. Operators
478
+ must secure the directory on Windows and arrange cleanup of files left by stopped
479
+ processes. Remote clients should use the resource URI, not assume a local path is
480
+ accessible. If storage fails, the complete result remains inline with
481
+ `exportError="EXPORT_UNAVAILABLE"`; do not repeat successful mutations.