mcpField
P
powerplatform mcp/cli

powerplatform mcp/cli

本地服务
github.com/michsob开发工具446 周前更新

关于 powerplatform mcp/cli

PowerPlatform MCP / CLI 是一个 MCP 服务兼独立命令行工具,用于查询并配置 PowerPlatform / Dataverse 环境,支持多环境管理。面向需要探索或自动化配置 Power Platform 环境的开发者与管理员。

主要功能

  1. 01支持多环境配置与切换
  2. 02查询实体、记录、插件、流和解决方案
  3. 03提供写入操作以自动化环境配置
  4. 04CLI 将完整结果缓存到文件系统

适用场景

  1. 01在 AI 客户端中交互式探索 Dataverse 实体与插件
  2. 02通过 CLI 导出大量结果供后续分析
  3. 03批量创建自定义 API、环境变量或安全角色

MCP 相关

该项目是 MCP 服务,向 AI 客户端提供约 67 个工具,涵盖实体、记录、插件、Power Automate 流、解决方案、安全角色等操作。

配置

本地服务的配置在各客户端中通用,复制后粘贴到客户端的 MCP 配置文件即可。

mcp.json · 通用配置
{
"mcpServers": {
"powerplatform": {
"command": "npx",
"args": [
"-y",
"powerplatform-mcp"
],
"env": {
"POWERPLATFORM_ENVIRONMENTS": "<POWERPLATFORM_ENVIRONMENTS>",
"POWERPLATFORM_DEV_URL": "<POWERPLATFORM_DEV_URL>",
"POWERPLATFORM_DEV_CLIENT_ID": "<POWERPLATFORM_DEV_CLIENT_ID>",
"POWERPLATFORM_DEV_CLIENT_SECRET": "<POWERPLATFORM_DEV_CLIENT_SECRET>",
"POWERPLATFORM_DEV_TENANT_ID": "<POWERPLATFORM_DEV_TENANT_ID>",
"POWERPLATFORM_UAT_URL": "<POWERPLATFORM_UAT_URL>",
"POWERPLATFORM_UAT_CLIENT_ID": "<POWERPLATFORM_UAT_CLIENT_ID>",
"POWERPLATFORM_UAT_CLIENT_SECRET": "<POWERPLATFORM_UAT_CLIENT_SECRET>",
"POWERPLATFORM_UAT_TENANT_ID": "<POWERPLATFORM_UAT_TENANT_ID>"
}
}
}
}
启动命令npx -y powerplatform-mcp
需要配置的环境变量
POWERPLATFORM_ENVIRONMENTS
POWERPLATFORM_DEV_URL
POWERPLATFORM_DEV_CLIENT_ID
POWERPLATFORM_DEV_CLIENT_SECRET密钥
POWERPLATFORM_DEV_TENANT_ID
POWERPLATFORM_UAT_URL
POWERPLATFORM_UAT_CLIENT_ID
POWERPLATFORM_UAT_CLIENT_SECRET密钥
POWERPLATFORM_UAT_TENANT_ID

本地服务需要在你的电脑上安装运行环境(如 Node.js 18+)。各客户端的配置文件位置不同,请参考客户端文档。

安装包
npmpowerplatform-mcp

工具

还没有获取到工具列表

本地服务需要在你的电脑上运行后才能读取工具,维护者暂未提供工具列表。

详细介绍

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、displayNamemaxLength、requiredLevel、description、solutionName
get-entity-keys列出实体上的备用键entityName
create-entity-alternate-key创建备用键entityName、schemaName、displayName、keyAttributessolutionName
记录
工具描述必填参数可选参数
get-record按 ID 获取记录entityNamePlural、recordId
query-recordsOData 查询entityNamePlural、filtermaxRecords(默认值为 50)
插件
工具描述必填参数可选参数
get-plugin-assemblies列出插件程序集includeManaged、maxRecords
get-plugin-assembly-complete获取包含类型、步骤和图像的程序集assemblyNameincludeDisabled
get-entity-plugin-pipeline获取在实体上执行的插件entityNamemessageFilter、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、moderank、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完整定义或解析后的摘要flowIdsummary
get-flow-runs流运行历史记录flowIdstatus、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)solutionNamemanaged
add-solution-component将组件添加到解决方案solutionUniqueName、componentId、componentTypeaddRequiredComponents
publish-customizations发布实体或所有自定义项entityLogicalName
工作流(经典)
工具描述必需参数可选参数
get-workflows列出经典工作流activeOnly、maxRecords
get-workflow-definitionXAML 定义或摘要workflowIdsummary
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、typedefaultValue、description、solutionName
set-environment-variable-value设置或更新环境变量值definitionId、valueexistingValueId
自定义 API
工具描述必填参数可选参数
get-custom-apis列出自定义 API 定义maxRecords, includeManaged
get-custom-api按唯一名称获取自定义 APIuniqueName
create-custom-api创建自定义 API 定义uniqueName, name, displayName, bindingType, isFunction, isPrivate, allowedCustomProcessingStepTypedescription, pluginTypeId, pluginTypeName, boundEntityLogicalName, solutionName
get-custom-api-response-properties列出响应属性customApiId
create-custom-api-response-property创建响应属性customApiId, uniqueName, name, displayName, typedescription, logicalEntityName, isOptional, solutionName
get-custom-api-request-parameters列出请求参数customApiId
create-custom-api-request-parameter创建请求参数customApiId, uniqueName, name, displayName, typedescription, logicalEntityName, isOptional, solutionName
Web 资源
工具描述必填参数可选参数
get-web-resources列出 Web 资源maxRecords, webResourceType, nameFilter
get-web-resource按名称获取 Web 资源name
create-web-resource上传新的 Web 资源name, displayName, webResourceType, contentdescription, solutionName
安全角色
工具描述必填参数可选参数
get-security-roles列出可自定义的安全角色solutionUniqueName, excludeSystemRoles, includePrivileges, maxRecords
get-security-role-privileges获取角色的权限(名称、访问权限、深度掩码)roleIdentityFilter, accessRightFilter
list-privileges浏览系统权限目录,以查找 privilegeId GUID 和支持的深度entityFilter, accessRightFilter, maxRecords
create-security-role创建新角色(默认属于根业务部门);可选的 solutionUniqueName 可在一个步骤中将其添加到解决方案namebusinessUnitId, description, solutionUniqueName
clone-security-role克隆角色及其权限。当该操作不可用时,使用 CloneAsRole,并回退到先创建再复制sourceRoleIdnewName, targetBusinessUnitId, solutionUniqueName
update-security-role更新角色名称、描述或业务部门roleIdname, 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-endpointsService Bus、Webhook、Event Hub、Event GridmaxRecords
MCP 提示词
提示词描述必需参数
entity-overview实体概览,包含关键属性和关系entityName
attribute-details属性详细信息(类型、格式、要求)entityName、attributeName
query-templateOData 查询模板,包含筛选示例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

发布

要发布新版本:

  1. 更新 package.json 中的 version
  2. 将更改提交到 main
  3. 创建并推送版本标签:
    git tag v1.0.2
    git push origin v1.0.2
    

GitHub Actions 将自动发布:

软件包npmGitHub PackagesDocker (GHCR)
MCP 服务npm i powerplatform-mcpnpm i @michsob/powerplatform-mcpghcr.io/michsob/powerplatform-mcp
命令行工具npm i powerplatform-clinpm i @michsob/powerplatform-clighcr.io/michsob/powerplatform-cli

npm 发布使用 可信发布(OIDC) — 无需令牌或密钥。GitHub Packages 和 GHCR 会自动使用内置的 GITHUB_TOKEN。

许可证

MIT

PowerPlatform MCP 服务

MseeP.ai 安全评估徽章

评论

支持 Markdown

第一次接触 MCP?

从协议是什么,到在客户端里装上第一个服务,这几条回答覆盖了大多数入门问题。

一个开放协议,规定了 AI 应用如何以统一方式连接外部工具与数据源。客户端负责与模型对话,MCP 服务负责提供工具、资源和提示模板,两者通过标准消息通信,同一个服务可以被不同客户端复用。