Power Automate Debugging with FlowStudio MCP
A step-by-step diagnostic process for investigating failing Power Automate
cloud flows through the FlowStudio MCP server.
Prerequisite: A FlowStudio MCP server must be reachable with a valid JWT.
See the power-automate-mcp skill for connection setup.
Subscribe at https://mcp.flowstudio.app
Source of Truth
Always call tools/list first to confirm available tool names and their
parameter schemas. Tool names and parameters may change between server versions.
This skill covers response shapes, behavioral notes, and diagnostic patterns —
things tools/list cannot tell you. If this document disagrees with tools/list
or a real API response, the API wins.
Python Helper
CODEBLOCK0
FlowStudio for Teams: Fast-Path Diagnosis (Skip Steps 2–4)
If you have a FlowStudio for Teams subscription, get_store_flow_errors
returns per-run failure data including action names and remediation hints
in a single call — no need to walk through live API steps.
CODEBLOCK1
For the full governance record (description, complexity, tier, connector list):
record = mcp("get_store_flow", environmentName=ENV, flowName=FLOW_ID)
# {"displayName": "My Flow", "state": "Started",
# "runPeriodTotal": 100, "runPeriodFailRate": 0.1, "runPeriodFails": 10,
# "runPeriodDurationAverage": 29410.8, ← milliseconds
# "runError": "{\"code\": \"EACCES\", ...}", ← JSON string, parse it
# "description": "...", "tier": "Premium", "complexity": "{...}"}
if record.get("runError"):
last_err = json.loads(record["runError"])
print("Last run error:", last_err)
Step 1 — Locate the Flow
CODEBLOCK3
Step 2 — Find the Failing Run
CODEBLOCK4
Step 3 — Get the Top-Level Error
CODEBLOCK5
Step 4 — Read the Flow Definition
CODEBLOCK6
Find the failing action in the definition. Inspect its inputs expression
to understand what data it expects.
Step 5 — Inspect Action Outputs (Walk Back from Failure)
For each action leading up to the failure, inspect its runtime output:
CODEBLOCK7
⚠️ Output payloads from array-processing actions can be very large.
Always slice (e.g. [:500]) before printing.
Step 6 — Pinpoint the Root Cause
Expression Errors (e.g. split on null)
If the error mentions
InvalidTemplate or a function name:
- 1. Find the action in the definition
- Check what upstream action/expression it reads
- Inspect that upstream action's output for null / missing fields
CODEBLOCK8
Wrong Field Path
Expression
triggerBody()?['fieldName'] returns null →
fieldName is wrong.
Check the trigger output shape with:
CODEBLOCK9
Connection / Auth Failures
Look for
ConnectionAuthorizationFailed — the connection owner must match the
service account running the flow. Cannot fix via API; fix in PA designer.
Step 7 — Apply the Fix
For expression/data issues:
CODEBLOCK10
⚠️ update_live_flow always returns an error key.
A value of null (Python None) means success.
Step 8 — Verify the Fix
CODEBLOCK11
Testing HTTP-Triggered Flows
For flows with a Request (HTTP) trigger, use trigger_live_flow instead
of resubmit_live_flow_run to test with custom payloads:
CODEBLOCK12
INLINECODE19 handles AAD-authenticated triggers automatically.
Only works for flows with a Request (HTTP) trigger type.
Quick-Reference Diagnostic Decision Tree
| Symptom | First Tool to Call | What to Look For |
|---|
| Flow shows as Failed | INLINECODE21 | INLINECODE22 = root cause |
| Expression crash |
get_live_flow_run_action_outputs on prior action | null / wrong-type fields in output body |
| Flow never starts |
get_live_flow | check
properties.state = "Started" |
| Action returns wrong data |
get_live_flow_run_action_outputs | actual output body vs expected |
| Fix applied but still fails |
get_live_flow_runs after resubmit | new run
status field |
Reference Files
Related Skills
- -
power-automate-mcp — Core connection setup and operation reference - INLINECODE30 — Build and deploy new flows
使用FlowStudio MCP调试Power Automate
一个逐步诊断过程,用于通过FlowStudio MCP服务器调查失败的Power Automate云端流。
前提条件:必须能够访问有效的JWT令牌的FlowStudio MCP服务器。连接设置请参见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
FlowStudio Teams版:快速诊断路径(跳过步骤2-4)
如果您拥有FlowStudio Teams版订阅,getstoreflow_errors可在单次调用中返回每次运行的失败数据,包括操作名称和修复提示——无需逐步遍历实时API步骤。
python
快速失败摘要
summary = mcp(get
storeflow
summary, environmentName=ENV, flowName=FLOWID)
{totalRuns: 100, failRuns: 10, failRate: 0.1,
averageDurationSeconds: 29.4, maxDurationSeconds: 158.9,
firstFailRunRemediation: }
print(f失败率: {summary[failRate]:.0%},共 {summary[totalRuns]} 次运行)
每次运行的错误详情(需要配置活动监控)
errors = mcp(get
storeflow
errors, environmentName=ENV, flowName=FLOWID)
if errors:
for r in errors[:3]:
print(r[startTime], |, r.get(failedActions), |, r.get(remediationHint))
# 如果errors确认了失败操作 → 跳转到步骤6(应用修复)
else:
# 存储中没有此流的运行级别详情 — 使用实时工具(步骤2-5)
pass
获取完整的治理记录(描述、复杂度、层级、连接器列表):
python
record = mcp(getstoreflow, environmentName=ENV, flowName=FLOW_ID)
{displayName: My Flow, state: Started,
runPeriodTotal: 100, runPeriodFailRate: 0.1, runPeriodFails: 10,
runPeriodDurationAverage: 29410.8, ← 毫秒
runError: {\code\: \EACCES\, ...}, ← JSON字符串,需解析
description: ..., tier: Premium, complexity: {...}}
if record.get(runError):
last_err = json.loads(record[runError])
print(上次运行错误:, last_err)
步骤1 — 定位流
python
result = mcp(listliveflows, environmentName=ENV)
返回一个包装对象:{mode, flows, totalCount, error}
target = next(f for f in result[flows] if My Flow Name in f[displayName])
FLOW_ID = target[id] # 纯UUID — 直接用作flowName
print(FLOW_ID)
步骤2 — 查找失败运行
python
runs = mcp(getliveflowruns, environmentName=ENV, flowName=FLOWID, top=5)
返回直接数组(最新在前):
[{name: 08584296068667933411438594643CU15,
status: Failed,
startTime: 2026-02-25T06:13:38.6910688Z,
endTime: 2026-02-25T06:15:24.1995008Z,
triggerName: manual,
error: {code: ActionFailed, message: An action failed...}},
{name: ..., status: Succeeded, error: null, ...}]
for r in runs:
print(r[name], r[status], r[startTime])
RUN_ID = next(r[name] for r in runs if r[status] == Failed)
步骤3 — 获取顶层错误
python
err = mcp(getliveflowrunerror,
environmentName=ENV, flowName=FLOWID, runName=RUNID)
返回:
{
runName: 08584296068667933411438594643CU15,
failedActions: [
{actionName: Applytoeachprepareworkers, status: Failed,
error: {code: ActionFailed, message: An action failed...},
startTime: ..., endTime: ...},
{actionName: HTTPfindADUserby_Name, status: Failed,
code: NotSpecified, startTime: ..., endTime: ...}
],
allActions: [
{actionName: Applytoeach, status: Skipped},
{actionName: Compose_WeekEnd, status: Succeeded},
...
]
}
failedActions按从外到内排序。根本原因是最后一个条目:
root = err[failedActions][-1]
print(f根本操作: {root[actionName]} → 代码: {root.get(code)})
allActions显示每个操作的状态 — 有助于发现哪些被跳过
参见common-errors.md以解码错误代码。
步骤4 — 读取流定义
python
defn = mcp(getliveflow, environmentName=ENV, flowName=FLOW_ID)
actions = defn[properties][definition][actions]
print(list(actions.keys()))
在定义中找到失败的操作。检查其inputs表达式以了解它期望的数据。
步骤5 — 检查操作输出(从失败回溯)
对于导致失败的每个操作,检查其运行时输出:
python
for actionname in [ComposeWeekEnd, HTTPGetData, Parse_JSON]:
result = mcp(getliveflowrunaction_outputs,
environmentName=ENV,
flowName=FLOW_ID,
runName=RUN_ID,
actionName=action_name)
# 返回数组 — 提供actionName时为单元素
out = result[0] if result else {}
print(action_name, out.get(status))
print(json.dumps(out.get(outputs, {}), indent=2)[:500])
⚠️ 数组处理操作的输出负载可能非常大。打印前务必切片(例如[:500])。
步骤6 — 定位根本原因
表达式错误(例如对null执行split)
如果错误提到InvalidTemplate或函数名:
- 1. 在定义中找到该操作
- 检查它读取的上游操作/表达式
- 检查该上游操作的输出中是否有null/缺失字段
python
示例:操作使用 split(item()?[Name], )
→ 源数据中Name为null
result = mcp(get
liveflow
runaction
outputs, ..., actionName=ComposeNames)
返回单元素数组;索引[0]获取操作对象
if not result:
print(Compose_Names未返回输出)