Skip to content

Commit e52e38b

Browse files
radioblazerMatt TownsendCopilot
authored
fix(power-automate): coerce JSON string args for large flow definitions (#298)
* fix(power-automate): coerce JSON string args for large flow definitions The MCP transport may serialize large object arguments (definition, connectionRefs, body) to JSON strings before they reach the Zod validator. Previously, z.record(z.unknown()) rejected these with "Expected object, received string". This adds a z.preprocess() wrapper (jsonRecord) that parses JSON strings back to objects before validation. Fixes: create_flow, update_flow, preview_update, validate_flow, preflight_flow, run_flow, invoke_operation, run_desktop_flow, pick_or_create_connection, and dynamic resolver tools. Source: https://github.com/matow_microsoft/flow-agent (packages/core/src/mcp/server.ts) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * feat(power-automate): add Microsoft Learn MCP as companion knowledge source Adds the Learn MCP server (https://learn.microsoft.com/api/mcp) to the plugin's .mcp.json. Updates AGENTS.md with hybrid lookup guidance: - Tier 1: local references/*.md (fast, offline, plugin-specific) - Tier 2: Learn MCP (live, comprehensive, up-to-date) No auth required, free, public endpoint. Tested and validated against 7 key scenarios (expressions, connectors, errors, child flows, ALM, article fetch, code samples) — all return rich relevant results. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Matt Townsend <matow+microsoft@microsoft.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent b7ca65c commit e52e38b

5 files changed

Lines changed: 121 additions & 23 deletions

File tree

plugins/power-automate/.claude-plugin/plugin.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "power-automate",
3-
"version": "2.1.0",
3+
"version": "2.2.0",
44
"description": "Build, edit, run, and debug Power Automate cloud flows via the FlowAgent MCP server — connection lifecycle, surgical edits, copy across environments, run management, and validated expressions.",
55
"author": {
66
"name": "Microsoft",

plugins/power-automate/.mcp.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
"-e",
77
"const p=require('node:path'),fs=require('node:fs');const r=process.env.PLUGIN_ROOT||process.env.CLAUDE_PLUGIN_ROOT||process.cwd();const src=process.env.PLUGIN_ROOT?'PLUGIN_ROOT':process.env.CLAUDE_PLUGIN_ROOT?'CLAUDE_PLUGIN_ROOT':'cwd';const mjs=p.resolve(r,'server','mcp.mjs');if(!fs.existsSync(mjs)){console.error('FlowAgent MCP not found at '+mjs+' (resolved via '+src+'='+r+'). Run /setup to fix.');process.exit(1);}(async()=>{try{await import(require('node:url').pathToFileURL(mjs).href)}catch(e){console.error(e);process.exit(1)}})();"
88
]
9+
},
10+
"microsoft-learn": {
11+
"type": "http",
12+
"url": "https://learn.microsoft.com/api/mcp"
913
}
1014
}
1115
}

plugins/power-automate/.plugin/plugin.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "power-automate",
3-
"version": "2.1.0",
3+
"version": "2.2.0",
44
"description": "Build, edit, run, and debug Power Automate cloud flows via the FlowAgent MCP server — connection lifecycle, surgical edits, copy across environments, run management, and validated expressions.",
55
"author": {
66
"name": "Microsoft",

plugins/power-automate/AGENTS.md

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,39 @@ this plugin's `.mcp.json` / the install steps in `README.md`.
2929
connection patterns, error troubleshooting)
3030
- `.claude-plugin/plugin.json` + `.plugin/plugin.json` — Claude / Copilot
3131
manifests
32-
- `.mcp.json` — MCP server wiring
32+
- `.mcp.json` — MCP server wiring (FlowAgent + Microsoft Learn)
3333

3434
The flow-definition rules, auth model, error reference, and known issues live in
3535
the [FlowAgent repo CLAUDE.md](https://github.com/matow_microsoft/flow-agent/blob/main/CLAUDE.md) and apply whether you call via MCP or shell.
36+
37+
## Documentation lookup (hybrid pattern)
38+
39+
This plugin uses a **two-tier knowledge architecture**:
40+
41+
### Tier 1: Local references (fast, offline, plugin-specific)
42+
The `references/*.md` files are curated, plugin-specific docs covering:
43+
- Flow definition rules (`$authentication`, `$connections`, `OpenApiConnection`)
44+
- Connection reference patterns (`Embedded` vs `Invoker`, logical names)
45+
- Error-to-fix mapping (the exact API errors FlowAgent users hit)
46+
- CLI command reference
47+
48+
**Always check `references/*.md` first** — they contain hard-won knowledge that
49+
Learn docs don't cover or bury across many articles.
50+
51+
### Tier 2: Microsoft Learn MCP (live, comprehensive, up-to-date)
52+
The `.mcp.json` wires `microsoft-learn` (`https://learn.microsoft.com/api/mcp`)
53+
which provides:
54+
- `microsoft_docs_search` — search Learn docs by topic
55+
- `microsoft_docs_fetch` — fetch a complete article by URL
56+
- `microsoft_code_sample_search` — find code examples
57+
58+
**Use Learn MCP when:**
59+
- The user asks about a connector or action you don't recognize
60+
- An expression function isn't in the local expression reference
61+
- You need the latest API changes or preview features
62+
- The user asks "how do I..." for a scenario not in references/
63+
- You need to verify whether a pattern is officially supported
64+
- Error troubleshooting needs more context than the local table provides
65+
66+
**Scoping tip:** Prefix queries with "Power Automate" or "cloud flow" for
67+
relevance. For connector docs, use the connector name directly.

0 commit comments

Comments
 (0)