Skip to content

Commit 6cec2f3

Browse files
committed
Merge branch 'main' into user/srdeshpande/Workday-EmergencyContact-Update
2 parents 2c0fb34 + a086d23 commit 6cec2f3

116 files changed

Lines changed: 3921 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
---
2+
title: Order Management with Enhanced Task Completion
3+
parent: MCP
4+
grand_parent: Extensibility
5+
nav_order: 3
6+
---
7+
8+
# Order Management with Enhanced Task Completion
9+
10+
{: .warning }
11+
> **Experimental feature.** Enhanced Task Completion is an experimental capability in Copilot Studio. See the [official documentation](https://github.com/microsoft/Agents/blob/main/docs/enhanced-task-completion.md) for current status and limitations.
12+
13+
An end-to-end sample demonstrating Copilot Studio agents with [**Enhanced Task Completion**](https://github.com/microsoft/Agents/blob/main/docs/enhanced-task-completion.md) calling MCP servers for e-commerce order management and warehouse fulfillment, with a **Gradio chat UI** that renders tool calls, reasoning, and file attachments inline.
14+
15+
## What is Enhanced Task Completion?
16+
17+
Enhanced Task Completion shifts Copilot Studio from a "plan-then-execute" model to an adaptive, conversational approach. Instead of selecting all tools upfront, the agent:
18+
19+
- **Reasons before acting** — asks clarifying questions and gathers context before calling tools
20+
- **Orchestrates tools dynamically** — recognizes dependencies between tool outputs, parallelizes independent calls, and adjusts strategy based on intermediate results
21+
- **Interleaves conversation and actions** — fluidly mixes questions, tool calls, and responses across multiple turns
22+
- **Recovers from failures** — retries or finds alternative approaches when tool calls fail
23+
24+
This sample demonstrates all of these capabilities through a realistic e-commerce customer service scenario where the agent chains 9 tools across two MCP servers and a connected agent to answer complex multi-part questions.
25+
26+
![Gradio Chat UI](./assets/gradio-ui.png)
27+
28+
## What's Included
29+
30+
### Orders Agent (Copilot Studio)
31+
32+
The primary agent with Enhanced Task Completion enabled. Handles customer inquiries by dynamically chaining tools from the Order Management MCP server. When a question involves inventory or fulfillment, it delegates to the Warehouse Agent as a connected agent.
33+
34+
### Warehouse Agent (Copilot Studio)
35+
36+
A connected agent invoked by the Orders Agent for warehouse and fulfillment queries. Calls tools from the Warehouse MCP server to check stock levels, track fulfillment pipeline stages, find alternative products, and look up restock dates.
37+
38+
### Order Management MCP Server (5 tools)
39+
40+
Node.js [Streamable HTTP](https://modelcontextprotocol.io/specification/2025-03-26/basic/transports#streamable-http) server with interdependent tools for e-commerce order operations:
41+
42+
| Tool | Input | Purpose |
43+
|---|---|---|
44+
| `search_orders` | Customer name/email/order# | Entry point — find orders |
45+
| `get_order` | order_id | Full order details + line items |
46+
| `get_shipment` | order_id | Tracking info (shipped/delivered only) |
47+
| `request_return` | order_id, item_skus[], reason | Initiate a return |
48+
| `get_return_status` | return_id | Check return progress |
49+
50+
### Warehouse MCP Server (4 tools)
51+
52+
Node.js Streamable HTTP server with interdependent tools for warehouse and fulfillment:
53+
54+
| Tool | Input | Purpose |
55+
|---|---|---|
56+
| `check_stock` | SKU | Inventory levels + warehouse location |
57+
| `get_fulfillment_status` | order_id | Pipeline stage (received → shipped) |
58+
| `find_alternatives` | SKU | Similar products in stock |
59+
| `get_restock_date` | SKU | Next inbound shipment date |
60+
61+
### Gradio Chat UI
62+
63+
Python frontend that connects to the Orders Agent via the [Microsoft Agents SDK](https://github.com/microsoft/Agents-for-python) and renders the full Enhanced Task Completion activity protocol inline:
64+
65+
- **Reasoning steps** — agent thinking displayed as collapsible accordions
66+
- **Tool calls** — grouped with parameters, duration, and results
67+
- **Intermediate messages** — agent narration between tool call batches
68+
- **File upload/download** — CSV/text files sent as base64 attachments, agent-generated files offered for download
69+
- **MSAL auth** — interactive login with persisted token cache (sign in once)
70+
71+
### Custom Connectors
72+
73+
Power Platform connector definitions (Swagger + apiProperties) that expose each MCP server as an action in Copilot Studio. The connectors use the `x-ms-agentic-protocol: mcp-streamable-1.0` extension to enable native MCP tool discovery.
74+
75+
## Prerequisites
76+
77+
- Node.js 18+
78+
- Python 3.12+
79+
- [Dev Tunnels CLI](https://learn.microsoft.com/en-us/azure/developer/dev-tunnels/get-started) (`devtunnel`)
80+
- A Power Platform environment with Copilot Studio
81+
- An Entra ID app registration with `CopilotStudio.Copilots.Invoke` permission
82+
83+
## Quick Start
84+
85+
### 1. Install dependencies
86+
87+
```bash
88+
node scripts/setup.mjs
89+
```
90+
91+
### 2. Import agents (first time only)
92+
93+
Import `agents/solution/OrderManagementMCPDemo.zip` into your environment via **make.powerapps.com > Solutions > Import**. After import, create connections for each MCP connector from the **Custom connectors** page (no auth — just click **Create**). See [Importing the Agent Solutions](./agents/IMPORT) for details.
94+
95+
### 3. Start MCP servers + tunnels
96+
97+
```bash
98+
node scripts/start.mjs
99+
```
100+
101+
This starts both MCP servers and creates anonymous dev tunnels. Note the tunnel URLs printed:
102+
103+
```
104+
Order Management MCP endpoint: https://xxxxx-3000.uks1.devtunnels.ms/mcp
105+
Warehouse MCP endpoint: https://xxxxx-3001.uks1.devtunnels.ms/mcp
106+
```
107+
108+
### 4. Update connector URLs
109+
110+
Each time you restart (tunnels get new URLs), update the custom connector hosts:
111+
112+
1. Go to **make.powerapps.com** > **Custom connectors**
113+
2. Find **"orders mcp"** > click **Edit** > update the **Host** field with the order tunnel host (e.g., `xxxxx-3000.uks1.devtunnels.ms`) > click **Update connector**
114+
3. Find **"warehouse server 3"** > click **Edit** > update the **Host** field with the warehouse tunnel host (e.g., `xxxxx-3001.uks1.devtunnels.ms`) > click **Update connector**
115+
116+
No need to republish the agents — the connectors are referenced dynamically.
117+
118+
### 5. Start the chat UI
119+
120+
Configure the `.env` file with your agent details (requires an Entra ID App Registration). See [Chat UI Setup](./SETUP) for step-by-step instructions.
121+
122+
```bash
123+
cp chat-ui/.env.sample chat-ui/.env
124+
# Edit chat-ui/.env — see SETUP.md for details
125+
node scripts/start-ui.mjs
126+
```
127+
128+
Open http://localhost:7860 and try one of these:
129+
130+
**Basic order lookup:**
131+
> Hi, I'm Sarah Mitchell. I ordered some Sony headphones recently but they arrived with a crackling sound in the left ear. I'd like to return them.
132+
133+
**Cross-server (orders + warehouse):**
134+
> I'm James Rivera. My Nintendo Switch order hasn't shipped yet. When can I expect it? If it's not available, what are my options?
135+
136+
**File upload — populate a CSV:**
137+
> Upload `chat-ui/data/demo-orders.csv` and ask: "Fill in all the empty columns for each order and return the completed CSV."
138+
139+
## Architecture
140+
141+
```mermaid
142+
graph TB
143+
User([fa:fa-user User]) -->|chat| GradioUI
144+
145+
subgraph Local Machine
146+
GradioUI["Gradio Chat UI<br/>Port 7860<br/><i>Reasoning, tool calls,<br/>file upload/download</i>"]
147+
OrderMCP["Order Management<br/>MCP Server<br/><b>5 tools</b> · Port 3000"]
148+
WarehouseMCP["Warehouse<br/>MCP Server<br/><b>4 tools</b> · Port 3001"]
149+
end
150+
151+
subgraph Copilot Studio
152+
OrdersAgent["Orders Agent<br/><i>Enhanced Task Completion</i>"]
153+
WarehouseAgent["Warehouse Agent<br/><i>connected agent</i>"]
154+
OrdersAgent -->|invokes| WarehouseAgent
155+
end
156+
157+
GradioUI -->|"Agents SDK<br/>(streaming)"| OrdersAgent
158+
OrdersAgent -->|"MCP Action<br/>(via connector)"| OrderMCP
159+
WarehouseAgent -->|"MCP Action<br/>(via connector)"| WarehouseMCP
160+
```
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
---
2+
title: Chat UI Setup
3+
parent: Order Management with Enhanced Task Completion
4+
grand_parent: MCP
5+
nav_exclude: true
6+
---
7+
8+
# Chat UI Setup
9+
10+
The Gradio chat UI authenticates against Copilot Studio using MSAL interactive login. You need an Entra ID App Registration and a `.env` file with your agent details.
11+
12+
## App Registration
13+
14+
1. Go to **portal.azure.com** > **App registrations** > **New registration**
15+
2. Name: e.g., "MCP Demo Chat Client"
16+
3. Supported account types: **Single tenant**
17+
4. Redirect URI: **Public client/native** > `http://localhost`
18+
5. After creation, go to **API permissions** > **Add a permission** > **APIs my organization uses**
19+
6. Search for **CopilotStudio** > select **CopilotStudio.Copilots.Invoke** (delegated)
20+
7. Click **Grant admin consent**
21+
8. Copy the **Application (client) ID** — this is your `AGENTAPPID` below
22+
23+
## Configure `.env`
24+
25+
Copy `chat-ui/.env.sample` to `chat-ui/.env` and fill in:
26+
27+
```env
28+
COPILOTSTUDIOAGENT__ENVIRONMENTID=<your-environment-id>
29+
COPILOTSTUDIOAGENT__SCHEMANAME=<agent-schema-name>
30+
COPILOTSTUDIOAGENT__TENANTID=<your-tenant-id>
31+
COPILOTSTUDIOAGENT__AGENTAPPID=<app-registration-client-id>
32+
```
33+
34+
| Variable | Where to find it |
35+
|---|---|
36+
| `ENVIRONMENTID` | The GUID in your Power Platform URL, or **Settings** > **Session details** in Copilot Studio |
37+
| `SCHEMANAME` | Copilot Studio > open the Orders Agent > **Settings** > **Advanced** > **Schema name** |
38+
| `TENANTID` | Your Entra ID tenant ID (Azure Portal > **Microsoft Entra ID** > **Overview**) |
39+
| `AGENTAPPID` | The Application (client) ID from the App Registration above |
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
title: Importing the Agent Solutions
3+
parent: Order Management with Enhanced Task Completion
4+
grand_parent: MCP
5+
nav_exclude: true
6+
---
7+
8+
# Importing the Agent Solutions
9+
10+
## Prerequisites
11+
12+
- A Power Platform environment with Copilot Studio
13+
- Admin or Maker role in the target environment
14+
15+
## Steps
16+
17+
### 1. Import the solution
18+
19+
The solution zip contains both agents, their custom connectors, and connection references — all in one package.
20+
21+
1. Go to [make.powerapps.com](https://make.powerapps.com)
22+
2. Select your target environment
23+
3. Navigate to **Solutions** > **Import solution**
24+
4. Upload `solution/OrderManagementMCPDemo.zip`
25+
5. Click **Next** through the details page
26+
6. If the import wizard shows a **Connections** page, click **New connection** for each connector (no auth needed — just click **Create**), then select the connections you just created
27+
7. Click **Import**
28+
29+
### 2. Create connections
30+
31+
After import, go to **Custom connectors** in the left nav. For each MCP connector (**orders mcp** and **warehouse server 3**), click **Create connection**. The MCP connectors have no authentication — just click **Create** with no credentials.
32+
33+
{: .note }
34+
> In a clean environment the import wizard may skip the Connections step entirely. Creating connections from the Custom connectors page ensures the agents can reach the MCP servers.
35+
36+
### 3. Publish agents
37+
38+
In Copilot Studio, open each agent and click **Publish** to make the latest version live.
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<botcomponent_connectionreferenceset>
2+
<botcomponent_connectionreference botcomponentid.schemaname="cr26e_OrdersAgent.topic.ordersmcp" connectionreferenceid.connectionreferencelogicalname="cr26e_OrdersAgent.shared_new-5forders-20mcp-5fee08b8354fad177a.6be7a421f5184b9ebb376965cf6cd8b8">
3+
<iscustomizable>1</iscustomizable>
4+
</botcomponent_connectionreference>
5+
<botcomponent_connectionreference botcomponentid.schemaname="cr26e_Warehouseagent.topic.warehouseserver3" connectionreferenceid.connectionreferencelogicalname="cr26e_Warehouseagent.shared_new-5fwarehouse-20server-203-5fee08b8354fad177a.726ca1c1522e492082b8e68667e2267e">
6+
<iscustomizable>1</iscustomizable>
7+
</botcomponent_connectionreference>
8+
</botcomponent_connectionreferenceset>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}
2.83 KB
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"swagger":"2.0","info":{"title":"orders mcp","description":"my orders mcp server connector","version":"1.0.0"},"host":"x1kv1q93-3000.uks1.devtunnels.ms","basePath":"/","schemes":["https"],"paths":{"/mcp":{"post":{"responses":{"200":{"description":"Immediate Response"}},"x-ms-agentic-protocol":"mcp-streamable-1.0","operationId":"InvokeServer","summary":"orders mcp","description":"my orders mcp server connector"}}},"securityDefinitions":{},"security":[]}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}

0 commit comments

Comments
 (0)