xero-mcp-server

xero-mcp-server

An MCP server that enables AI assistants to read and write Xero accounting data, including invoices, contacts, accounts, and payments, through natural language.

Category
访问服务器

README

Xero MCP Server

CI Verified by MCPForge License: MIT

A production-ready Model Context Protocol server for the Xero Accounting API.

This template lets Claude Desktop, Cursor, Windsurf, and other MCP-compatible clients read and write accounting data through controlled Xero tools.

Built as a starter template for teams that want a secure baseline before adding company-specific accounting workflows.

Who this is for

This repository is useful for:

  • developers building AI accounting assistants,
  • finance teams experimenting with MCP workflows,
  • SaaS teams connecting Xero to internal AI agents,
  • platform engineers who need a clean TypeScript MCP server example,
  • agencies building custom Xero automations for clients.

Features

  • TypeScript + Express MCP server
  • Xero OAuth 2.0 authorization flow
  • Refresh-token support
  • API key protection for /mcp
  • Rate limiting for MCP requests
  • Health endpoint at /health
  • Structured Pino logging
  • Zod-based environment validation
  • MCP tools for invoices, contacts, accounts, and payments
  • Jest test setup with Supertest
  • GitHub Actions CI workflow

Architecture

flowchart LR
  A[Claude / Cursor / MCP Client] -->|POST /mcp| B[Express MCP Server]
  B --> C[API Key Guard]
  C --> D[Rate Limit Middleware]
  D --> E[MCP Tools]
  E --> F[Xero Client]
  F -->|OAuth Bearer Token| G[Xero Accounting API]
  H[Browser] -->|GET /auth/xero| I[Xero OAuth]
  I --> J[Token Store]
  J --> F
  K[MCPForge Verify] --> B

See the larger diagram in docs/architecture.md.

Available MCP tools

Tool Purpose
xero_list_invoices List invoices with optional status, contact, and page filters.
xero_create_invoice Create a draft or authorised sales invoice / bill.
xero_list_contacts Search and list customers or suppliers.
xero_get_account Fetch a chart-of-accounts entry by code or UUID.
xero_list_accounts List accounts filtered by type and status.
xero_create_payment Record a payment against an authorised invoice.

Quick start

1. Install dependencies

npm ci

2. Configure environment

cp .env.example .env

Edit .env:

PORT=3000
NODE_ENV=development
LOG_LEVEL=info
SERVER_BASE_URL=http://localhost:3000

MCP_API_KEY=replace-with-a-long-random-secret

XERO_CLIENT_ID=your-xero-client-id
XERO_CLIENT_SECRET=your-xero-client-secret
XERO_REDIRECT_URI=http://localhost:3000/auth/xero/callback
XERO_SCOPES="openid profile email accounting.transactions accounting.contacts accounting.settings offline_access"

RATE_LIMIT_WINDOW_MS=900000
RATE_LIMIT_MAX=100

3. Run locally

npm run dev

4. Authorize Xero

Open this URL in your browser:

http://localhost:3000/auth/xero

After successful authorization, check status:

curl http://localhost:3000/auth/status

5. Check health

curl http://localhost:3000/health

Xero OAuth setup

In the Xero Developer Portal:

  1. Create a new app.
  2. Add this redirect URI:
http://localhost:3000/auth/xero/callback
  1. Copy the client ID and client secret into .env.
  2. Make sure your app has access to the scopes used by this server:
openid profile email accounting.transactions accounting.contacts accounting.settings offline_access

For production, set XERO_REDIRECT_URI to your deployed callback URL, for example:

https://your-domain.com/auth/xero/callback

Connect to Claude Desktop

Build the server first:

npm run build

Then add an MCP server entry in your Claude Desktop configuration.

Example for a local HTTP MCP endpoint:

{
  "mcpServers": {
    "xero": {
      "url": "http://localhost:3000/mcp",
      "headers": {
        "X-API-Key": "replace-with-your-mcp-api-key"
      }
    }
  }
}

Restart Claude Desktop after editing the configuration.

Connect to Cursor

In Cursor, add a new MCP server using the HTTP endpoint:

{
  "name": "xero",
  "url": "http://localhost:3000/mcp",
  "headers": {
    "X-API-Key": "replace-with-your-mcp-api-key"
  }
}

Then restart Cursor or reload the MCP server list.

Security notes

This template is intentionally safer than a minimal demo, but you should still harden it before production use.

Recommended production changes:

  • Replace the in-memory token store in src/auth.ts with Redis, Postgres, or another encrypted durable store.
  • Store secrets in a managed secret manager, not in plain .env files.
  • Rotate MCP_API_KEY regularly.
  • Add per-user or per-tenant authorization if multiple users will access the server.
  • Restrict write tools such as xero_create_invoice and xero_create_payment behind approvals.
  • Add audit logs for every tool call.
  • Use HTTPS in production.
  • Review scopes and remove anything your use case does not need.

Security Review

You can verify this MCP server with MCPForge:

https://www.mcpforge.tech/verify

MCPForge can help review:

  • exposed tools,
  • authentication behavior,
  • health checks,
  • compatibility with MCP clients,
  • risk level of write operations,
  • security posture before publishing or deployment.

After verification, you can link your public report from this README:

[![Verified by MCPForge](https://www.mcpforge.tech/api/badge/verified/xero-mcp-server)](https://www.mcpforge.tech/verified/xero-mcp-server)

Full MCPForge guide:

https://www.mcpforge.tech/blog/xero-mcp-server

Deployment

A common production setup:

  1. Deploy this service to Railway, Render, Fly.io, AWS, GCP, Azure, or a private Kubernetes cluster.
  2. Configure environment variables in the hosting provider.
  3. Set SERVER_BASE_URL to your public HTTPS URL.
  4. Set XERO_REDIRECT_URI to https://your-domain.com/auth/xero/callback.
  5. Add the same callback URL in the Xero Developer Portal.
  6. Run the OAuth flow once to connect the Xero tenant.
  7. Verify /health and /mcp before connecting production AI clients.
  8. Run a public or private verification with MCPForge.

Local development commands

npm run lint
npm run typecheck
npm test
npm run build

API endpoints

Method Path Description
GET /health Health and Xero connectivity check.
GET /auth/xero Start Xero OAuth authorization.
GET /auth/xero/callback Xero OAuth callback.
GET /auth/status Current authorization status.
POST /mcp MCP endpoint protected by X-API-Key.

Repository checklist

Before publishing your fork:

  • [ ] Replace your-org in the CI badge URL.
  • [ ] Replace the MCPForge badge slug if your public slug is not xero-mcp-server.
  • [ ] Replace the blog link with your final MCPForge article URL.
  • [ ] Add screenshots or a real verification report once available.
  • [ ] Configure production token storage.
  • [ ] Review Xero scopes.

License

MIT — see LICENSE.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选