项目简介 Power Platform MCP服务器是一个后端应用,它遵循Model Context Protocol (MCP),旨在为大型语言模型(LLM)客户端提供标准化的接口,以访问Microsoft Power Platform服务。通过这个服务器,LLM可以调用预定义的工具,与Dataverse数据库进行交互,或者管理和查询Power Automate流的运行状态。它特别适用于需要LLM代理与Microsoft业务应用生态系统集成的场景。
主要功能点
- Dataverse 工具集成: 提供了多种工具来与Dataverse环境交互,包括:
- 查询插件跟踪日志('GetPluginTraceLogs')。
- 执行通用的OData GET请求来检索Dataverse实体数据('Get')。
- 激活或停用Dataverse工作流('ActivateWorkflow')。
- 获取Dataverse中可用实体的列表('GetEntityList')。
- 获取特定实体的详细元数据,包括属性和关系('GetEntityMetadata')。
- Power Automate 工具集成: 提供了多种工具来管理和查询Power Automate流:
- 列出Power Automate流的触发器('GetFlowTriggers')。
- 获取手动触发流的回调URL('GetManualTriggerCallbackUrl')。
- 列出Power Automate流的运行历史('GetFlowRuns')。
- 获取特定流运行的详细信息('GetFlowRunDetails')。
- 列出特定流运行中的动作(步骤)('GetFlowRunActions')。
- 列出流触发器的历史记录('GetTriggerHistories')。
- 安全认证: 使用Azure AD的'DefaultAzureCredential'进行身份验证,支持通过'az login'等方式获取令牌,确保对Power Platform服务的安全访问。
- MCP协议支持: 作为MCP服务器,它通过JSON-RPC协议与客户端通信,并支持Stdio传输协议。
安装步骤
- 前提条件:
- 安装 .NET 10 SDK。
- 安装 Azure CLI 并登录 ('az login'),确保有权限访问目标Dataverse环境和Power Automate流。
- 对Dataverse环境具有读取'plugintracelogs'表的权限。
- 构建项目:
- 克隆此GitHub仓库:'git clone https://github.com/Cliveo/Power-Platform-MCP.git'
- 打开终端或命令行,导航到仓库根目录。
- 运行以下命令构建服务器:
dotnet build .\MyMCP\MyMCP.csproj -c Release - 构建成功后,可执行文件会在 '.\MyMCP\bin\Release\net10.0' 目录下。
服务器配置 (供MCP客户端使用) MCP客户端(如GitHub Copilot Agent)需要配置如何启动和连接此MCP服务器。以下是一个JSON格式的配置示例,您需要根据实际环境调整其中的参数。请将'<PATH_TO_YOUR_PROJECT>'替换为您克隆仓库的实际路径。
{ "server": { "name": "Power Platform MCP", "command": "dotnet", "args": [ "<PATH_TO_YOUR_PROJECT>/MyMCP/bin/Release/net10.0/MyMCP.dll" ], "environmentVariables": { // 可选:如果需要设置特定的环境变量,例如用于调试或测试 // "ASPNETCORE_ENVIRONMENT": "Development" }, "cwd": "<PATH_TO_YOUR_PROJECT>/MyMCP/bin/Release/net10.0/" // 服务器的工作目录,确保指向可执行文件所在目录 }, "tools": [ { "name": "MyMCP.GetPluginTraceLogs", "displayName": "获取Dataverse插件跟踪日志", "description": "使用Managed Identity/az登录查询Dataverse插件跟踪日志。", "parameters": { "orgUrl": { "type": "string", "description": "Dataverse组织URL,例如 https://contoso.crm.dynamics.com", "required": true }, "top": { "type": "integer", "description": "最大返回日志记录数 (默认25)", "default": 25 }, "filter": { "type": "string", "description": "可选的OData过滤器,例如 'messagename eq 'Create''" } } }, { "name": "MyMCP.Get", "displayName": "通用Dataverse OData GET", "description": "使用格式化值进行通用Dataverse OData GET。返回原始JSON。", "parameters": { "orgUrl": { "type": "string", "description": "Dataverse组织URL", "required": true }, "tableSetName": { "type": "string", "description": "表集名称,例如 contacts, accounts, plugintracelogs", "required": true }, "select": { "type": "string", "description": "$select子句,逗号分隔" }, "filter": { "type": "string", "description": "$filter OData过滤表达式" }, "top": { "type": "integer", "description": "$top最大记录数" }, "expand": { "type": "string", "description": "$expand关联实体" }, "orderby": { "type": "string", "description": "$orderby子句" }, "apply": { "type": "string", "description": "$apply转换,例如 groupby 或 aggregate" }, "count": { "type": "boolean", "description": "包含 $count=true", "default": false } } }, { "name": "MyMCP.ActivateWorkflow", "displayName": "激活/停用Dataverse工作流", "description": "使用SetState激活或停用工作流。当activate=true -> state=1/status=2;当false -> state=0/status=1。", "parameters": { "orgUrl": { "type": "string", "description": "Dataverse组织URL", "required": true }, "workflowId": { "type": "string", "description": "要激活/停用的工作流GUID", "required": true }, "activate": { "type": "boolean", "description": "true为激活,false为停用", "default": true } } }, { "name": "MyMCP.GetEntityList", "displayName": "获取Dataverse实体列表", "description": "获取Dataverse中可用实体(表)的列表。返回EntityDefinitions元数据。", "parameters": { "orgUrl": { "type": "string", "description": "Dataverse组织URL", "required": true } } }, { "name": "MyMCP.GetEntityMetadata", "displayName": "获取Dataverse实体元数据", "description": "获取特定实体的详细元数据,包括属性和关系。", "parameters": { "orgUrl": { "type": "string", "description": "Dataverse组织URL", "required": true }, "entityLogicalName": { "type": "string", "description": "实体逻辑名称,例如 contact, account, opportunity", "required": true }, "includeAttributes": { "type": "boolean", "description": "包含属性定义 (默认true)", "default": true }, "includeRelationships": { "type": "boolean", "description": "包含关系定义 (默认false)", "default": false } } }, { "name": "MyMCP.GetFlowTriggers", "displayName": "获取Power Automate流触发器", "description": "列出Power Automate流的触发器。", "parameters": { "flowApiBaseUrl": { "type": "string", "description": "Flow API基本URL,例如 https://australia.api.flow.microsoft.com", "required": true }, "environmentId": { "type": "string", "description": "环境ID (GUID或名称) 例如 Default-xxxx", "required": true }, "flowId": { "type": "string", "description": "流ID (GUID)", "required": true } } }, { "name": "MyMCP.GetManualTriggerCallbackUrl", "displayName": "获取手动触发流的回调URL", "description": "获取流的手动(HTTP)触发器的回调URL。", "parameters": { "flowApiBaseUrl": { "type": "string", "description": "Flow API基本URL", "required": true }, "environmentId": { "type": "string", "description": "环境ID", "required": true }, "flowId": { "type": "string", "description": "流ID", "required": true }, "triggerName": { "type": "string", "description": "触发器名称 (默认 'manual')", "default": "manual" } } }, { "name": "MyMCP.GetFlowRuns", "displayName": "获取Power Automate流运行历史", "description": "列出Power Automate流的运行(执行历史)。", "parameters": { "flowApiBaseUrl": { "type": "string", "description": "Flow API基本URL", "required": true }, "environmentId": { "type": "string", "description": "环境ID", "required": true }, "flowId": { "type": "string", "description": "流ID", "required": true }, "since": { "type": "string", "description": "可选的UTC下限。包含StartTime大于此值的运行(例如,2025-09-08T00:00:00Z)。" }, "status": { "type": "string", "description": "可选的状态过滤器: Succeeded, Failed, Canceled, Running, 或 All (默认)。" } } }, { "name": "MyMCP.GetFlowRunDetails", "displayName": "获取特定流运行详情", "description": "获取特定流运行的详细信息。", "parameters": { "flowApiBaseUrl": { "type": "string", "description": "Flow API基本URL", "required": true }, "environmentId": { "type": "string", "description": "环境ID", "required": true }, "flowId": { "type": "string", "description": "流ID", "required": true }, "runName": { "type": "string", "description": "运行名称(来自运行列表)", "required": true } } }, { "name": "MyMCP.GetFlowRunActions", "displayName": "获取特定流运行的动作", "description": "列出特定流运行的动作(步骤)。", "parameters": { "flowApiBaseUrl": { "type": "string", "description": "Flow API基本URL", "required": true }, "environmentId": { "type": "string", "description": "环境ID", "required": true }, "flowId": { "type": "string", "description": "流ID", "required": true }, "runName": { "type": "string", "description": "运行名称(来自运行列表)", "required": true } } }, { "name": "MyMCP.GetTriggerHistories", "displayName": "获取流触发器历史", "description": "列出流触发器的历史记录。", "parameters": { "flowApiBaseUrl": { "type": "string", "description": "Flow API基本URL", "required": true }, "environmentId": { "type": "string", "description": "环境ID", "required": true }, "flowId": { "type": "string", "description": "流ID", "required": true }, "triggerName": { "type": "string", "description": "触发器名称 (默认 'manual')", "default": "manual" } } } ] }
基本使用方法
- 启动服务器: MCP客户端(如GitHub Copilot Agent)会根据上述配置自动启动Power Platform MCP服务器。
- LLM调用工具: 在LLM应用中,您可以提示LLM使用服务器暴露的工具。例如,如果LLM需要查询Dataverse插件日志,它可能会生成一个调用'MyMCP.GetPluginTraceLogs'工具的请求,并提供'orgUrl'、'top'、'filter'等参数。
- 接收结果: 服务器执行工具后,会将结果(通常是JSON格式)通过MCP协议返回给LLM客户端。LLM可以解析这些结果并用于进一步的交互或决策。
信息
分类
商业系统