#PowerPlatformTip 170: 'One Flow, Many Tools – a Switch Router for Copilot Studio Agents'
TL;DR: Build one flow with the agent trigger with an
actionand aninputparameter. A Switch onactionroutes to get (OData filter), create or update (JSON body), and Respond to the agent returns JSON. Add it to a Copilot Studio agent as a tool, no HTTP endpoint, JSON-RPC or custom connector needed.
Everyone talks about turning Power Automate flows into MCP servers, but a real MCP server needs a premium HTTP trigger, JSON-RPC handling and a custom connector. For an internal agent you don’t need any of that. A plain flow with the When an agent calls the flow trigger, added as an agent flow tool, gives Copilot Studio the same value: the flow name becomes the tool name, its trigger inputs become the parameters, and Respond to the agent returns the result. This tip packs several operations into one flow using a Switch router.
💡 Challenge
You want a Copilot Studio agent to read and write your data (Dataverse, SharePoint, …) through Power Automate. Building a proper MCP server means a premium When a HTTP request is received trigger, JSON-RPC methods like tools/list and tools/call, and a custom connector with x-ms-agentic-protocol: mcp-streamable-1.0. That’s a lot of plumbing for an internal scenario, and it needs premium licensing.
✅ Solution
Use a single flow with the When an agent calls the flow trigger and expose it to the agent as a tool. Drive the behaviour with two inputs:
action– which operation to run:get,createorupdate.input– a generic string whose meaning depends on the action: an OData filter forget, a JSON body forcreate/update.
A Switch on action routes to the right branch, and one Respond to the agent action returns JSON. Copilot Studio handles all the tool discovery, so you never touch JSON-RPC yourself.
flowchart TD
A["Agent trigger<br/>action, input, id"] --> B{"Switch on action"}
B -->|get| C["List rows<br/>Filter Query = input"]
B -->|create| D["Parse JSON on input"] --> E["Add a row"]
B -->|update| F["Parse JSON on input"] --> G["Update row by id"]
C --> H["Respond to the agent"]
E --> H
G --> H
🔧 How It’s Done
1. Create the trigger inputs. On When an agent calls the flow, add:
🔸 action (Text) – describe it for the model: “get, create or update”.
🔸 input (Text) – “For get: an OData filter like Status eq 'open'. For create/update: a JSON object like {\"title\":\"Test\"}.”
🔸 id (Text, optional) – “Record ID, required for update”.
Clear input descriptions matter: the agent reads them to decide what to pass.
2. Add a Switch on the action value.
1
triggerBody()?['text']
🔸 The exact reference is ['text'], ['text_1'], ['text_2'] depending on input order. Check it in the trigger’s Code view or by inserting the input as dynamic content once.
3. Case get – treat input as OData. Use List rows / Get items and drop the string straight into Filter Query:
1
triggerBody()?['text_1']
🔸 No parsing needed, an OData filter is already a plain string.
4. Case create – treat input as JSON. Add Parse JSON on triggerBody()?['text_1'] with a schema for your fields:
1
2
3
4
{ "type": "object", "properties": {
"title": { "type": "string" },
"status": { "type": "string" }
} }
🔸 Action names must be unique in a flow, so the Parse JSON in the update case gets a different name (for example Parse_JSON_1). Rename both, for example to Parse_create and Parse_update, and reference exactly those names with body('Parse_create') and body('Parse_update'). A reference to an action in another Switch case fails, because that case did not run.
🔸 Then feed body('Parse_create')?['title'] etc. into Add a row / Create item.
🔸 Without a schema you can also read a field directly: json(triggerBody()?['text_1'])?['title'].
5. Case update – JSON body plus an ID. Same Parse JSON as above, target the record with:
1
triggerBody()?['text_2']
🔸 The ?[...] operator returns null for fields missing in the JSON, so you can read optional fields safely, e.g. body('Parse_update')?['status'].
6. Respond with JSON. After the Switch, add a Compose and return it via Respond to the agent (a result text output). To avoid referencing actions in branches that did not run, first add an Initialize variable result (String) before the Switch, set it with Set variable in each case (for example string(outputs('List_rows')?['body/value']) for get), and return that variable:
1
2
3
4
5
{
"ok": true,
"action": "@{triggerBody()?['text']}",
"result": @{variables('result')}
}
🔸 Use @{...} for string values and the stringified variable for nested JSON. Because the variable always exists, the response also works when a branch was skipped.
7. Handle bad JSON. Wrap Parse JSON in a Scope and use Configure run after (has failed) on a Set variable that stores {"ok":false,"error":"invalid JSON"}, so the agent gets a readable answer when a create/update payload isn’t valid JSON.
8. Check the response settings. In Respond to the agent → Settings → Networking, keep Asynchronous response set to Off. The agent waits for the answer, and the flow must respond within 100 seconds, so keep queries small (Filter Query, Select columns, Row count).
9. Add it to the agent. Publish the flow, then in Copilot Studio open your agent → Tools → Add a tool → Flow, select it and choose Add and configure. The flow name becomes the tool name, and the action / input / id inputs become the tool parameters. Write a clear tool description there as well: the orchestrator uses it to decide when to call the flow. A flow only appears in this list if it has the When an agent calls the flow trigger and a Respond to the agent action.
🎉 Result
Your agent gets one dependable tool that can read (OData), create and update records, all from a single flow. No HTTP trigger, no JSON-RPC, no custom connector, and everything stays inside your governed Power Platform environment.
🌟 Key Advantages
🔸 No plumbing: an agent flow tool replaces the whole HTTP + JSON-RPC + custom connector stack for internal use.
🔸 One tool, many operations: the Switch on action keeps get / create / update in a single, maintainable flow.
🔸 Flexible input: one input parameter carries an OData filter or a JSON body, interpreted per branch.
🔸 Clean contract: structured JSON responses (ok, action, result) make the agent’s downstream handling reliable.
⚠️ Good to Know
🔸 Licensing depends on where the flow is billed. An agent flow consumes Copilot Studio capacity for every action it executes. A Power Automate cloud flow with the same trigger is licensed like any cloud flow: then the Dataverse connector is premium and SharePoint is standard. You can convert a cloud flow in a solution to an agent flow by changing its plan to Copilot Studio, but that conversion cannot be reversed.
🔸 Write access is real access. The flow runs with the connection you configured. Limit what create and update may touch (allowed columns, allowed tables), because the model decides what it sends.
🛠️ FAQ
1. Is this a real MCP server?
No. A real MCP server needs a premium HTTP trigger, JSON-RPC (tools/list, tools/call) and a custom connector with x-ms-agentic-protocol: mcp-streamable-1.0. This is the internal equivalent: an agent flow tool where Copilot Studio does the tool discovery for you.
2. One flow with a Switch, or one flow per operation?
Both work. A Switch keeps everything in one tool. Separate flows (create, get, update) make each flow name a distinct tool with its own description and parameters, which the agent often selects more reliably. Choose based on how many operations you have.
3. Why not parse the OData string in the get branch?
An OData filter is already a plain string that goes straight into Filter Query. Only create / update need Parse JSON, because you read individual fields out of the body.
4. How does the agent know what to send?
From your input descriptions. Spell out the expected format (OData vs. JSON) in each trigger input’s description, that’s the text the model uses to build the call.
5. Why does my flow not show up under Tools → Add a tool → Flow?
It needs the When an agent calls the flow trigger, a Respond to the agent action with Asynchronous response off, and it must be published.
🔗 Related Tips
- #PowerPlatformTip 158: Return Flow Data to Power Apps with ParseJSON, the pattern of returning JSON from a flow to its caller that this router uses.
- #PowerPlatformTip 104: Efficient JSON Handling, Parse JSON schemas for the
create/updatebranches. - #PowerPlatformTip 95: Optimized SharePoint Queries, building the OData Filter Query used in the
getbranch. - #PowerPlatformTip 173: Let Copilot Studio Build the Call - Your Connector as an AI Tool, the alternative when a connector action instead of a flow should be the tool.
- #PowerPlatformTip 174: Self-Healing Connector Actions in Copilot Studio, the same trigger and response pattern with a fixed
ok/errorshape and retries. - #PowerPlatformTip 168: Collect Failed Action Details with the result() Function, richer error messages for the bad-JSON branch in step 7.
- #PowerPlatformTip 118: Copy Actions in Switch/Condition, working cleanly inside Switch branches.
This tip is by Marcel Lehmann, Microsoft MVP (Business Applications) and founder of the Power Platform Academy, which runs free live workshops (in German). See the next free workshop dates (in German). For companies that want this implemented for them, see KMUpower: Power Platform consulting & automation for SMEs (DACH).