关于 powerplatform mcp/cli
PowerPlatform MCP / CLI 是一个 MCP 服务兼独立命令行工具,用于查询并配置 PowerPlatform / Dataverse 环境,支持多环境管理。面向需要探索或自动化配置 Power Platform 环境的开发者与管理员。
主要功能
- 01支持多环境配置与切换
- 02查询实体、记录、插件、流和解决方案
- 03提供写入操作以自动化环境配置
- 04CLI 将完整结果缓存到文件系统
适用场景
- 01在 AI 客户端中交互式探索 Dataverse 实体与插件
- 02通过 CLI 导出大量结果供后续分析
- 03批量创建自定义 API、环境变量或安全角色
MCP 相关
该项目是 MCP 服务,向 AI 客户端提供约 67 个工具,涵盖实体、记录、插件、Power Automate 流、解决方案、安全角色等操作。
配置
本地服务的配置在各客户端中通用,复制后粘贴到客户端的 MCP 配置文件即可。
npx -y powerplatform-mcpPOWERPLATFORM_ENVIRONMENTSPOWERPLATFORM_DEV_URLPOWERPLATFORM_DEV_CLIENT_IDPOWERPLATFORM_DEV_CLIENT_SECRET密钥POWERPLATFORM_DEV_TENANT_IDPOWERPLATFORM_UAT_URLPOWERPLATFORM_UAT_CLIENT_IDPOWERPLATFORM_UAT_CLIENT_SECRET密钥POWERPLATFORM_UAT_TENANT_ID本地服务需要在你的电脑上安装运行环境(如 Node.js 18+)。各客户端的配置文件位置不同,请参考客户端文档。
工具
本地服务需要在你的电脑上运行后才能读取工具,维护者暂未提供工具列表。
详细介绍
PowerPlatform MCP / CLI
用于查询和配置 PowerPlatform / Dataverse 环境的 Model Context Protocol(MCP)服务和独立 CLI。支持多个环境、实体元数据、记录、插件、流、解决方案、工作流、业务规则、安全角色、自定义 API、Web 资源等,还包括用于自动化环境设置的写入操作。
为什么同时提供 MCP 和 CLI?
MCP 可直接与 AI 客户端(Claude、Cursor、GitHub Copilot)集成,以交互式对话的方式探索环境。
CLI 会将结果写入文件系统缓存,而不是以内联方式返回。MCP 工具响应受 AI 客户端上下文窗口的限制;查询包含数百个实体、流或插件步骤的环境时,结果可能被截断或质量下降。CLI 通过将完整结果持久化到磁盘,避免了这一限制,让后续分析可以使用这些结果,而不会占用上下文窗口。两种接口共用相同的工具和功能。
安装
需要 Node.js 22+(< 25)。
MCP 服务
npm install -g powerplatform-mcp
# or
npx powerplatform-mcp
CLI
npm install -g powerplatform-cli
# or
npx powerplatform-cli
Docker
# MCP Server
docker pull ghcr.io/michsob/powerplatform-mcp
docker run --env-file .env ghcr.io/michsob/powerplatform-mcp
# CLI
docker pull ghcr.io/michsob/powerplatform-cli
docker run --env-file .env ghcr.io/michsob/powerplatform-cli entity-attributes account
配置
该工具支持多个环境。通过环境变量定义它们:
POWERPLATFORM_ENVIRONMENTS=DEV,UAT,PROD
# For each environment, set:
POWERPLATFORM_DEV_URL=https://dev-org.crm.dynamics.com
POWERPLATFORM_DEV_CLIENT_ID=your-client-id
POWERPLATFORM_DEV_CLIENT_SECRET=your-client-secret
POWERPLATFORM_DEV_TENANT_ID=your-tenant-id
POWERPLATFORM_UAT_URL=https://uat-org.crm.dynamics.com
POWERPLATFORM_UAT_CLIENT_ID=...
POWERPLATFORM_UAT_CLIENT_SECRET=...
POWERPLATFORM_UAT_TENANT_ID=...
本地开发时,将 .env.example 复制为 .env,并填写凭据。
MCP 服务
MCP 服务专为 AI 驱动的客户端(Claude、Cursor、GitHub Copilot)设计。
可用的 MCP 工具(67 个)
所有工具都接受可选的 environment 参数,用于指定目标环境(默认为第一个已配置的环境)。
实体
| 工具 | 描述 | 必填参数 | 可选参数 |
|---|---|---|---|
get-entity-metadata | 获取实体元数据 | entityName | |
get-entity-attributes | 列出所有属性/字段 | entityName | |
get-entity-attribute | 获取特定属性 | entityName、attributeName | |
get-entity-relationships | 获取 1:N 和 N:N 关系 | entityName | |
create-entity-string-attribute | 创建单行文本列 | entityName、schemaName、displayName | maxLength、requiredLevel、description、solutionName |
get-entity-keys | 列出实体上的备用键 | entityName | |
create-entity-alternate-key | 创建备用键 | entityName、schemaName、displayName、keyAttributes | solutionName |
记录
| 工具 | 描述 | 必填参数 | 可选参数 |
|---|---|---|---|
get-record | 按 ID 获取记录 | entityNamePlural、recordId | |
query-records | OData 查询 | entityNamePlural、filter | maxRecords(默认值为 50) |
插件
| 工具 | 描述 | 必填参数 | 可选参数 |
|---|---|---|---|
get-plugin-assemblies | 列出插件程序集 | includeManaged、maxRecords | |
get-plugin-assembly-complete | 获取包含类型、步骤和图像的程序集 | assemblyName | includeDisabled |
get-entity-plugin-pipeline | 获取在实体上执行的插件 | entityName | messageFilter、includeDisabled |
get-plugin-trace-logs | 获取插件跟踪日志 | entityName、messageName、correlationId、pluginStepId、exceptionOnly、hoursBack、maxRecords | |
get-all-plugin-steps | 获取所有 SDK 消息处理步骤 | includeDisabled、maxRecords | |
get-plugin-type | 按类名查找插件类型 | typeName | |
get-sdk-message | 按名称查找 SDK 消息 | messageName | |
create-plugin-step | 注册插件步骤 | name、pluginTypeId、sdkMessageId、stage、mode | rank、supportedDeployment、description、configuration、sdkMessageFilterId、solutionName |
流(Power Automate)
| 工具 | 描述 | 必需参数 | 可选参数 |
|---|---|---|---|
get-flows | 列出云端流(智能筛选) | activeOnly、maxRecords、nameContains、excludeSystem、excludeCustomerInsights、excludeCopilotSales | |
search-workflows | 搜索工作流和流 | name、primaryEntity、description、category、statecode、includeDescription、maxResults | |
get-flow-definition | 完整定义或解析后的摘要 | flowId | summary |
get-flow-runs | 流运行历史记录 | flowId | status、startedAfter、startedBefore、maxRecords |
get-flow-run-details | 包含操作级错误的运行详情 | flowId、runId | |
cancel-flow-run | 取消正在运行或等待中的运行 | flowId、runId | |
resubmit-flow-run | 重试失败的运行 | flowId、runId | |
scan-flow-health | 批量运行状况扫描(成功率) | daysBack、maxRunsPerFlow、maxFlows、activeOnly | |
get-flow-inventory | 轻量级流清单 | maxRecords |
解决方案
| 工具 | 描述 | 必需参数 | 可选参数 |
|---|---|---|---|
get-publishers | 列出非只读发布者 | ||
get-solutions | 列出可见解决方案 | ||
get-solution | 根据唯一名称获取解决方案 | uniqueName | |
get-solution-components | 列出解决方案中的组件 | solutionUniqueName | |
export-solution | 导出解决方案(base64) | solutionName | managed |
add-solution-component | 将组件添加到解决方案 | solutionUniqueName、componentId、componentType | addRequiredComponents |
publish-customizations | 发布实体或所有自定义项 | entityLogicalName |
工作流(经典)
| 工具 | 描述 | 必需参数 | 可选参数 |
|---|---|---|---|
get-workflows | 列出经典工作流 | activeOnly、maxRecords | |
get-workflow-definition | XAML 定义或摘要 | workflowId | summary |
get-ootb-workflows | 后台工作流、BPF、操作、按需工作流 | maxRecords、categories |
业务规则
| 工具 | 描述 | 必需参数 | 可选参数 |
|---|---|---|---|
get-business-rules | 列出业务规则 | activeOnly、maxRecords | |
get-business-rule | 包含 XAML 的业务规则 | workflowId |
选项集
| 工具 | 描述 | 必需参数 |
|---|---|---|
get-global-option-set | 获取全局选项集定义 | optionSetName |
配置
| 工具 | 描述 | 必需参数 | 可选参数 |
|---|---|---|---|
get-connection-references | 连接引用 | maxRecords、managedOnly、hasConnection、inactive | |
get-environment-variables | 环境变量定义和数值 | maxRecords、managedOnly | |
create-environment-variable | 创建环境变量定义 | schemaName、displayName、type | defaultValue、description、solutionName |
set-environment-variable-value | 设置或更新环境变量值 | definitionId、value | existingValueId |
自定义 API
| 工具 | 描述 | 必填参数 | 可选参数 |
|---|---|---|---|
get-custom-apis | 列出自定义 API 定义 | maxRecords, includeManaged | |
get-custom-api | 按唯一名称获取自定义 API | uniqueName | |
create-custom-api | 创建自定义 API 定义 | uniqueName, name, displayName, bindingType, isFunction, isPrivate, allowedCustomProcessingStepType | description, pluginTypeId, pluginTypeName, boundEntityLogicalName, solutionName |
get-custom-api-response-properties | 列出响应属性 | customApiId | |
create-custom-api-response-property | 创建响应属性 | customApiId, uniqueName, name, displayName, type | description, logicalEntityName, isOptional, solutionName |
get-custom-api-request-parameters | 列出请求参数 | customApiId | |
create-custom-api-request-parameter | 创建请求参数 | customApiId, uniqueName, name, displayName, type | description, logicalEntityName, isOptional, solutionName |
Web 资源
| 工具 | 描述 | 必填参数 | 可选参数 |
|---|---|---|---|
get-web-resources | 列出 Web 资源 | maxRecords, webResourceType, nameFilter | |
get-web-resource | 按名称获取 Web 资源 | name | |
create-web-resource | 上传新的 Web 资源 | name, displayName, webResourceType, content | description, solutionName |
安全角色
| 工具 | 描述 | 必填参数 | 可选参数 |
|---|---|---|---|
get-security-roles | 列出可自定义的安全角色 | solutionUniqueName, excludeSystemRoles, includePrivileges, maxRecords | |
get-security-role-privileges | 获取角色的权限(名称、访问权限、深度掩码) | roleId | entityFilter, accessRightFilter |
list-privileges | 浏览系统权限目录,以查找 privilegeId GUID 和支持的深度 | entityFilter, accessRightFilter, maxRecords | |
create-security-role | 创建新角色(默认属于根业务部门);可选的 solutionUniqueName 可在一个步骤中将其添加到解决方案 | name | businessUnitId, description, solutionUniqueName |
clone-security-role | 克隆角色及其权限。当该操作不可用时,使用 CloneAsRole,并回退到先创建再复制 | sourceRoleId | newName, targetBusinessUnitId, solutionUniqueName |
update-security-role | 更新角色名称、描述或业务部门 | roleId | name, description, businessUnitId, solutionUniqueName |
delete-security-role | 删除角色(具有破坏性——需要 confirm: true) | roleId, confirm | |
add-security-role-privileges | 向角色追加权限(AddPrivilegesRole——保留现有权限) | roleId, privileges[] | |
remove-security-role-privileges | 从角色移除权限(循环调用 RemovePrivilegeRole) | roleId, privilegeIds[] | |
replace-security-role-privileges | 清除并替换全部权限(ReplacePrivilegesRole——具有破坏性,需要 confirm: true) | roleId, privileges[], confirm |
privileges[] 中的每一项都是 { privilegeId, depth, businessUnitId? }。深度可为 Basic(用户)、Local(业务部门)、Deep(业务部门及子级)或 Global(组织)。
依赖项
| 工具 | 描述 | 必填参数 |
|---|---|---|
check-component-dependencies | 阻止删除的依赖项 | componentId, componentType |
check-delete-eligibility | 检查组件是否可以删除 | componentId, componentType |
服务终结点
| 工具 | 描述 | 可选参数 |
|---|---|---|
get-service-endpoints | Service Bus、Webhook、Event Hub、Event Grid | maxRecords |
MCP 提示词
| 提示词 | 描述 | 必需参数 |
|---|---|---|
entity-overview | 实体概览,包含关键属性和关系 | entityName |
attribute-details | 属性详细信息(类型、格式、要求) | entityName、attributeName |
query-template | OData 查询模板,包含筛选示例 | entityName |
relationship-map | 完整的 1:N 和 N:N 关系映射 | entityName |
命令行
与 MCP 服务提供相同的工具,但结果会缓存到文件系统,以便完整保留大型数据集的输出。
全局选项
--env <name> — 目标环境(默认为第一个已配置的环境)。
命令
实体
entity-metadata <entityName>
entity-attributes <entityName>
entity-attribute <entityName> <attributeName>
entity-relationships <entityName>
entity-keys <entityName>
create-entity <schemaName> <displayName> <displayCollectionName> [--primary-name-schema <name>] [--primary-name-display <name>] [--description <desc>] [--ownership <UserOwned|OrganizationOwned>] [--has-activities] [--has-notes] [--solution <name>]
create-entity-string-attribute <entityName> <schemaName> <displayName> [--max-length <n>] [--required-level <level>] [--description <desc>] [--solution <name>]
create-entity-memo-attribute <entityName> <schemaName> <displayName> [--max-length <n>] [--required-level <level>] [--description <desc>] [--solution <name>]
create-entity-file-attribute <entityName> <schemaName> <displayName> [--max-size-kb <n>] [--required-level <level>] [--description <desc>] [--solution <name>]
create-entity-integer-attribute <entityName> <schemaName> <displayName> [--min <n>] [--max <n>] [--required-level <level>] [--description <desc>] [--solution <name>]
create-entity-decimal-attribute <entityName> <schemaName> <displayName> [--precision <n>] [--min <n>] [--max <n>] [--required-level <level>] [--description <desc>] [--solution <name>]
create-entity-money-attribute <entityName> <schemaName> <displayName> [--precision-source <0|1|2>] [--precision <n>] [--min <n>] [--max <n>] [--required-level <level>] [--description <desc>] [--solution <name>]
create-entity-boolean-attribute <entityName> <schemaName> <displayName> [--true-label <label>] [--false-label <label>] [--default-value <true|false>] [--required-level <level>] [--description <desc>] [--solution <name>]
create-entity-datetime-attribute <entityName> <schemaName> <displayName> [--format <DateOnly|DateAndTime>] [--behavior <UserLocal|DateOnly|TimeZoneIndependent>] [--required-level <level>] [--description <desc>] [--solution <name>]
create-entity-picklist-attribute <entityName> <schemaName> <displayName> [-o <value:label>]... [--required-level <level>] [--description <desc>] [--solution <name>]
create-entity-lookup <referencingEntity> <referencedEntity> <relationshipSchemaName> <lookupSchemaName> <displayName> [--required-level <level>] [--description <desc>] [--cascade-delete <NoCascade|RemoveLink|Restrict|Cascade>] [--solution <name>]
create-entity-alternate-key <entityName> <schemaName> <displayName> <keyAttributes...> [--solution <name>]
delete-entity-attribute <entityName> <attributeName>
记录
record <entityNamePlural> <recordId>
query-records <entityNamePlural> <filter> [--max <n>]
create-record <entityNamePlural> <jsonBody>
update-record <entityNamePlural> <recordId> <jsonBody>
delete-record <entityNamePlural> <recordId>
associate-records <entityNamePlural> <recordId> <navigationProperty> <relatedEntityNamePlural> <relatedRecordId>
disassociate-records <entityNamePlural> <recordId> <navigationProperty> [relatedRecordId]
插件
plugin-assemblies [--include-managed] [--max <n>]
plugin-assembly <assemblyName> [--include-disabled]
plugin-packages [--include-managed] [--max <n>]
plugin-type <typeName>
entity-pipeline <entityName> [--message <msg>] [--include-disabled]
plugin-trace-logs [--entity <name>] [--message <msg>] [--correlation-id <id>] [--step-id <id>] [--hours <n>] [--max <n>] [--exceptions-only]
all-plugin-steps [--include-disabled] [--max <n>]
sdk-message <messageName>
register-plugin-package <filePath> [--pkg-version <version>] [--solution <name>]
update-plugin-package <filePath> --plugin-package-id <id> [--pkg-version <version>]
create-plugin-step <name> <pluginTypeId> <sdkMessageId> [--stage <n>] [--mode <n>] [--rank <n>] [--supported-deployment <n>] [--description <desc>] [--configuration <cfg>] [--message-filter-id <id>] [--solution <name>]
create-plugin-step-image <stepId> [--name <name>] [--entity-alias <alias>] [--image-type <0|1|2>] [--message-property-name <name>] [--attributes <csv>]
流
flows [--active] [--name <contains>] [--include-managed] [--max <n>]
flow-definition <flowId> [--summary]
flow-inventory [--max <n>]
flow-runs <flowId> [--status <s>] [--after <iso>] [--before <iso>] [--max <n>]
flow-run-details <flowId> <runId>
flow-health [--days <n>] [--max-runs <n>] [--max-flows <n>] [--active]
search-workflows [--name <name>] [--entity <entity>] [--category <n>] [--active] [--max <n>]
create-cloud-flow <clientDataFile> [--primary-entity <entity>] [--solution <name>]
activate-flow <flowId>
deactivate-flow <flowId>
解决方案
solutions
solution <uniqueName>
solution-components <uniqueName>
publishers
add-solution-component <solutionUniqueName> <componentId> <componentType> [--add-required]
publish-customizations [--entity <logicalName>]
工作流
workflows [--active] [--max <n>]
workflow-definition <workflowId> [--summary]
ootb-workflows [--categories <0,1,2,3,4>]
业务规则
business-rules [--active] [--max <n>]
business-rule <workflowId>
选项集
optionset <optionSetName>
依赖项
check-dependencies <componentId> <componentType>
配置
connection-references [--managed-only] [--has-connection] [--no-connection] [--inactive] [--max-records <n>]
create-connection-reference <logicalName> <displayName> <connectorId> [--description <desc>] [--solution <name>]
environment-variables [--managed-only] [--max-records <n>]
create-environment-variable <schemaName> <displayName> [--type <type>] [--default-value <val>] [--description <desc>] [--solution <name>]
set-environment-variable-value <definitionId> <value> [--existing-value-id <id>]
自定义 API
custom-apis [--include-managed] [--max <n>]
custom-api <uniqueName>
create-custom-api <uniqueName> <displayName> [--binding-type <n>] [--bound-entity <name>] [--is-function] [--is-private] [--processing-type <n>] [--plugin-type-id <id>] [--plugin-type-name <name>] [--description <desc>] [--solution <name>]
custom-api-response-properties <customApiId>
create-custom-api-response-property <customApiId> <uniqueName> <displayName> [--type <n>] [--description <desc>] [--solution <name>]
custom-api-request-parameters <customApiId>
create-custom-api-request-parameter <customApiId> <uniqueName> <displayName> [--type <n>] [--description <desc>] [--optional] [--solution <name>]
Web 资源
web-resources [--type <n>] [--name <contains>] [--max <n>]
web-resource <name>
create-web-resource <name> <displayName> <filePath> [--type <n>] [--description <desc>] [--solution <name>]
set-entity-icon <entityName> <svgFilePath> [--solution <name>] [--web-resource-name <name>] [--display-name <name>] [--no-publish]
表单和视图
entity-forms <entityName> [--type <n>]
entity-form-fields <formId>
add-form-field <entityName> <formId> <attributeName>
remove-form-field <entityName> <formId> <attributeName>
entity-views <entityName>
add-view-column <entityName> <viewId> <attributeName> [--width <n>]
set-view-columns <entityName> <viewId> <columns...> [--order-by <attr>] [--desc]
remove-view-column <entityName> <viewId> <attributeName>
PAC 集成
pac-auth Authenticate pac CLI using environment credentials
generate-models <outdirectory> [--settings <path>] [--entities <filter>] [--namespace <ns>]
deploy-plugin <pluginFile> --plugin-id <id> [--type <Nuget|Assembly>] [--configuration <config>]
安全角色
security-roles [--solution <name>] [--include-system] [--include-privileges] [--max-records <n>]
security-role-privileges <roleId> [--entity <name>] [--access-right <type>]
privileges [--entity <name>] [--access-right <type>] [--max-records <n>]
create-security-role --name <name> [--bu <id>] [--description <desc>] [--solution <name>]
clone-security-role <sourceRoleId> [--name <name>] [--target-bu <id>] [--solution <name>]
update-security-role <roleId> [--name <name>] [--description <desc>] [--bu <id>] [--solution <name>]
delete-security-role <roleId> --yes
add-role-privileges <roleId> --privileges <spec> # JSON array or shorthand <guid>:<Basic|Local|Deep|Global>,...
remove-role-privileges <roleId> --privileges <id,id,id>
replace-role-privileges <roleId> --privileges <spec> --yes
服务终结点
service-endpoints [--max <n>]
开发
git clone https://github.com/michsob/powerplatform-mcp.git
cd powerplatform-mcp
npm install
cp .env.example .env # fill in credentials
npm run build
npm run inspector # test with MCP Inspector
发布
要发布新版本:
- 更新
package.json中的version - 将更改提交到
main - 创建并推送版本标签:
git tag v1.0.2 git push origin v1.0.2
GitHub Actions 将自动发布:
| 软件包 | npm | GitHub Packages | Docker (GHCR) |
|---|---|---|---|
| MCP 服务 | npm i powerplatform-mcp | npm i @michsob/powerplatform-mcp | ghcr.io/michsob/powerplatform-mcp |
| 命令行工具 | npm i powerplatform-cli | npm i @michsob/powerplatform-cli | ghcr.io/michsob/powerplatform-cli |
npm 发布使用 可信发布(OIDC) — 无需令牌或密钥。GitHub Packages 和 GHCR 会自动使用内置的 GITHUB_TOKEN。
许可证
MIT
评论
一个开放协议,规定了 AI 应用如何以统一方式连接外部工具与数据源。客户端负责与模型对话,MCP 服务负责提供工具、资源和提示模板,两者通过标准消息通信,同一个服务可以被不同客户端复用。
