Token导航 LogoToken导航TokenDH.com
Business Central Mc Pserver logo
AI代理stdio官方级别未说明来源级核验

Business Central Mc Pserver

MCP Server

一个使用Microsoft Agent Framework直接连接Business Central的Python代理,支持跨平台和多种认证方式。

工具数

0

提示词数

0

GitHub Stars

7

资源数

0
跨平台PythonClaudeClaude DesktopClaudeVS Code

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

作者 / 组织

Bertverbeek4PS

提供方

Bertverbeek4PS

最后核验

2026/5/17 20:19

快速接入

先看主来源和安装命令,再打开仓库或文档;下面只保留这个条目的关键接入事实。

命令预览

pip install -r requirements.txt

详细介绍

商务中心MCP代理

Python代理使用 Microsoft代理框架 (语义内核ChatCompletionAgent)直接与Business Central连接。

✨ 特性

  • 直接连接 -不需要exe文件!直接连接到Business Central MCP HTTP端点
  • 交叉平台的 -适用于Windows、macOS和Linux
  • 灵活的身份验证 -支持设备代码流(委托)和客户端凭据(应用程序)
  • Microsoft代理框架 -使用语义内核ChatCompletionAgent模式

快速开始

  1. 安装依赖项:
pip install -r requirements.txt
  1. 配置 BusinessCentralMCP.env:
# Azure OpenAI
AZURE_OPENAI_API_KEY=your_key
AZURE_OPENAI_ENDPOINT=https://your-resource.openai.azure.com
AZURE_OPENAI_CHAT_DEPLOYMENT_NAME=gpt-4o

# Business Central
BC_TENANT_ID=your_tenant_id
BC_CLIENT_ID=your_client_id
# BC_CLIENT_SECRET=your_secret  # Optional - for service principal auth
BC_ENVIRONMENT_NAME=Production
BC_COMPANY_NAME=CRONUS International Ltd.
  1. :
python bc_direct_agent.py

身份验证选项:

  • 设备代码流(默认):交互式浏览器身份验证-代理提示您访问URL并输入代码
  • 客户端凭证流:添加 BC_CLIENT_SECRET 使用服务主体身份验证(无用户交互)

建筑

此实现遵循Microsoft代理框架模式:

User Question
    ↓
ChatCompletionAgent (Semantic Kernel)
    ↓
BusinessCentralMCPPlugin (@kernel_function decorators)
    ↓
MCP Client Session (stdio_client)
    ↓
BcMCPProxy.exe (MCP Server)
    ↓
Business Central API

关键组件

  1. 语义内核 -核心框架
  2. ChatCompletionAgent -代理人来自 semantic_kernel.agents
  3. BusinessCentralMCP插件 -插件与 @kernel_function 装饰器
  4. 功能选择行为。自动() -启用自动函数调用
  5. MCP客户端会话 -通过stdio连接到BC MCP服务器

先决条件

  1. 业务中心MCP服务器(BcMCPProxy.exe)

- 下载/构建来源:https://github.com/microsoft/BCTech/tree/master/samples/BcMCPProxy - 地方 BcMCPProxy.exe 在此目录或更新路径中 .env

  1. Azure AD应用程序注册

- 在Azure门户中创建应用注册 - 添加重定向URL: ms-appx-web://Microsoft.AAD.BrokerPlugin/ - 添加API权限: - Financials.ReadWrite.All (委托) - user_impersonation (委托)

  1. Python 3.10+
  1. Azure OpenAI或OpenAI API密钥

安装

  1. 克隆此存储库:
git clone 
cd BusinessCentralMCPserver
  1. 安装依赖项:
pip install -r requirements.txt
  1. 配置环境变量:

- 编辑 BusinessCentralMCP.env 并填写您的值: - Azure OpenAI凭据 - BC MCP服务器路径 - Azure租户/客户端ID - 不列颠哥伦比亚省环境和公司名称

配置

编辑 BusinessCentralMCP.env:

# Azure OpenAI
AZURE_OPENAI_API_KEY=your_key_here
AZURE_OPENAI_ENDPOINT=https://your-resource.openai.azure.com
AZURE_OPENAI_CHAT_DEPLOYMENT_NAME=your_deployment
AZURE_OPENAI_API_VERSION=2024-08-01-preview

# Business Central MCP Server
BC_MCP_SERVER_PATH=BcMCPProxy.exe
BC_TENANT_ID=your_tenant_id
BC_CLIENT_ID=your_client_id
BC_ENVIRONMENT_NAME=production
BC_COMPANY_NAME=CRONUS International Ltd.
BC_CONFIG_NAME=default

用法

运行代理:

python bc_mcp_agent.py

代理人将:

  1. 初始化语义内核
  2. 连接到BC MCP服务器
  3. 发现可用的BC工具
  4. 启动交互式聊天会话

交互示例

> What tools are available?
[Agent lists all BC MCP tools]

> Show me customer information
[Agent calls appropriate BC tool and displays results]

> List recent sales orders
[Agent queries BC and formats the response]

运作原理

Microsoft代理框架模式

此实现使用 精确模式 来自语义内核PlantRequestAgent参考:

  1. 内核设置
   kernel = Kernel()
   add_chat_service(kernel)  # Azure OpenAI or OpenAI
  1. 插件创建
   class BusinessCentralMCPPlugin:
       @kernel_function(description="...", name="...")
       async def call_bc_tool(self, tool_name: str, arguments: str) -> str:
           # Calls MCP server
  1. 插件注册
   kernel.add_plugin(bc_plugin, plugin_name="business_central")
  1. 代理创建
   agent = ChatCompletionAgent(
       name="BusinessCentralAgent",
       instructions=system_prompt,
       kernel=kernel,
       function_choice_behavior=FunctionChoiceBehavior.Auto()
   )
  1. 交互式循环
   async for response_item in agent.invoke(user_input):
       print(response_item.content, end="")

MCP连接

代理使用stdio(标准输入/输出)连接到BcMCPProxy.exe:

async with stdio_client(server_params) as (read, write):
    async with ClientSession(read, write) as session:
        await session.initialize()
        # Use session to call tools

与PlantRequestAgent的区别

PlantRequestAgent制作 直接HTTP API调用 前往商务中心:

async with httpx.AsyncClient() as client:
    response = await client.get(url, headers=headers)

此BC MCP代理通过 MCP服务器 相反:

result = await session.call_tool(tool_name, arguments=args_dict)

MCP方法的好处:

  • 抽象身份验证(由MCP服务器处理)
  • 简化了API访问
  • 与其他MCP客户端兼容(Claude Desktop、VS Code)
  • 集中式BC访问逻辑

故障排除

未找到MCP服务器

❌ Error: BC MCP Server not found at: BcMCPProxy.exe

解决方案:更新 BC_MCP_SERVER_PATH.env 包含BcMCPProxy.exe的完整路径

身份验证错误

❌ Error connecting to BC MCP Server: ...

解决方案:

  1. 检查Azure AD应用程序注册
  2. 验证重定向URL格式
  3. 确保授予API权限
  4. 确认租户/客户ID正确

连接超时

解决方案:

  1. 验证BC环境名称是否正确
  2. 检查公司名称(区分大小写)
  3. 测试与BC的网络连接

参考文献

  • BcMCP代理: https://github.com/microsoft/BCTech/tree/master/samples/BcMCPProxy
  • MCP协议: https://modelcontextprotocol.io/
  • 语义内核: https://learn.microsoft.com/en-us/semantic-kernel/
  • Microsoft代理框架:语义内核ChatCompletionAgent的组合

许可证

MIT许可证

目录标签

目录标签

跨平台PythonClaude商业中央本地部署Python代理MicrosoftAgentFramework认证管理

支持客户端

Claude DesktopClaudeVS Code

接入字段

传输方式(transport,传输协议)

stdio

鉴权方式(authType,认证方式)

session

工具数量(toolCount,工具数)

0

资源数量(resourceCount,资源数)

0

提示词数量(promptCount,提示词数)

0

权限和风险

stdiosession部署方式未说明

接入前请确认传输方式、认证方式和部署位置,并根据实际工具能力限制访问范围。

安装前确认

不要直接授予不必要的文件、网络或账号权限;先核对安装命令和配置内容。

来源信息

继续浏览同类 MCP