power-automate
Microsoft ships an official Power Automate plugin for Claude Code and GitHub Copilot CLI
(power-automate@power-platform-skills). Its working part is FlowAgent, a self-contained
MCP server (server/mcp.mjs, 62 tools) that signs in through the Azure CLI. This skill makes
that engine usable from every agent: scripts/pa speaks MCP over stdio to it, and pa serve
registers it as an MCP server in any client. Provenance and what changed:
references/provenance.md.
PA=<this skill>/scripts/pa # python3, standard library only; needs node 18+ and az
$PA doctor # node, az, signed-in user, tenant, token expiry, engine (never a token)
$PA envs # environments
$PA flows --name "forum" # cloud flows in the default environment (or --env <id>)
$PA get <flow-id> --path properties.definition.actions
$PA export <flow-id> -o /tmp/flow.json # reviewable copy before any change
$PA tools # all 62 engine tools; $PA tools <name> for one schema
$PA call <tool> '{"json":"args"}' # any tool; also @file, -, or --arg key=value (JSON-parsed)
$PA batch steps.jsonl # several calls in ONE engine session (keeps current env/flow)
$PA mcp-config codex|claude|gemini|opencode|copilot # register `pa serve` as an MCP server
Exit status: 0 success, 1 tool error (the JSON says why), 2 sign-in or engine failure,
3 engine not found (pa engine install makes a sparse checkout of Microsoft's repo).
Sign-in: one human step, then agents reuse it
Read references/auth.md before the first call on a machine.
pa doctor. If az_account is null, run pa login (device code). It prints a URL and a
code; the human opens it on any device and approves with their passkey. An agent may start it
in a background shell and relay the code; never approve or type credentials yourself.
- Only for connection management (creating or repairing a connection):
pa login --connectivity.
- After that, tokens refresh silently for every agent on the machine; the sign-in survives
while used at least once every 90 days.
Non-secret defaults (tenant, login hint, default environment) live in
~/.config/power-automate/profile.env, local to the machine and never committed. Teams Workflows
flows are in the tenant's default environment, Default-<tenantId>, which pa uses when
PA_TENANT_ID is set.
Working on flows
Rules: references/flow-authoring.md. Tool catalogue:
references/engine-tools.md.
- Read before writing.
pa export <id> first; quote the step you will change.
- Never guess a parameter name or an id.
get_operation_details, resolve_entity,
resolve_params. An ambiguous resolution goes back to the human.
- Edit surgically.
edit_flow with "dryRun": true, show the diff, then apply with the
returned previewToken. Parameter names containing / are changed with op: merge on the
parameters object. update_flow/edit_flow keep the last 10 backups (restore_backup).
- Create stopped, validate, then enable.
validate_flow and preflight_flow, then
create_flow (Stopped by default), test, then publish_flow (= turn on). disable_flow turns
it off.
- Managed solutions are read-only unless the human explicitly accepts
forceManaged.
- Debug from the run.
get_run_history, diagnose_run, get_run_actions,
get_run_action_content (inputs/outputs of one action).
- Webhook trigger URLs are credentials. Store them in the secret vault, never in a repo, a
log, a ticket or chat;
pa never prints tokens.
- One writer per flow. The API has no conditional write; concurrent agents can clobber each
other.
Patterns
Validated or annotated definitions in references/patterns/:
teams-chat-to-email-relay.json: every message in named group/meeting chats and in all 1:1
DMs, forwarded as a base64 JSON event by email (standard licence only).
teams-channel-to-email-relay.json: a channel's posts (and replies, once verified) forwarded
the same way.
teams-webhook-to-channel-card.json: the Teams Workflows webhook-to-channel-card shape.
forum-workflow-chat-step.edit.json: edit_flow arguments repointing a webhook workflow's
"post message" step at a group chat and posting the payload's chatText.
Teams events to a webhook (n8n) and licensing
references/teams-events-and-licensing.md. In short:
the HTTP action and the "When an HTTP request is received" trigger are premium, the Teams
connector (including the Teams webhook trigger) and Outlook are standard. A standard flow reaches
n8n by email (Outlook "Send an email (V2)" to a Cloudflare Email Routing Worker or an IMAP
mailbox). Chats and DMs can also go straight to n8n's Microsoft Teams Trigger with delegated
Chat.Read; channel messages through Graph need admin consent.
Without the engine
pa rest GET environments and friends call the Flow service, Dataverse or Graph with an Azure
CLI token: references/rest-and-dataverse.md.
1---2name: power-automate3description: "Author, edit, enable, run and debug Microsoft Power Automate cloud flows, including flows built in the Teams Workflows app, from any agent CLI. Wraps FlowAgent, the MCP engine inside Microsoft's official power-automate plugin, behind a shell CLI (scripts/pa) and an MCP launcher (pa serve). Covers the passkey-safe device-code sign-in, listing environments and flows, exporting and surgically editing a flow, creating flows from validated definition patterns (Teams webhook to card, Teams chat or channel message forwarded out), run history and diagnosis, connections, and which Teams events can reach a webhook such as n8n without a premium licence. Triggers: power automate, cloud flow, Teams workflow, Workflows app, flow definition, edit the flow, turn the flow on/off, why did the flow fail, Teams webhook, forward Teams messages, premium connector, HTTP action licence. Do NOT use for posting a message through an existing workflow (call its webhook, e.g. a repo's teams:post task), Power Apps or Power Pages apps, Copilot Studio agents, Dataverse table design, or Graph app registrations beyond the permission table in references/teams-events-and-licensing.md."4metadata:5 source: https://skillmd.com/skills/delorenj/power-automate6---78# power-automate910Microsoft ships an official Power Automate plugin for Claude Code and GitHub Copilot CLI11(`power-automate@power-platform-skills`). Its working part is **FlowAgent**, a self-contained12MCP server (`server/mcp.mjs`, 62 tools) that signs in through the Azure CLI. This skill makes13that engine usable from every agent: `scripts/pa` speaks MCP over stdio to it, and `pa serve`14registers it as an MCP server in any client. Provenance and what changed:15[references/provenance.md](references/provenance.md).1617```bash18PA=<this skill>/scripts/pa # python3, standard library only; needs node 18+ and az19$PA doctor # node, az, signed-in user, tenant, token expiry, engine (never a token)20$PA envs # environments21$PA flows --name "forum" # cloud flows in the default environment (or --env <id>)22$PA get <flow-id> --path properties.definition.actions23$PA export <flow-id> -o /tmp/flow.json # reviewable copy before any change24$PA tools # all 62 engine tools; $PA tools <name> for one schema25$PA call <tool> '{"json":"args"}' # any tool; also @file, -, or --arg key=value (JSON-parsed)26$PA batch steps.jsonl # several calls in ONE engine session (keeps current env/flow)27$PA mcp-config codex|claude|gemini|opencode|copilot # register `pa serve` as an MCP server28```2930Exit status: 0 success, 1 tool error (the JSON says why), 2 sign-in or engine failure,313 engine not found (`pa engine install` makes a sparse checkout of Microsoft's repo).3233## Sign-in: one human step, then agents reuse it3435Read [references/auth.md](references/auth.md) before the first call on a machine.36371. `pa doctor`. If `az_account` is null, run `pa login` (device code). It prints a URL and a38 code; the human opens it on any device and approves with their passkey. An agent may start it39 in a background shell and relay the code; never approve or type credentials yourself.402. Only for connection management (creating or repairing a connection): `pa login --connectivity`.413. After that, tokens refresh silently for every agent on the machine; the sign-in survives42 while used at least once every 90 days.4344Non-secret defaults (tenant, login hint, default environment) live in45`~/.config/power-automate/profile.env`, local to the machine and never committed. Teams Workflows46flows are in the tenant's default environment, `Default-<tenantId>`, which `pa` uses when47`PA_TENANT_ID` is set.4849## Working on flows5051Rules: [references/flow-authoring.md](references/flow-authoring.md). Tool catalogue:52[references/engine-tools.md](references/engine-tools.md).5354- **Read before writing.** `pa export <id>` first; quote the step you will change.55- **Never guess a parameter name or an id.** `get_operation_details`, `resolve_entity`,56 `resolve_params`. An `ambiguous` resolution goes back to the human.57- **Edit surgically.** `edit_flow` with `"dryRun": true`, show the diff, then apply with the58 returned `previewToken`. Parameter names containing `/` are changed with `op: merge` on the59 `parameters` object. `update_flow`/`edit_flow` keep the last 10 backups (`restore_backup`).60- **Create stopped, validate, then enable.** `validate_flow` and `preflight_flow`, then61 `create_flow` (Stopped by default), test, then `publish_flow` (= turn on). `disable_flow` turns62 it off.63- **Managed solutions are read-only** unless the human explicitly accepts `forceManaged`.64- **Debug from the run.** `get_run_history`, `diagnose_run`, `get_run_actions`,65 `get_run_action_content` (inputs/outputs of one action).66- **Webhook trigger URLs are credentials.** Store them in the secret vault, never in a repo, a67 log, a ticket or chat; `pa` never prints tokens.68- **One writer per flow.** The API has no conditional write; concurrent agents can clobber each69 other.7071## Patterns7273Validated or annotated definitions in `references/patterns/`:7475- `teams-chat-to-email-relay.json`: every message in named group/meeting chats and in all 1:176 DMs, forwarded as a base64 JSON event by email (standard licence only).77- `teams-channel-to-email-relay.json`: a channel's posts (and replies, once verified) forwarded78 the same way.79- `teams-webhook-to-channel-card.json`: the Teams Workflows webhook-to-channel-card shape.80- `forum-workflow-chat-step.edit.json`: `edit_flow` arguments repointing a webhook workflow's81 "post message" step at a group chat and posting the payload's `chatText`.8283## Teams events to a webhook (n8n) and licensing8485[references/teams-events-and-licensing.md](references/teams-events-and-licensing.md). In short:86the HTTP action and the "When an HTTP request is received" trigger are premium, the Teams87connector (including the Teams webhook trigger) and Outlook are standard. A standard flow reaches88n8n by email (Outlook "Send an email (V2)" to a Cloudflare Email Routing Worker or an IMAP89mailbox). Chats and DMs can also go straight to n8n's Microsoft Teams Trigger with delegated90`Chat.Read`; channel messages through Graph need admin consent.9192## Without the engine9394`pa rest GET environments` and friends call the Flow service, Dataverse or Graph with an Azure95CLI token: [references/rest-and-dataverse.md](references/rest-and-dataverse.md).