We know that a Copilot Studio agent usually answers in text. How about the agent showing an interactive dashboard in the chat instead, where the user can select a button to take action?
That is what MCP Apps provide. An MCP App lets an MCP server return an interactive UI along with the tool result, and Copilot Studio renders it in the conversation.
We will be building the MCP server using C# and hosted on Azure Functions.
What is an MCP App?
- An MCP App is an interactive UI (an HTML page) that an MCP server provides for one of its tools.
- The tool points to the UI through a metadata field named
_meta.ui.resourceUri. - The host (Copilot Studio here) reads that HTML and renders it in the conversation, in a sandboxed frame.
- The UI can call tools on the same MCP server, so a button click can run a server action.
MCP Apps render in Microsoft Copilot and in the Copilot Studio preview chat. They don’t render in Teams or web chat at the time of writing this post.
Why Azure Functions?
- Azure Functions has an MCP extension.
- We write normal C# functions, add a few attributes, and the extension exposes them as MCP tools at a single endpoint.
Prerequisites
- .NET 11 SDK.
- Azure Functions Core Tools v4 (the
funccommand). - Node.js LTS, to build the dashboard UI.
- An Azure subscription.
- Access to Microsoft Copilot Studio.
- Visual Studio Code or any editor.
Note: The full source code is on GitHub: mcp-server-azure-functions-copilot-studio. This post explains the key parts instead of listing all the code.
The scenario
- A small Product Inventory with five products, kept in memory (no database).
- Tool
get_inventoryreturns all products and shows the dashboard. - Tool
restock_productadds 1 to 100 units to a product. - The dashboard has a Restock +5 button on every row and a Refresh button.
Lets start by creating the project.
Create the Azure Functions Project
- Create a folder named
InventoryMcpFunctionsand open a terminal in it. - Create an isolated worker project that targets .NET 11.
func init --worker-runtime dotnet-isolated --target-framework net11.0
- Add the MCP extension package.
Microsoft.Azure.Functions.Worker.Extensions.Mcpturns our functions into MCP tools and resources.
dotnet add package Microsoft.Azure.Functions.Worker.Extensions.Mcp

- In
host.json, give the server a name and short instructions underextensions.mcp. - The MCP client receives these values when it first connects to the server. The client is the app that connects to the MCP server and calls its tools. In our case it’s the Copilot Studio agent. GitHub Copilot CLI and Visual Studio Code are other examples of MCP clients.
| Setting | Value |
|---|---|
| serverName | InventoryMcpServer |
| serverVersion | 1.0.0 |
| instructions | Tools to view and restock a small product inventory. |
Now we have an empty Functions project with the MCP extension. Next we define the tools.
Define the MCP Tools
Each tool is a regular C# function with MCP attributes on its parameters. The tools live in InventoryTools.cs.
How a function becomes a tool
[Function]registers the function with Azure Functions, as usual.[McpToolTrigger("<tool-name>", "<tool-description>")]exposes the function as an MCP tool.<tool-name>is the name the agent calls, for examplerestock_product.<tool-description>explains what the tool does. The agent reads it to decide when to call the tool.
[McpToolProperty("<input-name>", "<input-description>", isRequired: true)]defines one tool input.<input-name>is the input name, for examplequantity.<input-description>tells the agent what value to pass, for exampleHow many units to add (1 to 100).- The input type comes from the C# parameter type, so an
intparameter becomes an integer input.
This is the shape of the restock_product tool:
[Function(nameof(RestockProduct))]public string RestockProduct( [McpToolTrigger("restock_product", "Adds stock to a product...")] ToolInvocationContext context, [McpToolProperty("productId", "The product ID to restock, for example P002.", isRequired: true)] string productId, [McpToolProperty("quantity", "How many units to add (1 to 100).", isRequired: true)] int quantity)
- The function validates the quantity, updates the product and returns the result as JSON text.
get_inventoryhas no inputs. It returns the product list and the low stock count as JSON text.
The tools work as plain MCP tools at this point. Lets link get_inventory to a UI.
Link the Tool to the Dashboard UI
Two attributes connect a tool to its UI. One sits on the tool, and one sits on the function that returns the HTML.
On the tool: point to the UI
get_inventoryhas an extra attribute,[McpMetadata].- The metadata sets
ui.resourceUritoui://inventory/dashboard.html. - The Azure Functions MCP extension (the
Microsoft.Azure.Functions.Worker.Extensions.Mcppackage we added earlier) builds the tool definitions from our attributes. - It adds this metadata to the
get_inventorydefinition as_meta.ui.resourceUri. This is the field Copilot Studio looks for.
[McpToolTrigger("get_inventory", "Shows the current product inventory as an interactive dashboard...")][McpMetadata("""{ "ui": { "resourceUri": "ui://inventory/dashboard.html" } }""")]
On the resource: serve the HTML
- A second function in
InventoryWidget.csuses[McpResourceTrigger]. This exposes an MCP resource, which is content the client can read. - The resource URI must match the
resourceUrifrom the tool exactly. - The MIME type must be
text/html;profile=mcp-app. Without it, Copilot Studio doesn’t treat the HTML as an MCP App. - The function reads the built
index.htmlfile from the app folder and returns it.
[McpResourceTrigger("ui://inventory/dashboard.html", "Inventory Dashboard", MimeType = "text/html;profile=mcp-app")]
restock_product has no [McpMetadata]. It runs without a UI, and the agent replies in text.
What happens at run time
- The agent calls
get_inventory. - Copilot Studio sees
_meta.ui.resourceUrion the tool and reads theui://inventory/dashboard.htmlresource. - It renders the HTML in the chat and passes the tool result to the page.
- The page fills the table from that result.
Now we have the server side ready. Next lets build the dashboard page itself.
Build the Dashboard UI
MCP App UI requirements
An MCP App UI is a single HTML document. The MCP server returns the document as text, with the MIME type text/html;profile=mcp-app.
- Copilot Studio renders the document in a sandboxed frame.
- To avoid external references, include all scripts and styles in the HTML file.
- Scripts, styles, and images from external domains are blocked. To allow a domain, add it under
ui.cspin the[McpMetadata]attribute on the resource function. UseconnectDomainsfor network calls andresourceDomainsfor scripts, styles, and images.
[McpMetadata("""{ "ui": { "csp": { "connectDomains": ["https://api.contoso.com"], "resourceDomains": ["https://cdn.contoso.com"] } } }""")]
Our dashboard keeps everything inside the HTML file, so it doesn’t set csp.
You can create a standalone HTML file or build it with a framework such as React. If you use a build tool, configure it to output a single HTML file.
Dashboard page logic
The dashboard is a TypeScript page in the app folder, with no UI framework. It uses the @modelcontextprotocol/ext-apps npm package. The package provides the App class, which handles communication between the page and Copilot Studio.
app.ontoolresultreceives theget_inventoryresult and renders the table.- The Restock +5 button calls
app.callServerToolwithrestock_product. Copilot Studio sends the call to the MCP server over the same connection and API key. - After a restock, the page updates the row and calls
app.updateModelContextto share the new stock level with the agent. - The Refresh button calls
get_inventoryand renders the table again. - The page doesn’t retry a failed restock, because a retry can add the stock twice.
Build the single HTML file
- Vite and the
vite-plugin-singlefileplugin build the page into one file,app/dist/index.html. - The project file copies
app/distto the build output, so the HTML file is deployed with the functions. - The
InventoryWidget.csresource function reads and returns this file. - To build the page, run these commands from the project folder.
cd appnpm installnpm run buildcd ..
Note: Run
npm run buildbefore every publish.
The code is ready. Lets create the Function App in Azure.
Create the Function App and Publish
- In the Azure portal, create a Function App and choose the Flex Consumption plan.
- Use these settings on the Basics tab.
| Setting | Value |
|---|---|
| Resource Group | A new group, for example rg-mcp-functions |
| Function App name | A unique name, for example mcp-inventory-rajeev |
| Region | A region near you, for example West US 3 |
| Runtime stack | .NET |
| Version | 11 (STS), isolated worker model |
| Instance size | 512 MB |

- Select Review + create, then Create.
- Once the app is created, open Settings > Scale and concurrency and set Maximum instance count to
1.
Note: The demo keeps data in memory. With one instance, every request sees the same stock. The data resets when the app restarts.
- Now that Function App is ready in Azure, lets push our code.
- From the project folder, publish the code. Replace the name with your Function App name.
func azure functionapp publish mcp-inventory-rajeev

Collect the endpoint and the key
To connect a Copilot Studio agent to this Azure Functions MCP server, we need two values: the MCP server URL and the mcp_extension key.
- URL: Copy the Default domain from the Function App Overview page. The URL is
https://<default-domain>/runtime/webhooks/mcp. - Key: Open Functions > App keys. Under System keys, copy the
mcp_extensionvalue.
Now we have the MCP server running in Azure, with its URL and key. Lets connect it to a Copilot Studio agent.
Add the MCP Server to a Copilot Studio Agent
- In Copilot Studio, create an agent. We named ours Inventory Assistant.
- Add instructions that tell the agent when to use each tool and to confirm before a restock. For example:
You help store managers check product stock and restock items.Tools- Always use the Inventory MCP tools for inventory data. Never guess or invent stock numbers.- Use "get_inventory" when the user asks to see stock, products, or what is running low.- Use "restock_product" when the user asks to restock or add stock to a product.When to act or ask- Before restocking, confirm the product and quantity if the user didn't state both.- If a tool fails, tell the user in one sentence and suggest trying again. Don't retry on your own.Communication- Keep answers short and clear.- When the inventory dashboard appears, don't repeat its full contents in text. Give a one-line summary.
- On the Build tab, select + next to Tools.
- In the Add a tool dialog, select Add > Model Context Protocol (MCP).

- Fill the Add MCP server form with these values, then select Add.
| Field | Value |
|---|---|
| Server name | Inventory MCP |
| Server description | Checks and restocks product inventory. Use for inventory, stock, or restock questions. |
| Server URL | https://<default-domain>/runtime/webhooks/mcp |
| Authentication | API key |
| Parameter type | Header |
| Header name | x-functions-key |
| Key value | The mcp_extension key |

- In Select a connection, open the Connection list and select Create new connection.

- Enter a display name, paste the
mcp_extensionkey in x-functions-key, and select Create.

- The connection shows a green check. Select Add.

- Inventory MCP now appears under Tools.

Note: Copilot Studio saves the tool definitions when you add the server. If you change a tool’s metadata later, remove the MCP server and add it again. Then start a new chat.
The agent is connected to our server. Now lets test it in the preview chat.
Test the Agent
Show the dashboard
- Open the Preview tab and ask
Show me the inventory. - The agent calls
get_inventory. The dashboard appears in the chat with five products, and three are marked Low.

Restock from the dashboard
- Select Restock +5 on the Wireless Mouse row.
- The dashboard calls
restock_producton the server. The row updates from 42 to 47 and a message confirms the change.

Restock from a prompt
- Ask
Restock USB-C Hub by 10. - The agent asks for confirmation first. Reply
Yes. - The agent calls
restock_product. USB-C Hub goes from 6 to 16, and the agent lists the products that are still low.

Summary
We hosted a C# MCP server on Azure Functions and connected it to a Copilot Studio agent with an API key. Two attributes did the UI work. [McpMetadata] linked the get_inventory tool to a UI resource, and [McpResourceTrigger] served that HTML with the text/html;profile=mcp-app MIME type.
The full project is on GitHub. If you want to host the server on App Service instead, see my earlier post.
References:
- MCP tool trigger for Azure Functions
- MCP resource trigger for Azure Functions
- Use MCP apps in Copilot Studio
- MCP Apps overview
🙂



Leave a Reply