@teamnetwork-nz/xero-mcp-server 1.15.3 → 1.16.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/.env.example ADDED
@@ -0,0 +1,36 @@
1
+ # Sanitised template: no live credentials or identities.
2
+ # See README.md for requirements, defaults and .env loading behaviour.
3
+ # Replace required/alternative placeholders privately; uncomment optional settings only when needed.
4
+
5
+ # Output date setting: local or an IANA timezone; shared by SSLStore and Xero.
6
+ # DATETIMEFORMAT=local
7
+ # Existing access token; use instead of a client ID/secret pair. Renew externally when expired.
8
+ # XERO_CLIENT_BEARER_TOKEN=<set-privately>
9
+ # Custom Connection client ID; must be set together with XERO_CLIENT_SECRET.
10
+ XERO_CLIENT_ID=<set-privately>
11
+ # Custom Connection client secret; must be set together with XERO_CLIENT_ID.
12
+ XERO_CLIENT_SECRET=<set-privately>
13
+ # Download destination; choose a private directory outside source control.
14
+ # XERO_DOWNLOAD_PATH=<set-privately>
15
+ # Literal true registers payroll tools; requires appropriate scopes.
16
+ # XERO_ENABLE_PAYROLL=false
17
+ # Compatibility alias for XERO_READWRITE; canonical variable wins.
18
+ # XERO_ENABLE_READWRITE=<set-privately>
19
+ # Reports are enabled unless set to literal false.
20
+ # XERO_ENABLE_REPORTS=true
21
+ # Comma-separated Host allowlist required for non-loopback HTTP; use the public hostnames accepted by the listener.
22
+ # XERO_HTTP_ALLOWED_HOSTS=<set-privately>
23
+ # Comma-separated browser Origin allowlist; configure when browser clients need access.
24
+ # XERO_HTTP_ALLOWED_ORIGINS=<set-privately>
25
+ # Private bearer secret required for non-loopback HTTP; clients send Authorization: Bearer <secret>.
26
+ # XERO_HTTP_BEARER_TOKEN=<set-privately>
27
+ # Listener bind address. Non-loopback binding requires a bearer token and explicit allowed hosts.
28
+ # XERO_HTTP_HOST=127.0.0.1
29
+ # Maximum HTTP request body; integer 1–16777216 bytes.
30
+ # XERO_HTTP_MAX_BODY_BYTES=1048576
31
+ # HTTP listener port; integer 1–65535.
32
+ # XERO_HTTP_PORT=3000
33
+ # Only true enables mutation tools; read-only is the default. Review each operation before use.
34
+ # XERO_READWRITE=false
35
+ # stdio or http; HTTP serves /mcp and GET /health.
36
+ # XERO_TRANSPORT=stdio
package/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # TEAMnetwork Xero MCP Server
2
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
+
3
5
  ## Streamable HTTP
4
6
 
5
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`.
@@ -320,7 +322,7 @@ are returned as decimal strings with their currency code.
320
322
 
321
323
  For TEAMlink purchase bills, live API verification confirmed that the convention
322
324
  `<supplier-invoice-number> / <TEAMlink-orderId>` is stored in Xero's
323
- `InvoiceNumber` field (for example `4462570 / 121058`), while `Reference` is empty.
325
+ `InvoiceNumber` field (for example `SYNTHETIC-BILL / TEST-REFERENCE`), while `Reference` is empty.
324
326
  Exact and batch searches therefore use Xero's native `InvoiceNumbers` filter. The
325
327
  separate `reference` search remains available for records that use that field.
326
328
 
@@ -353,7 +355,7 @@ In your `claude_desktop_config.json`, point directly at the built file:
353
355
  "mcpServers": {
354
356
  "xero": {
355
357
  "command": "node",
356
- "args": ["C:\\Users\\you\\Development\\Xero-MCP\\dist\\index.js"],
358
+ "args": ["C:/path/to\\Xero-MCP\\dist\\index.js"],
357
359
  "env": {
358
360
  "XERO_CLIENT_ID": "your_client_id_here",
359
361
  "XERO_CLIENT_SECRET": "your_client_secret_here",
@@ -383,3 +385,50 @@ MIT
383
385
  ## Security
384
386
 
385
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.
@@ -17,13 +17,50 @@ function strictSchema(schema) {
17
17
  return schema.strict();
18
18
  return schema;
19
19
  }
20
+ function addOutputFormat(schema) {
21
+ const strict = strictSchema(schema);
22
+ if (typeof strict.extend !== "function")
23
+ return strict;
24
+ return strict.extend({
25
+ outputFormat: z.enum(["json"]).optional().describe("Return the result as valid JSON text without Markdown wrappers."),
26
+ }).strict?.() ?? strict;
27
+ }
28
+ function toJsonValue(text) {
29
+ const fenced = text.match(/\x60\x60\x60json\s*([\s\S]*?)\s*\x60\x60\x60/i)?.[1];
30
+ const candidate = fenced ?? text;
31
+ try {
32
+ return JSON.parse(candidate);
33
+ }
34
+ catch {
35
+ return text;
36
+ }
37
+ }
20
38
  /** Make every tool object reject undeclared arguments, including no-argument tools. */
21
39
  export function enforceStrictToolInputs(server) {
22
40
  const mutable = server;
23
41
  const createRegisteredTool = mutable._createRegisteredTool.bind(server);
24
42
  mutable._createRegisteredTool = (...args) => {
25
- // SDK 1.29 funnels both tool() and registerTool() through this method.
26
- args[3] = strictSchema(args[3]);
43
+ // The MCP-only output option is stripped here so it cannot leak into vendor API parameters.
44
+ args[3] = addOutputFormat(args[3]);
45
+ const handler = args[8];
46
+ if (typeof handler === "function") {
47
+ args[8] = async (input, ...rest) => {
48
+ const values = input && typeof input === "object" ? input : {};
49
+ const { outputFormat, ...toolArgs } = values;
50
+ const result = await handler(toolArgs, ...rest);
51
+ if (outputFormat !== "json" || result?.isError || !Array.isArray(result?.content))
52
+ return result;
53
+ const textItems = result.content.filter((item) => item.type === "text" && typeof item.text === "string");
54
+ if (textItems.length === 0)
55
+ return result;
56
+ const data = result.structuredContent !== undefined
57
+ ? result.structuredContent
58
+ : textItems.length === 1
59
+ ? toJsonValue((textItems[0]?.text ?? ''))
60
+ : textItems.map((item) => toJsonValue(item.text));
61
+ return { ...result, content: [{ type: "text", text: JSON.stringify(data, null, 2) }], ...(result.structuredContent === undefined && data && typeof data === "object" ? { structuredContent: data } : {}) };
62
+ };
63
+ }
27
64
  return createRegisteredTool(...args);
28
65
  };
29
66
  }
package/package.json CHANGED
@@ -1,39 +1,44 @@
1
- {
2
- "name": "@teamnetwork-nz/xero-mcp-server",
3
- "version": "1.15.3",
4
- "description": "MCP server implementation for Xero integration - TEAMnetwork",
5
- "license": "MIT",
6
- "main": "dist/index.js",
7
- "author": "Daryl Petersen - TEAMnetwork (https://teamnetwork.co.nz)",
8
- "type": "module",
9
- "bin": "./dist/index.js",
10
- "files": [
11
- "dist"
12
- ],
13
- "scripts": {
14
- "build": "tsc && shx chmod +x dist/*.js",
15
- "test": "npm run build && node --test test/*.test.js",
16
- "prepare": "npm run build",
17
- "watch": "tsc --watch",
18
- "lint:fix": "eslint --fix",
19
- "lint": "eslint ."
20
- },
21
- "dependencies": {
22
- "@modelcontextprotocol/sdk": "^1.32.2",
23
- "dotenv": "^16.4.7",
24
- "openid-client": "^6.8.1",
25
- "xero-node": "^13.3.0",
26
- "zod": "^4.6.7"
27
- },
28
- "devDependencies": {
29
- "@eslint/js": "^9.39.1",
30
- "@types/node": "^22.13.10",
31
- "eslint": "^9.39.1",
32
- "eslint-config-prettier": "^10.1.8",
33
- "globals": "^16.5.0",
34
- "prettier": "3.7.4",
35
- "shx": "^0.3.4",
36
- "typescript": "^5.9.3",
37
- "typescript-eslint": "^8.48.1"
38
- }
39
- }
1
+ {
2
+ "name": "@teamnetwork-nz/xero-mcp-server",
3
+ "version": "1.16.0",
4
+ "description": "MCP server implementation for Xero integration - TEAMnetwork",
5
+ "license": "MIT",
6
+ "main": "dist/index.js",
7
+ "author": "Daryl Petersen - TEAMnetwork (https://teamnetwork.co.nz)",
8
+ "type": "module",
9
+ "bin": "./dist/index.js",
10
+ "files": [
11
+ "dist/**/*.js",
12
+ "dist/**/*.d.ts",
13
+ "README.md",
14
+ ".env.example"
15
+ ],
16
+ "scripts": {
17
+ "build": "tsc && shx chmod +x dist/*.js",
18
+ "test": "npm run build && node --test debug/tests/*.test.js",
19
+ "prepare": "npm run build",
20
+ "watch": "tsc --watch",
21
+ "lint:fix": "eslint --fix",
22
+ "lint": "eslint .",
23
+ "audit:package": "node scripts/check-package-privacy.mjs",
24
+ "prepublishOnly": "npm run build && npm run audit:package"
25
+ },
26
+ "dependencies": {
27
+ "@modelcontextprotocol/sdk": "^1.32.2",
28
+ "dotenv": "^16.4.7",
29
+ "openid-client": "^6.8.1",
30
+ "xero-node": "^13.3.0",
31
+ "zod": "^4.6.7"
32
+ },
33
+ "devDependencies": {
34
+ "@eslint/js": "^9.39.1",
35
+ "@types/node": "^22.13.10",
36
+ "eslint": "^9.39.1",
37
+ "eslint-config-prettier": "^10.1.8",
38
+ "globals": "^16.5.0",
39
+ "prettier": "3.7.4",
40
+ "shx": "^0.3.4",
41
+ "typescript": "^5.9.3",
42
+ "typescript-eslint": "^8.48.1"
43
+ }
44
+ }