返回顶部
p

power-automate-build Power Automate构建

>-

作者: admin | 来源: ClawHub
源自
ClawHub
版本
V 1.1.0
安全检测
已通过
285
下载量
免费
免费
0
收藏
概述
安装方式
版本历史

power-automate-build

使用FlowStudio MCP构建和部署Power Automate流

通过FlowStudio MCP服务器以编程方式构建和部署Power Automate云端流的逐步指南。

前提条件:必须能够访问有效的FlowStudio MCP服务器,并持有有效的JWT令牌。
连接设置请参见power-automate-mcp技能。
订阅地址:https://mcp.flowstudio.app



事实来源

始终先调用tools/list 以确认可用的工具名称及其参数模式。工具名称和参数可能因服务器版本而异。
本技能涵盖响应结构、行为说明和构建模式——这些是tools/list无法告知的内容。如果本文档与tools/list或实际API响应存在差异,以API为准。


Python辅助函数

python
import json, urllib.request

MCP_URL = https://mcp.flowstudio.app/mcp
MCPTOKEN = JWT_TOKEN>

def mcp(tool, kwargs):
payload = json.dumps({jsonrpc: 2.0, id: 1, method: tools/call,
params: {name: tool, arguments: kwargs}}).encode()
req = urllib.request.Request(MCP_URL, data=payload,
headers={x-api-key: MCP_TOKEN, Content-Type: application/json,
User-Agent: FlowStudio-MCP/1.0})
try:
resp = urllib.request.urlopen(req, timeout=120)
except urllib.error.HTTPError as e:
body = e.read().decode(utf-8, errors=replace)
raise RuntimeError(fMCP HTTP {e.code}: {body[:200]}) from e
raw = json.loads(resp.read())
if error in raw:
raise RuntimeError(fMCP error: {json.dumps(raw[error])})
return json.loads(raw[result][content][0][text])

ENV = # 例如 Default-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx



步骤1 — 安全检查:流是否已存在?

在构建之前始终先检查,避免重复创建:

python
results = mcp(liststoreflows,
environmentName=ENV, searchTerm=My New Flow)

liststoreflows 返回直接数组(无包装对象)

if len(results) > 0: # 流已存在 — 修改而非创建 # id格式为 envId.flowId — 拆分获取流UUID FLOW_ID = results[0][id].split(., 1)[1] print(f现有流: {FLOW_ID}) defn = mcp(getliveflow, environmentName=ENV, flowName=FLOW_ID) else: print(未找到流 — 从头构建) FLOW_ID = None

步骤2 — 获取连接引用

每个连接器操作都需要一个connectionName,指向流的connectionReferences映射中的键。该键链接到环境中已认证的连接。

必须执行:您必须先调用listliveconnections — 不要询问用户连接名称或GUID。API会返回您需要的精确值。
仅当API确认所需的连接缺失时,才提示用户。

2a — 始终先调用listliveconnections

python
conns = mcp(listliveconnections, environmentName=ENV)

仅筛选已连接(已认证)的连接

active = [c for c in conns[connections] if c[statuses][0][status] == Connected]

构建查找表:connectorName → connectionName (id)

conn_map = {} for c in active: conn_map[c[connectorName]] = c[id]

print(f找到 {len(active)} 个活动连接)
print(可用连接器:, list(conn_map.keys()))

2b — 确定流需要哪些连接器

根据您正在构建的流,确定需要哪些连接器。常见连接器API名称:

连接器API名称
SharePointsharedsharepointonline
Outlook / Office 365
shared
office365 |
| Teams | shared_teams |
| 审批 | shared_approvals |
| OneDrive for Business | shared_onedriveforbusiness |
| Excel Online (Business) | shared_excelonlinebusiness |
| Dataverse | shared_commondataserviceforapps |
| Microsoft Forms | shared_microsoftforms |

不需要连接的流(例如仅包含Recurrence + Compose + HTTP)可以跳过步骤2的其余部分 — 在部署调用中省略connectionReferences。

2c — 如果连接缺失,引导用户

python
connectorsneeded = [sharedsharepointonline, shared_office365] # 根据流调整

missing = [c for c in connectorsneeded if c not in connmap]

if not missing:
print(✅ 所有必需连接均可用 — 继续构建)
else:
# ── 停止:连接必须通过交互方式创建 ──
# 连接需要在浏览器中进行OAuth授权 — 没有API可以创建它们。
print(⚠️ 以下连接器在此环境中没有活动连接:)
for c in missing:
friendly = c.replace(shared_, ).replace(onlinebusiness, Online (Business))
print(f • {friendly} (API名称: {c}))
print()
print(请创建缺失的连接:)
print( 1. 打开 https://make.powerautomate.com/connections)
print( 2. 从右上角选择器中选择正确的环境)
print( 3. 为上面列出的每个缺失连接器点击+ 新建连接)
print( 4. 按提示登录并授权)
print( 5. 完成后告诉我 — 我将重新检查并继续构建)
# 在用户确认之前,不要继续执行步骤3。
# 用户确认后,重新运行步骤2a以刷新conn_map。

2d — 构建connectionReferences块

仅在2c确认没有缺失连接后执行:

python
connection_references = {}
for connector in connectors_needed:
connection_references[connector] = {
connectionName: connmap[connector], # 来自listlive_connections的GUID
source: Invoker,
id: f/providers/Microsoft.PowerApps/apis/{connector}
}

重要 — 操作中的host.connectionName:在步骤3构建操作时,将host.connectionName设置为该映射中的(例如shared_teams),而不是连接GUID。GUID仅放在connectionReferences条目内部。引擎通过操作的host.connectionName匹配键来找到正确的连接。

替代方案 — 如果您已有使用相同连接器的流,可以从其定义中提取connectionReferences:
python
refflow = mcp(getlive_flow, environmentName=ENV, flowName=)
connectionreferences = refflow[properties][connectionReferences]

有关完整的连接引用结构,请参见power-automate-mcp技能的connection-references.md参考文件。


步骤3 — 构建流定义

构建定义对象。有关完整模式,请参见flow-schema.md,以下是可复制粘贴模板的操作模式参考:

python
definition = {
$schema: https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#,
contentVersion: 1.0.0.0,
triggers: { ... }, # 参见 trigger-types.md / build-patterns.md
actions: { ... } # 参见 ACTION-PATTERNS-*.md / build-patterns.md
}

有关涵盖Recurrence+SharePoint+Teams、HTTP触发器等的完整即用型流定义,请参见build-patterns.md


步骤4 — 部署(创建或更新)

updateliveflow在单个工具中处理创建和更新。

创建新流(无现有流)

省略flowName — 服务器生成新的GUID并通过PUT创建:

python
result = mcp(updateliveflow,
environmentName=ENV,
# flowName

标签

skill ai

通过对话安装

该技能支持在以下平台通过对话安装:

OpenClaw WorkBuddy QClaw Kimi Claude

方式一:安装 SkillHub 和技能

帮我安装 SkillHub 和 power-automate-build-1776203724 技能

方式二:设置 SkillHub 为优先技能安装源

设置 SkillHub 为我的优先技能安装源,然后帮我安装 power-automate-build-1776203724 技能

通过命令行安装

skillhub install power-automate-build-1776203724

下载

⬇ 下载 power-automate-build v1.1.0(免费)

文件大小: 30.4 KB | 发布时间: 2026-4-15 10:55

v1.1.0 最新 2026-4-15 10:55
Add metadata.openclaw declaring FLOWSTUDIO_MCP_TOKEN env var requirement to resolve security scan flag

Archiver·手机版·闲社网·闲社论坛·羊毛社区· 多链控股集团有限公司 · 苏ICP备2025199260号-1

Powered by Discuz! X5.0   © 2024-2025 闲社网·线报更新论坛·羊毛分享社区·http://xianshe.com

p2p_official_large
返回顶部