Skip to main content
Glama
user-vik

power-automate-mcp-server

by user-vik
README.md
# power-automate-mcp-server

An [MCP](https://modelcontextprotocol.io) server that exposes Power Automate
cloud-flow management and run troubleshooting to an MCP client (Claude Code,
Claude Desktop, etc.).

It talks to the Power Automate management plane
(`api.flow.microsoft.com`, the `Microsoft.ProcessSimple` provider) using an
Entra token for the `service.flow.microsoft.com` audience. With **delegated**
auth (interactive / CLI) it needs **no admin consent** — it operates as the
signed-in user and sees the flows that user owns or is shared on.

## Tools

### Read (always on)

| Tool                | Purpose                                                                       |
| ------------------- | ----------------------------------------------------------------------------- |
| `list_environments` | List Power Platform environments and their `name` (used everywhere else).     |
| `list_flows`        | List cloud flows the caller can see in an environment.                        |
| `get_flow`          | Full flow JSON — trigger/action definition and connection references.         |
| `list_flow_runs`    | Recent runs of a flow, newest first, with status/error; pages via `nextLink`. |
| `get_flow_run`      | Full detail for one run, including per-action status and error payloads.      |

### Write (`PA_MCP_MODE=write`)

| Tool           | Purpose                                                |
| -------------- | ------------------------------------------------------ |
| `run_flow`     | Trigger an on-demand run of a manually-triggered flow. |
| `enable_flow`  | Start a flow so its triggers fire.                     |
| `disable_flow` | Stop a flow so its triggers no longer fire.            |

Every write call is audit-logged to stderr with timestamp, tool, target, and
caller identity.

### Destructive (`PA_MCP_MODE=write` **and** `PA_MCP_ALLOW_DELETE=true`)

| Tool          | Purpose                                                              |
| ------------- | -------------------------------------------------------------------- |
| `delete_flow` | Permanently delete a flow. Two-step dry_run → confirm_token → apply. |

The destructive tier is off by default. When enabled, each call is a plan first:
`dry_run=true` (the default) returns the flow that would be removed plus a
single-use `confirm_token`; only a second call with `dry_run=false` and that
token performs the delete, guarded by an `If-Match` ETag.

## Setup

```bash
cd power-automate-mcp-server
npm install
```

Register it with your MCP client. Example `.claude.json` entry (delegated auth,
read-only):

```json
{
  "mcpServers": {
    "power-automate": {
      "type": "stdio",
      "command": "node",
      "args": ["/absolute/path/to/power-automate-mcp-server/index.js"],
      "env": {
        "AZURE_TENANT_ID": "<your-entra-tenant-id>",
        "PA_AUTH_MODE": "interactive",
        "PA_MCP_MODE": "read"
      }
    }
  }
}
```

To allow triggering and enabling/disabling flows, set `"PA_MCP_MODE": "write"`.
To also allow deletion, add `"PA_MCP_ALLOW_DELETE": "true"`.

Set `PA_DEFAULT_ENVIRONMENT` to a value from `list_environments` if you want to
omit `environment` on every call.

See [`.env.example`](.env.example) for the full list of environment variables,
including all supported auth modes.

## Auth notes

- **Delegated (recommended here):** `interactive`, `device-code`, or `cli`.
  No admin consent, but the caller only sees flows they own or are shared on.
- **Service principal:** non-interactive, but an SP must be granted Power
  Platform admin consent before it can enumerate flows — a tenant-admin action.

## Requirements

- Node.js >= 20
- An Entra identity that can sign in to Power Automate in the target tenant.

## License

MIT — see [LICENSE](LICENSE).