Xero MCP服务器
一种模型上下文协议(MCP)服务器实现,提供对Xero会计和业务功能的标准访问,通过MCP启用联系人管理、发票创建和账目管理等操作。
MCP 服务配置
复制以下 JSON 到 OPClaw 或其他 MCP 客户端的配置文件中即可使用
{
"mcpServers": {
"xero": {
"args": [
"insert-your-file-path-here/xero-mcp-server/dist/index.js"
],
"command": "node",
"env": {
"XERO_CLIENT_ID": "your_client_id_here",
"XERO_CLIENT_SECRET": "your_client_secret_here"
}
}
}
}
该服务需要配置环境变量:XERO_CLIENT_ID、XERO_CLIENT_SECRET
可用工具 (12 个)
该服务在 MCP 协议中暴露的工具,AI 可按需调用
list-contacts
List all contacts in Xero. This includes Suppliers and Customers.
该工具无需必填参数,直接调用即可
list-invoices 3 个参数 需填 1 项
List invoices in Xero. This includes Draft, Submitted, and Paid invoices. Ask the user if they want to see invoices for a specific contact, invoice number, or to see all invoices before running. Ask the user if they want the next page of invoices after running this tool if 10 invoices are returned. If they want the next page, call this tool again with the next page number and the contact or invoice number if one was provided in the previous call.
必填参数:page
create-contact 3 个参数 需填 1 项
Create a contact in Xero.
必填参数:name
create-invoice 3 个参数 需填 2 项
Create an invoice in Xero.
必填参数:contactId、lineItems
list-accounts
Lists all accounts in Xero. Use this tool to get the account codes and names to be used when creating invoices in Xero
该工具无需必填参数,直接调用即可
list-tax-rates
Lists all tax rates in Xero. Use this tool to get the tax rates to be used when creating invoices in Xero
该工具无需必填参数,直接调用即可
list-quotes 2 个参数 需填 1 项
List all quotes in Xero. Ask the user if they want to see quotes for a specific contact before running. Ask the user if they want the next page of quotes after running this tool if 10 quotes are returned. If they do, call this tool again with the page number and the contact provided in the previous call.
必填参数:page
create-quote 7 个参数 需填 2 项
Create a quote in Xero.
必填参数:contactId、lineItems
update-contact 7 个参数 需填 2 项
Update a contact in Xero.
必填参数:contactId、name
update-invoice 4 个参数 需填 1 项
Update an invoice in Xero. Only works on draft invoices.
必填参数:invoiceId
list-credit-notes 2 个参数 需填 1 项
List credit notes in Xero. Ask the user if they want to see credit notes for a specific contact, or to see all credit notes before running. Ask the user if they want the next page of credit notes after running this tool if 10 credit notes are returned. If they want the next page, call this tool again with the next page number and the contact if one was provided in the previous call.
必填参数:page
create-credit-note 3 个参数 需填 2 项
Create a credit note in Xero.
必填参数:contactId、lineItems
服务介绍
Xero MCP 服务器
这是一个为 Xero 实现的 Model Context Protocol (MCP) 服务器。它提供了 MCP 协议与 Xero API 之间的桥梁,允许以标准化的方式访问 Xero 的会计和业务功能。
功能
- Xero OAuth2 认证支持自定义连接
- 联系人管理
- 会计科目表管理
- 发票创建和管理
- 符合 MCP 协议
先决条件
- Node.js(v18 或更高版本)
- npm 或 pnpm
- 一个具有 API 凭据的 Xero 开发者账户
文档和链接
设置
创建 Xero 账户
如果您还没有 Xero 账户和组织,可以通过这里注册免费试用版来创建一个。
我们建议首先使用演示公司开始,因为它自带一些预加载的示例数据。登录后,通过左上角的下拉菜单选择“演示公司”切换到它。您可以在任何时候通过左上角的下拉菜单导航至我的 Xero重置演示公司的数据或更改国家。
注意:要使用特定于薪资的查询,地区应该是 NZ 或 UK。
认证
Xero MCP 服务器支持两种认证模式:
1. 自定义连接
这是测试和开发时更好的选择,允许您为特定组织指定客户端 ID 和密钥。
这也是将此集成到第三方 MCP 客户端(如 Claude Desktop)时推荐的方法。
配置您的 Xero 开发者账户
按照以下说明设置自定义连接:https://developer.xero.com/documentation/guides/oauth2/custom-connections/
目前所有会话都需要以下范围:scopes
将 MCP 服务器与 Claude Desktop 集成
要将 MCP 服务器添加到 Claude,请转到设置 > 开发者 > 编辑配置,并将以下内容添加到您的 claude_desktop_config.json 文件中:
{
"mcpServers": {
"xero": {
"command": "npx",
"args": ["-y", "@xeroapi/xero-mcp-server@latest"],
"env": {
"XERO_CLIENT_ID": "your_client_id_here",
"XERO_CLIENT_SECRET": "your_client_secret_here"
}
}
}
}
注意:如果您正在使用 Node Version Manager,请将 "command": "npx" 部分更改为可执行文件的完整路径,例如在 Mac / Linux 上为 your_home_directory/.nvm/versions/node/v22.14.0/bin/npx,在 Windows 上为 "your_home_directory\\.nvm\\versions\\node\\v22.14.0\\bin\\npx"
2. Bearer Token
如果要在运行时支持多个 Xero 账户并允许 MCP 客户端根据需要执行认证流程(如 PKCE),则这是更好的选择。
在这种情况下,请使用以下配置:
{
"mcpServers": {
"xero": {
"command": "npx",
"args": ["-y", "@xeroapi/xero-mcp-server@latest"],
"env": {
"XERO_CLIENT_BEARER_TOKEN": "your_bearer_token"
}
}
}
}
注意:如果已定义 XERO_CLIENT_BEARER_TOKEN,则它将优先于 XERO_CLIENT_ID。
可用的 MCP 命令
list-contacts: 从 Xero 获取联系人列表list-invoices: 获取发票列表list-accounts: 获取账户列表list-tax-rates: 获取税率列表list-quotes: 获取报价单列表list-credit-notes: 获取贷项通知单列表list-trial-balance: 获取试算平衡表list-profit-and-loss: 获取损益报告list-items: 获取项目列表list-bank-transactions: 获取银行账户交易列表list-payroll-employees: 获取工资单员工列表create-contact: 创建新联系人create-invoice: 创建新发票create-quote: 创建新报价单create-credit-note: 创建新贷项通知单update-contact: 更新现有联系人update-invoice: 更新现有的草稿发票update-quote: 更新现有的草稿报价单update-credit-note: 更新现有的草稿贷项通知单
有关详细的 API 文档,请参阅 MCP 协议规范。
开发者指南
安装
# Using npm
npm install
# Using pnpm
pnpm install
运行构建
# Using npm
npm run build
# Using pnpm
pnpm build
与 Claude Desktop 集成
要将您的 Xero MCP 服务器在开发中链接到 Claude Desktop,请转到设置 > 开发者 > 编辑配置,并将以下内容添加到您的 claude_desktop_config.json 文件中:
注意:对于 Windows 系统,请确保 args 路径中的反斜杠 \ 已经转义,例如 "C:\\projects\xero-mcp-server\\dist\\index.js"
{
"mcpServers": {
"xero": {
"command": "node",
"args": ["insert-your-file-path-here/xero-mcp-server/dist/index.js"],
"env": {
"XERO_CLIENT_ID": "your_client_id_here",
"XERO_CLIENT_SECRET": "your_client_secret_here"
}
}
}
}
许可证
MIT
安全性
请不要将您的 .env 文件或任何敏感凭据提交到版本控制系统(它已经被包含在 .gitignore 中作为安全默认设置。)