返回市场
MCP业务中心服务器

MCP业务中心服务器

作者:knowall-ai2 星标更新:2025-10-26

项目介绍

smithery 徽章

Microsoft Business Central MCP 服务器

<img width="1536" height="1024" alt="mcp-business-central" src="https://github.com/user-attachments/assets/13932bfd-a5b9-4668-a7cd-ac9549a09673" />

这是一个用于 Microsoft Dynamics 365 Business Central 的 Model Context Protocol (MCP) 服务器。它通过正确格式化的 API v2.0 调用,为 AI 助手提供对 Business Central 数据的直接访问。

特性

  • 正确的 API URL:使用 /companies(id)/resource 格式(没有 ODataV4 段)
  • 零安装:使用 npx 运行,无需预先安装
  • Azure CLI 认证:利用现有的 Azure CLI 认证
  • 简洁的工具名称:没有前缀,只有 get_schema, list_items
  • 完整的 CRUD 操作:创建、读取、更新和删除 Business Central 记录

安装

使用 npx(推荐)

无需安装!在 Claude Desktop 或 Claude Code 中进行配置:

{
  "mcpServers": {
    "business-central": {
      "type": "stdio",
      "command": "cmd",
      "args": ["/c", "npx", "-y", "@knowall-ai/mcp-business-central"],
      "env": {
        "BC_URL_SERVER": "https://api.businesscentral.dynamics.com/v2.0/{tenant-id}/{environment}/api/v2.0",
        "BC_COMPANY": "您的公司名称",
        "BC_AUTH_TYPE": "azure_cli"
      }
    }
  }
}

注意(Windows):如上所示,使用 cmd/c 来正确执行 npx。

使用 Smithery

通过 Smithery 安装:

npx -y @smithery/cli install @knowall-ai/mcp-business-central --client claude

本地开发

git clone https://github.com/knowall-ai/mcp-business-central.git
cd mcp-business-central
npm install
npm run build
node build/index.js

配置

环境变量

变量必需描述示例
BC_URL_SERVERBusiness Central API 基础 URLhttps://api.businesscentral.dynamics.com/v2.0/{tenant}/Production/api/v2.0
BC_COMPANY公司显示名称KnowAll Ltd
BC_AUTH_TYPE认证类型(默认:azure_cliazure_cli

获取配置值

  1. 租户 ID:在 Azure 门户 → Azure Active Directory → 概述中找到
  2. 环境:通常是 ProductionSandbox
  3. 公司名称:在 Business Central 中显示的名称

示例 URL 格式:

https://api.businesscentral.dynamics.com/v2.0/00000000-0000-0000-0000-000000000000/Production/api/v2.0

先决条件

可用工具

1. get_schema

获取 Business Central 资源的 OData 元数据。

参数:

  • resource (字符串,必需):资源名称(例如,customers, contacts, salesOpportunities

示例:

{
  "resource": "customers"
}

2. list_items

列出项目,可选过滤和分页。

参数:

  • resource (字符串,必需):资源名称
  • filter (字符串,可选):OData 过滤表达式
  • top (数字,可选):返回的最大项目数
  • skip (数字,可选):跳过的项目数以实现分页

示例:

{
  "resource": "customers",
  "filter": "displayName eq 'Contoso'",
  "top": 10
}

3. get_items_by_field

根据特定字段值获取项目。

参数:

  • resource (字符串,必需):资源名称
  • field (字符串,必需):要筛选的字段名称
  • value (字符串,必需):匹配值

示例:

{
  "resource": "contacts",
  "field": "companyName",
  "value": "Contoso Ltd"
}

4. create_item

在 Business Central 中创建新项目。

参数:

  • resource (字符串,必需):资源名称
  • item_data (对象,必需):要创建的项目数据

示例:

{
  "resource": "contacts",
  "item_data": {
    "displayName": "John Doe",
    "companyName": "Contoso Ltd",
    "email": "john.doe@contoso.com"
  }
}

5. update_item

更新现有项目。

参数:

  • resource (字符串,必需):资源名称
  • item_id (字符串,必需):项目 ID(GUID)
  • item_data (对象,必需):要更新的字段

示例:

{
  "resource": "customers",
  "item_id": "1366066e-7688-f011-b9d1-6045bde9b95f",
  "item_data": {
    "displayName": "更新后的名称"
  }
}

6. delete_item

从 Business Central 删除项目。

参数:

  • resource (字符串,必需):资源名称
  • item_id (字符串,必需):项目 ID(GUID)

示例:

{
  "resource": "contacts",
  "item_id": "a1b2c3d4-e5f6-g7h8-i9j0-k1l2m3n4o5p6"
}

常见资源

  • companies - 公司信息
  • customers - 客户记录
  • contacts - 联系人记录
  • salesOpportunities - 销售机会
  • salesQuotes - 销售报价
  • salesOrders - 销售订单
  • salesInvoices - 销售发票
  • items - 产品/服务项目
  • vendors - 供应商记录

故障排除

401 未授权

  • 确保 Azure CLI 已登录:az login
  • 验证您是否有权限访问租户中的 Business Central
  • 测试令牌检索:az account get-access-token --resource https://api.businesscentral.dynamics.com

公司未找到

  • 检查公司名称是否完全匹配(区分大小写)
  • 验证公司是否存在:访问 Business Central Web UI
  • 确保 URL 包含正确的租户 ID 和环境

资源未找到

  • 检查资源名称拼写(例如,customers 而不是 customer
  • 某些资源可能在您的 Business Central 版本中不可用
  • 使用 get_schema 探索可用资源

开发

# 安装依赖
npm install

# 构建 TypeScript
npm run build

# 开发监视模式
npm run dev

许可证

MIT

贡献

欢迎在 https://github.com/knowall-ai/mcp-business-central 提交问题和拉取请求

相关项目