xero-mcp-server
v2.0.5MCP server implementation for Xero integration - TEAMnetwork
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. A Model Context Protocol (MCP) server for Xero, maintained by TEAMnetwork. Forked and extended from the official Xero MCP Server. Provides AI agents and MCP-compatible clients (e.g.
Summary extracted from the README.
TEAMnetwork Xero MCP Server
Streamable HTTP
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.
A Model Context Protocol (MCP) server for Xero, maintained by TEAMnetwork. Forked and extended from the official Xero MCP Server.
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.
Features
- Invoices - create, list, structured search, native batch lookup, settlement/history inspection, update, authorise, void, get full detail, download as PDF
- Contacts - create, list, identifier-based resolution, update, archive
- Quotes — create, list, update, convert to invoice
- Payments & Credit Notes — create, list, update
- Bank Transactions & Manual Journals — create, list, update
- Accounts, Items, Tax Rates, Tracking — list, create, update
- Financial Reports — Trial Balance, Profit & Loss, Balance Sheet, Aged Payables/Receivables
- Invoice Attachments — list, upload (e.g. Crystal Reports PDFs), download, delete
- Payroll — employees, leave, timesheets (optional, off by default)
- Modular scopes — only request the Xero API permissions your use case needs
Prerequisites
- Node.js v18 or higher
- A Xero developer account with API credentials
Docs and Links
Setup
1. Create a Xero Developer App
Set up a Custom Connection following Xero's guide: https://developer.xero.com/documentation/guides/oauth2/custom-connections/
When configuring scopes in your Xero app, include the scopes for the feature groups you plan to use (see Feature Groups below). At minimum you need:
accounting.transactions
accounting.contacts
accounting.settings
accounting.attachments
accounting.journals.read
2. Authentication
There are two authentication modes:
Custom Connections (recommended)
Uses a Client ID and Secret tied to a specific Xero organisation. Best for Claude Desktop and single-org setups.
{
"mcpServers": {
"xero": {
"command": "npx",
"args": ["-y", "tn-xero-mcp-server@latest"],
"env": {
"XERO_CLIENT_ID": "your_client_id_here",
"XERO_CLIENT_SECRET": "your_client_secret_here"
}
}
}
}
Bearer Token
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.
{
"mcpServers": {
"xero": {
"command": "npx",
"args": ["-y", "tn-xero-mcp-server@latest"],
"env": {
"XERO_CLIENT_BEARER_TOKEN": "your_bearer_token"
}
}
}
}
When obtaining a bearer token, request the scopes matching your enabled feature groups. See Feature Groups for the full scope list.
Feature Groups
Scopes and tools are controlled by environment variables. This means you only provision the Xero API permissions your setup actually needs.
| Variable | Default | Scopes requested | Tools enabled |
|---|---|---|---|
| (core — always on) | — | accounting.transactions accounting.contacts accounting.settings accounting.attachments accounting.journals.read |
All invoicing, contact, payment, attachment, PDF & journal tools |
XERO_ENABLE_REPORTS |
true |
accounting.reports.read |
Trial Balance, P&L, Balance Sheet, Aged Payables/Receivables |
XERO_ENABLE_PAYROLL |
false |
payroll.settings payroll.employees payroll.timesheets |
All payroll tools |
XERO_READWRITE |
false |
No additional scopes | Create, update, and delete tools |
Note: To use payroll tools, your Xero region must be NZ or UK, and your Xero app must have the payroll scopes provisioned.
XERO_ENABLE_READWRITE=true remains a deprecated compatibility alias for one release. XERO_READWRITE takes precedence when both are set.
Full configuration example
{
"mcpServers": {
"xero": {
"command": "npx",
"args": ["-y", "tn-xero-mcp-server@latest"],
"env": {
"XERO_CLIENT_ID": "your_client_id_here",
"XERO_CLIENT_SECRET": "your_client_secret_here",
"XERO_ENABLE_REPORTS": "true",
"XERO_ENABLE_PAYROLL": "false",
"XERO_READWRITE": "false",
"XERO_DOWNLOAD_PATH": "C:/Users/you/Downloads/Xero"
}
}
}
}
XERO_DOWNLOAD_PATH
The local directory where downloaded invoice PDFs and attachments are saved.
Defaults to ~/Downloads if not set.
DATETIMEFORMAT
Controls which timezone is used when computing "today" defaults and displaying UTC timestamps from the API.
| Value | Behaviour |
|---|---|
unset or local (default) |
Use the system's local timezone (Intl.DateTimeFormat auto-detection) |
IANA name e.g. Pacific/Auckland |
Use this explicit timezone |
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).
Available Tools
Invoices
| Tool | Description |
|---|---|
list-invoices |
List invoices and filter direction with type=ACCREC (AR sales invoices) or type=ACCPAY (AP purchase bills) |
xero_search_transactions |
Structured invoice/bill search; set type=ACCREC for AR or type=ACCPAY for AP, because contact filters do not infer direction |
xero_batch_invoice_lookup |
Native exact lookup for up to 100 invoice numbers with per-input duplicate/unmatched results |
xero_lookup_invoice |
Scalar exact invoice-number lookup for clients affected by Hermes array coercion |
get-invoice |
Get full details of a single invoice including all line items |
xero_get_bill_settlement |
Trace payments, credits, prepayments, overpayments and the outstanding balance |
xero_get_invoice_history |
Retrieve Xero-recorded invoice/bill history events (not a complete field-level audit trail) |
create-invoice |
Create a new draft invoice (AR or AP) |
update-invoice |
Update a draft invoice |
authorise-invoice |
Promote a DRAFT or SUBMITTED invoice to AUTHORISED |
void-invoice |
Void an AUTHORISED invoice, or delete a DRAFT invoice |
get-invoice-pdf |
Download the Xero-generated invoice PDF to local disk |
list-invoice-attachments |
List all file attachments on an invoice |
xero_list_bill_attachments |
Return compact structured attachment metadata without binary content |
upload-invoice-attachment |
Upload a local file (e.g. Crystal Reports PDF) as an invoice attachment |
get-invoice-attachment |
Download an invoice attachment to local disk |
xero_get_bill_attachment |
Explicit metadata-verified attachment download with a configurable size limit |
delete-invoice-attachment |
Delete an attachment from an invoice |
Quotes
| Tool | Description |
|---|---|
list-quotes |
List quotes |
create-quote |
Create a new quote |
update-quote |
Update an existing quote |
convert-quote-to-invoice |
Convert a quote into a draft invoice, copying all line items |
Contacts
| Tool | Description |
|---|---|
list-contacts |
List contacts; contactRole=customer filters AR customers and contactRole=supplier filters AP suppliers; omit it to include unclassified contacts |
xero_find_contact |
Resolve a contact without silently choosing ambiguous matches; role is optional because contacts may be customer, supplier, both, or Unknown |
create-contact |
Create a new contact |
update-contact |
Update an existing contact |
archive-contact |
Archive a contact (Xero does not support hard deletion) |
list-contact-groups |
List contact groups |
Payments & Credit Notes
| Tool | Description |
|---|---|
list-payments |
List payments |
create-payment |
Record a payment against an invoice |
list-overpayments |
List overpayments (not returned by list-payments) |
list-prepayments |
List prepayments (not returned by list-payments) |
list-credit-notes |
List credit notes |
create-credit-note |
Create a credit note |
update-credit-note |
Update a draft credit note |
Bank & Journals
| Tool | Description |
|---|---|
list-bank-transactions |
List bank transactions |
create-bank-transaction |
Create a bank transaction |
update-bank-transaction |
Update a bank transaction |
list-report-bank-summary |
Opening/closing balance and cash in/out per bank account (Xero's Bank Summary report) |
list-manual-journals |
List manual journals |
create-manual-journal |
Create a manual journal |
update-manual-journal |
Update a manual journal |
list-journals |
List the underlying GL posting stream (double-entry journal lines per account) |
Settings & Configuration
| Tool | Description |
|---|---|
list-accounts |
List chart of accounts |
list-tax-rates |
List tax rates |
list-items |
List inventory items |
create-item |
Create an inventory item |
update-item |
Update an inventory item |
list-tracking-categories |
List tracking categories and options |
create-tracking-category |
Create a tracking category |
update-tracking-category |
Update a tracking category |
update-tracking-options |
Update tracking options |
create-tracking-option |
Create a tracking option |
list-organisation-details |
Get organisation details |
Financial Reports (requires XERO_ENABLE_REPORTS=true)
| Tool | Description |
|---|---|
list-trial-balance |
Trial balance report |
list-profit-and-loss |
Profit and loss report |
list-report-balance-sheet |
Balance sheet report |
list-aged-receivables-by-contact |
Aged receivables for a contact |
list-aged-payables-by-contact |
Aged payables for a contact |
list-profit-and-loss enforces a single-calendar-month base range and returns
comparison-column metadata containing each label, MCP-derived date window, MTD flag,
source: MCP_DERIVED, and verifiedCallShape: true. Multi-month base ranges are rejected
because Xero can return misleading rolling totals. Comparison calls with periods>=1 also
require the current calendar month as the base; completed-month comparisons are rejected.
For N completed monthly columns, request the current month with periods=N and ignore
the first MTD column, or make N separate calls with periods=0.
Pagination
For tools with page and pageSize, Found N is the count for the current page, not a
total. To retrieve the complete filtered result set, increment page until a page contains
fewer records than pageSize. xero_search_transactions and xero_find_contact expose
pagination.complete, pagination.truncated, and pagination.nextPage instead. Xero does
not expose a configurable page size for list-quotes; continue until it returns an empty page.
Attachment filenames are non-authoritative and may contain amounts that differ from the
bill's gross total. Use Xero invoice SubTotal, TotalTax, and Total fields for financial
reconciliation, and retrieve binary attachment content only when explicitly needed.
AP and AR filtering
Invoice direction is explicit. ACCREC means Accounts Receivable sales invoices (money owed
to you by customers); ACCPAY means Accounts Payable purchase bills (money you owe suppliers).
Use the type filter on list-invoices, xero_search_transactions, and exact invoice lookup
tools whenever direction matters. Omitting type searches both. A supplier or contactId
filter identifies the contact on the transaction but does not automatically select ACCPAY.
Contact role is related but separate. customer means Xero's IsCustomer flag is true and
supplier means IsSupplier is true. A contact can be a customer, supplier, both, or neither
(Type: Unknown). Omit role/contactRole when unclassified contacts must remain searchable.
These role filters do not filter invoice direction; combine contact resolution with an explicit
invoice type for an AP- or AR-specific workflow.
xero_search_transactions searches invoices and bills. Bank transactions are a separate Xero
resource accessed with list-bank-transactions, using RECEIVE and SPEND transaction types
rather than ACCREC and ACCPAY.
Payroll (requires XERO_ENABLE_PAYROLL=true)
| Tool | Description |
|---|---|
list-payroll-employees |
List payroll employees |
list-payroll-employee-leave |
List an employee's leave records |
list-payroll-employee-leave-balances |
List an employee's leave balances |
list-payroll-employee-leave-types |
List leave types for an employee |
list-payroll-leave-periods |
List leave periods for an employee |
list-payroll-leave-types |
List all available leave types |
list-timesheets |
List timesheets |
create-payroll-timesheet |
Create a timesheet |
add-payroll-timesheet-line |
Add a line to a timesheet |
update-payroll-timesheet-line |
Update a timesheet line |
approve-payroll-timesheet |
Approve a timesheet |
revert-payroll-timesheet |
Revert an approved timesheet |
delete-timesheet |
Delete a timesheet |
get-payroll-timesheet |
Get a timesheet by ID |
Agent guidance
The server supplies MCP instructions that are automatically delivered to the calling agent at session start. These cover:
- Datetime handling —
YYYY-MM-DDdate inputs, local-timezone "today" defaults, UTC timestamp display - Efficiency rules — filter server-side first; never page through all records to find specific items
- Xero terminology — ACCREC/ACCPAY, AUTHORISED, IsReconciled explained
- Read-only mode — detecting and communicating when write tools are absent
- API limitations — reconciliation, aged reports, rate limits, page size guidance
For a full query playbook, see the MCP resource xero://guidance/agent-playbook (or AGENTS.md for local reference).
Structured lookup contracts
The xero_* lookup tools return compact JSON with a consistent matchStatus
(EXACT, MULTIPLE, CANDIDATES, NOT_FOUND, or ERROR), an explicit
ambiguous flag, pagination completeness/continuation metadata where relevant,
and structured errors. Xero and external identifiers remain strings; money values
are returned as decimal strings with their currency code.
For TEAMlink purchase bills, live API verification confirmed that the convention
<supplier-invoice-number> / <TEAMlink-orderId> is stored in Xero's
InvoiceNumber field (for example SYNTHETIC-BILL / TEST-REFERENCE), while Reference is empty.
Exact and batch searches therefore use Xero's native InvoiceNumbers filter. The
separate reference search remains available for records that use that field.
xero_batch_invoice_lookup.invoiceNumbers is a native JSON string array. Numeric-
looking identifiers are intentionally not coerced to numbers. The reported Hermes
coerce_tool_args defect is outside this repository and must also be corrected in
the Hermes runtime if that client still rewrites valid JSON arrays before sending
the MCP request. Until then, use scalar xero_lookup_invoice for exact single-value
lookups or xero_search_transactions for broader matching.
For Developers
Local development setup
git clone https://github.com/your-org/tn-xero-mcp-server.git
cd tn-xero-mcp-server
npm install
cp .env.example .env
# Edit .env with your credentials
npm run build
Linking to Claude Desktop for development
In your claude_desktop_config.json, point directly at the built file:
{
"mcpServers": {
"xero": {
"command": "node",
"args": ["C:/path/to\\Xero-MCP\\dist\\index.js"],
"env": {
"XERO_CLIENT_ID": "your_client_id_here",
"XERO_CLIENT_SECRET": "your_client_secret_here",
"XERO_ENABLE_PAYROLL": "false",
"XERO_DOWNLOAD_PATH": "C:\\Users\\you\\Downloads\\Xero"
}
}
}
}
Windows note: Backslashes in
argspaths must be escaped as\\.
Publishing updates
npm run build
npm publish
License
MIT
Security
Do not commit your .env file or any credentials to version control. The .gitignore excludes .env by default.
Environment variable reference
The server automatically loads .env from its working directory; environment variables already set by the client take precedence.
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.
| Variable | Required | Default | Purpose and accepted values |
|---|---|---|---|
DATETIMEFORMAT |
No | local |
Output date setting: local or an IANA timezone; shared by SSLStore and Xero. |
XERO_CLIENT_BEARER_TOKEN |
Alternative | unset |
Existing access token; use instead of a client ID/secret pair. Renew externally when expired. |
XERO_CLIENT_ID |
Alternative | unset |
Custom Connection client ID; must be set together with XERO_CLIENT_SECRET. |
XERO_CLIENT_SECRET |
Alternative | unset |
Custom Connection client secret; must be set together with XERO_CLIENT_ID. |
XERO_DOWNLOAD_PATH |
No | user Downloads directory |
Download destination; choose a private directory outside source control. |
XERO_ENABLE_PAYROLL |
No | false |
Literal true registers payroll tools; requires appropriate scopes. |
XERO_ENABLE_READWRITE |
Deprecated | unset |
Compatibility alias for XERO_READWRITE; canonical variable wins. |
XERO_ENABLE_REPORTS |
No | true |
Reports are enabled unless set to literal false. |
XERO_HTTP_ALLOWED_HOSTS |
Conditional | unset |
Comma-separated Host allowlist required for non-loopback HTTP; use the public hostnames accepted by the listener. |
XERO_HTTP_ALLOWED_ORIGINS |
No | unset |
Comma-separated browser Origin allowlist; configure when browser clients need access. |
XERO_HTTP_BEARER_TOKEN |
Conditional | unset |
Private bearer secret required for non-loopback HTTP; clients send Authorization: Bearer . |
XERO_HTTP_HOST |
No | 127.0.0.1 |
Listener bind address. Non-loopback binding requires a bearer token and explicit allowed hosts. |
XERO_HTTP_MAX_BODY_BYTES |
No | 1048576 |
Maximum HTTP request body; integer 1–16777216 bytes. |
XERO_HTTP_PORT |
No | 3000 |
HTTP listener port; integer 1–65535. |
XERO_READWRITE |
No | false |
Only true enables mutation tools; read-only is the default. Review each operation before use. |
XERO_TRANSPORT |
No | stdio |
stdio or http; HTTP serves /mcp and GET /health. |
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.
Agent first-use workflow
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.
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.
Repository and package privacy
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.
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.
Development and diagnostics
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.
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.