business-central-mcp-server
business-central-mcp-server
一个 MCP 服务器,将 Dynamics 365 Business Central(在线)数据暴露给 MCP 客户端(Claude Code、Claude Desktop 等)——环境、公司,以及通过标准 v2.0 API 或自定义 AL API 可访问的任何实体。
它使用针对同一受众的 Entra 令牌与 api.businesscentral.dynamics.com 通信。使用委托身份验证(interactive / cli / azure-powershell)时,无需应用注册,也无需管理员同意——它以已登录用户的身份运行,受该用户的 Business Central 权限集约束。
工具
读取(始终开启)
工具 | 用途 |
| 列出租户中的 BC 环境(生产环境 + 沙盒)。 |
| 列出环境中的公司(法人实体);id 供实体工具使用。 |
| 列出 API 路由上的实体集(customers、items、salesInvoices 等)。 |
| 对实体集执行 OData 查询—— |
| 按 id(GUID)获取单条记录,包括其 |
从 AL 扩展发布的自定义 API 可通过 api_route: "{publisher}/{group}/{version}" 在任何地方访问。
导出文档
Business Central 将生成的文档和上传的文件作为 OData 媒体流提供,而不是 JSON 字段。export_file 获取这些字节并将其写入磁盘;该工具返回路径、大小和 SHA-256,而不是内容,因此大型 PDF 永远不会进入模型的上下文。它只从 BC 读取,但由于它写入本地文件系统,因此注册在写入层——设置 BC_MCP_MODE=write 以使用它。
先检查媒体链接,然后下载:
// get_entity — confirm the invoice has a renderable PDF
{ "entity_set": "salesInvoices", "record_id": "<guid>", "sub_path": "pdfDocument" }
// export_file — write the bytes out
{
"entity_set": "salesInvoices",
"record_id": "<guid>",
"sub_path": "pdfDocument/pdfDocumentContent",
"output_path": "./exports"
}有用的媒体路径:salesInvoices、salesCreditMemos 和 purchaseInvoices 上的 pdfDocument/pdfDocumentContent;attachments 上的 content;items 和 employees 上的 picture。
output_path 可以是文件或目录——目录(或尾部分隔符)表示文件名根据记录和嗅探到的内容类型派生。完全省略它则回退到 BC_EXPORT_DIR,然后是工作目录。除非传递 overwrite: true,否则不会覆盖现有文件,并且超过 max_bytes(默认 64 MiB)的下载会在写入任何内容之前被拒绝。
写入(BC_MCP_MODE=write)
工具 | 用途 |
| 插入记录(customer、item、sales order 等)。 |
| 对记录执行 PATCH 字段, |
| 调用绑定操作—— |
| 将文档(发票 PDF、附件、图片)下载到本地文件。 |
每次写入调用都会以时间戳、工具、目标和调用者身份记录到 stderr。这些操作会修改真实的 ERP 数据——过账文档会创建无法简单删除的会计条目。实验时请将 BC_DEFAULT_ENVIRONMENT 指向沙盒。
破坏性(BC_MCP_MODE=write 且 BC_MCP_ALLOW_DELETE=true)
工具 | 用途 |
| 永久删除记录。两步:dry_run → confirm_token → apply。 |
破坏性层默认关闭。启用后,每次调用首先是一个计划:dry_run=true(默认)返回将被删除的记录以及一次性 confirm_token;只有第二次调用 dry_run=false 并使用该令牌才会执行删除,并由 If-Match etag 保护。
Related MCP server: Microsoft Business Central MCP Server
在 Claude Desktop 中安装
从最新版本下载 business-central-mcp-server-<version>.mcpb 并打开它。这就是整个安装过程——无需克隆、无需 npm install、无需在机器上安装 Node。Claude Desktop 自带 Node 运行时,捆绑包携带其依赖项。
安装对话框收集:
字段 | 必填 | 说明 |
Entra tenant ID | 是 | 你的 Business Central 所在的租户 GUID。 |
Export folder | 是 |
|
Sign-in method | 否 | 默认为 |
Server mode | 否 |
|
Allow record deletion | 否 | 默认关闭。需要写入模式;没有写入模式则忽略。 |
Default environment | 否 | 跳过每次调用时传递 |
Default company ID | 否 | 跳过每次调用时传递 |
Client ID / secret | 否 | 仅限服务主体登录。密钥由操作系统凭据管理器保存。 |
Token scope / API base | 否 | 仅限主权云或嵌入式 ISV 部署。 |
使用默认的 interactive 登录时,请将客户端 ID 和密钥留空。服务器回退到公共 Azure CLI 客户端,打开你的浏览器,并以已登录用户的身份在该用户的 Business Central 权限集下运行。无需进行应用注册,也无需安排管理员同意。
每次 Claude Desktop 重启时都会出现浏览器提示。令牌仅保存在内存中;持久化它们需要原生凭据缓存模块和每个平台单独的捆绑包。
自行构建捆绑包
npm ci
npm run build:mcpb # writes dist/business-central-mcp-server-<version>.mcpb
npm run verify:mcpb # unpacks it and boots the server the way Desktop wouldbuild:mcpb 拒绝生成清单版本与 package.json 不一致,或声明的工具列表与服务器实际注册的工具不一致的捆绑包。
设置(Claude Code 和其他 MCP 客户端)
cd business-central-mcp-server
npm install将其注册到你的 MCP 客户端。示例 .claude.json 条目(委托身份验证,只读):
{
"mcpServers": {
"business-central": {
"type": "stdio",
"command": "node",
"args": ["/absolute/path/to/business-central-mcp-server/index.js"],
"env": {
"AZURE_TENANT_ID": "<your-entra-tenant-id>",
"BC_AUTH_MODE": "interactive",
"BC_MCP_MODE": "read",
"BC_DEFAULT_ENVIRONMENT": "Production"
}
}
}
}要允许创建/更新记录和调用绑定操作,请设置 "BC_MCP_MODE": "write"。要同时允许删除,请添加 "BC_MCP_ALLOW_DELETE": "true"。
如果你在单一公司工作并希望省略每次调用中的 company_id,请将 BC_DEFAULT_COMPANY_ID 设置为 list_companies 中的值。
设置 BC_EXPORT_DIR 以选择当调用省略 output_path 时 export_file 的写入位置。
有关环境变量的完整列表(包括所有支持的身份验证模式),请参阅 .env.example。
身份验证说明
委托(推荐):
interactive、device-code、cli或azure-powershell。无需应用注册;调用者以已登录用户身份运行,受该用户的 BC 权限集和公司访问权限限制。服务主体: 非交互式,但 SP 必须注册为 Business Central 内部的 Entra 应用程序(Entra 应用程序页面,并分配权限集),数据平面才会接受它。
list_environments使用管理中心发现 API,这还需要 BC 管理中心访问权限。如果你直接传递环境名称,其他工具无需它即可工作。
要求
目标租户中具有 Business Central 许可的 Entra 身份。
如果从源代码运行,需要 Node.js >= 20。Claude Desktop 捆绑包没有此要求;Desktop 提供运行时。
许可证
MIT — 参见 LICENSE。
This server cannot be deployed
Maintenance
Related MCP Connectors
Managed MCP gateway with OAuth, per-agent permissions, shared accounts and activity logs.
Provide seamless access to Appfolio Property Manager Reporting API through a standardized MCP serv…
Governed MCP gateway: one endpoint for your tools, with credential custody and audit log.
Query, browse, and automate OmegaAI workspaces from any MCP client. Streamable HTTP with OAuth 2.0.
Related MCP Servers
- AlicenseBqualityDmaintenanceEnables MCP clients to interact with Microsoft Dynamics 365 Business Central entities, providing tools to get schemas, list, create, update, and delete records.6MIT
- AlicenseAqualityCmaintenanceModel Context Protocol (MCP) server for Microsoft Dynamics 365 Business Central. Provides AI assistants with direct access to Business Central data through properly formatted API v2.0 calls.6441 npm10MIT
- AlicenseNot gradedqualityDmaintenanceEnables MCP clients to access and manage Microsoft Dynamics 365 Business Central entities, such as creating sales orders, via a modern async MCP server.MIT
- AlicenseAqualityDmaintenanceMCP server for Microsoft Dynamics 365 Business Central that enables AI assistants to query and manage Business Central data via full CRUD operations.6441 npmMIT