You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/azure-functions/functions-bindings-mcp-resource-trigger.md
+16-6Lines changed: 16 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -21,7 +21,7 @@ For information on setup and configuration details, see the [overview](functions
21
21
> For C#, the Azure Functions MCP extension supports only the [isolated worker model](dotnet-isolated-process-guide.md).
22
22
::: zone-end
23
23
24
-
::: zone pivot="programming-language-csharp,programming-language-python,programming-language-typescript"
24
+
::: zone pivot="programming-language-csharp,programming-language-python,programming-language-typescript,programming-language-javascript"
25
25
## Example 1
26
26
27
27
Example 1 shows how to leverage resource to implement the UI element of MCP Apps.
@@ -125,12 +125,15 @@ In this example, a folder called `assets` containing the `readme` is bundled wit
125
125
</ItemGroup>
126
126
```
127
127
128
-
The `PreserveNewest` directive copies everything under `assets` into the build output, preserving the folder structure. When deployed to Azure Functions, these files are extracted to the function app root directory (`%HOME%\site\wwwroot`), so a file at `assets/readme.md` in the project is accessible at runtime via `Path.Combine(AppContext.BaseDirectory, "assets", "readme.md")`. This works the same way both locally and when deployed to Azure. The asset files are packaged with the deployment artifact rather than uploaded separately to external storage. For the complete code example, see the [Azure Functions MCP Extension repo](https://github.com/Azure/azure-functions-mcp-extension/tree/main/test/TestAppIsolated).
128
+
For the complete code example, see the [Azure Functions MCP Extension repo](https://github.com/Azure/azure-functions-mcp-extension/tree/main/test/TestAppIsolated).
129
129
130
130
::: zone-end
131
131
132
132
::: zone pivot="programming-language-java"
133
-
The MCP extention in Java does not support resource today.
133
+
134
+
> [!IMPORTANT]
135
+
> The MCP extension in Java does _not_ support resource today.
136
+
134
137
::: zone-end
135
138
136
139
::: zone pivot="programming-language-javascript"
@@ -215,7 +218,9 @@ app.mcpTool("getWeather", {
215
218
For the complete code example, see [weatherMcpApp.ts](https://github.com/Azure-Samples/remote-mcp-functions-typescript/blob/McpAppDemo/src/functions/weatherMcpApp.ts).
216
219
217
220
> [!NOTE]
218
-
> The MCP resource trigger for TypeScript requires version `4.12.0-preview.2` or later of the [`@azure/functions`](https://www.npmjs.com/package/@azure/functions/v/4.12.0-preview.2) package, which is in _preview_ extension bundle version `[4.32.0, 5.0.0)`. Check `host.json` to make sure the correct bundle version is specified:
221
+
> The MCP resource trigger for TypeScript requires version `4.12.0-preview.2` or later of the [`@azure/functions`](https://www.npmjs.com/package/@azure/functions/v/4.12.0-preview.2) package.
222
+
>
223
+
> The function app must include the preview extension bundle version `[4.32.0, 5.0.0)`. Check `host.json` to make sure the correct bundle version is specified:
For the complete code example, see [function_app.py](https://github.com/Azure-Samples/remote-mcp-functions-python/blob/main/src).
289
294
290
295
> [!NOTE]
291
-
> The MCP resource trigger for Python requires version `1.25.0b3` or later of the [`azure-functions`](https://pypi.org/project/azure-functions/1.25.0b3/) package, which is in _preview_ extension bundle version `[4.32.0, 5.0.0)`. Check `host.json` to make sure the correct bundle version is specified:
296
+
> The MCP resource trigger for Python requires version `1.25.0b3` or later of the [`azure-functions`](https://pypi.org/project/azure-functions/1.25.0b3/) package.
297
+
>
298
+
> If the app is using Python 3.9 - 3.12, add the following app setting to `local.settings.json` if running locally or as an environment variable if running in production: `PYTHON_ISOLATE_WORKER_DEPENDENCIES: 1`.
299
+
>
300
+
> Using this feature requires the preview extension bundle version `[4.32.0, 5.0.0)`. Check host.json to make sure the correct bundle version is specified:
Copy file name to clipboardExpand all lines: articles/azure-functions/scenario-mcp-apps.md
+38-20Lines changed: 38 additions & 20 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,31 +1,34 @@
1
1
---
2
2
title: Build an MCP Apps server using Azure Functions
3
-
description: "Learn how to create and deploy an MCP Apps server that returns interactive UI using Azure Functions. This quickstart uses the Azure Developer CLI to deploy an MCP Apps project that enables AI clients to access tools with rich interactive interfaces hosted on Azure's Flex Consumption plan."
3
+
description: "Learn how to create and deploy an MCP App that returns interactive UI using Azure Functions. This quickstart uses the Azure Developer CLI to deploy an MCP App project that enables AI clients to access tools with rich interactive interfaces hosted on Azure's Flex Consumption plan."
#Customer intent: As a developer, I want to create an MCP Apps server that returns interactive UI from my MCP tools, so AI clients can render rich visual experiences using Azure Functions.
11
+
#Customer intent: As a developer, I want to create an MCP Apps that returns interactive UI from my MCP tools, so AI clients can render rich visual experiences using Azure Functions.
12
12
---
13
13
14
-
# Quickstart: Build an MCP Apps server using Azure Functions
14
+
# Quickstart: Build an MCP Apps using Azure Functions
15
15
16
-
In this quickstart, you create an MCP Apps server from a template project by using the Azure Developer CLI (`azd`). [MCP Apps](https://blog.modelcontextprotocol.io/posts/2026-01-26-mcp-apps/) is an extension of the Model Context Protocol (MCP) specification that lets tools return interactive elements instead of plain text.
16
+
In this quickstart, you create an [MCP App](https://blog.modelcontextprotocol.io/posts/2026-01-26-mcp-apps/)from a template project by using the Azure Developer CLI (`azd`). [MCP Apps](https://blog.modelcontextprotocol.io/posts/2026-01-26-mcp-apps/) is an extension of the Model Context Protocol (MCP) specification that lets tools return rich, interactive user interfaces (HTML/JavaScript in sandboxed iframes) instead of plain text.
17
17
18
-
The MCP server you create uses the Azure Functions MCP server extension to provide tools with rich UI for AI models, agents, and assistants. After running the project locally and verifying your code by using GitHub Copilot, you deploy it to a new serverless function app in Azure Functions that follows current best practices for secure and scalable deployments.
18
+
This quickstart will use the Azure Functions MCP extension to build an MCP App using the MCP tool and resource trigger. After running the project locally and verifying your code by using GitHub Copilot, you deploy it to a new serverless function app in Azure Functions that follows current best practices for secure and scalable deployments.
19
19
20
20
>[!TIP]
21
-
>If you want to create a custom MCP server that uses text-based tools instead of interactive UI, see [Quickstart: Build a custom remote MCP server using Azure Functions](scenario-custom-remote-mcp-server.md).
21
+
>MCP tools built with the Azure Functions MCP extension don't have to return results in interactive UIs. If your server only needs text-based tools, see [Quickstart: Build a custom remote MCP server using Azure Functions](scenario-custom-remote-mcp-server.md).
22
22
23
23
Because the new app runs on the Flex Consumption plan, which follows a _pay-for-what-you-use_ billing model, completing this quickstart incurs a small cost of a few USD cents or less in your Azure account.
24
24
25
-
::: zone pivot="programming-language-javascript,programming-language-java,programming-language-powershell"
25
+
::: zone pivot="programming-language-javascript,programming-language-java"
26
26
> [!IMPORTANT]
27
-
> While [creating custom MCP servers](./functions-bindings-mcp.md) is supported for all Functions languages, this MCP Apps quickstart currently only has examples for C#, Python, and TypeScript. To complete this quickstart, select one of these supported languages at the top of the article.
27
+
> While [creating custom MCP servers](./functions-bindings-mcp.md) is supported for Java and JavaScript, this MCP Apps quickstart currently only has examples for C#, Python, and TypeScript. To complete this quickstart, select one of these supported languages at the top of the article.
This article supports version 4 of the Node.js programming model for Azure Functions.
31
34
::: zone-end
@@ -49,10 +52,9 @@ This article supports version 2 of the Python programming model for Azure Functi
49
52
::: zone pivot="programming-language-csharp,programming-language-python,programming-language-typescript"
50
53
+[Node.js](https://nodejs.org/) (required to build the MCP Apps UI)
51
54
52
-
+[Visual Studio Code](https://code.visualstudio.com/) with these extensions:
55
+
+[Visual Studio Code Insiders](https://code.visualstudio.com/insiders) with these extensions:
53
56
54
57
+[Azure Functions extension](https://marketplace.visualstudio.com/items?itemName=ms-azuretools.vscode-azurefunctions). This extension requires [Azure Functions Core Tools](functions-run-local.md) and attempts to install it when not available.
@@ -61,6 +63,9 @@ This article supports version 2 of the Python programming model for Azure Functi
61
63
62
64
+ An Azure account with an active subscription. [Create an account for free](https://azure.microsoft.com/pricing/purchase-options/azure-account?cid=msft_learn).
63
65
66
+
> [!IMPORTANT]
67
+
> MCP Apps require [Visual Studio Code Insiders](https://code.visualstudio.com/insiders). The stable release of VS Code doesn't yet support rendering MCP App UI resources.
68
+
64
69
## Initialize the project
65
70
66
71
Use the Azure Developer CLI to create an Azure Functions code project from a template.
@@ -110,7 +115,7 @@ The MCP Apps weather tool includes a frontend application that you must build be
110
115
cd src/McpWeatherApp/app
111
116
npm install
112
117
npm run build
113
-
cd ../../..
118
+
cd ../
114
119
```
115
120
116
121
::: zone-end
@@ -122,9 +127,18 @@ The MCP Apps weather tool includes a frontend application that you must build be
122
127
cd src/app
123
128
npm install
124
129
npm run build
125
-
cd ../..
130
+
cd ../
131
+
```
132
+
133
+
1. In the `/src` directory, install Python dependencies:
134
+
135
+
```console
136
+
pip install -r requirements.txt
126
137
```
127
138
139
+
> [!NOTE]
140
+
> It is a best practice to create a virtual environment before doing the pip install to avoid dependency issues or collisions, or if you are running in CodeSpaces. See [Python Environments in VS Code](https://code.visualstudio.com/docs/python/environments) for more information.
141
+
128
142
::: zone-end
129
143
::: zone pivot="programming-language-typescript"
130
144
@@ -177,9 +191,9 @@ You can review the code that defines the MCP Apps tools. An MCP Apps tool requir
177
191
::: zone pivot="programming-language-csharp"
178
192
The function code for the MCP Apps weather tool is defined in the `src/McpWeatherApp` folder. The `[McpMetadata]` attribute adds UI metadata to the tool, and the `[McpResourceTrigger]` attribute serves the HTML widget:
The `ToolMetadata` constant declares a `ui.resourceUri` that tells the MCP host to fetch the interactive UI from `ui://weather/index.html` after the tool runs. The `GetWeatherWidget` function serves the bundled HTML file at that URI using `[McpResourceTrigger]`.
185
199
@@ -188,11 +202,9 @@ You can view the complete project template in the [Azure Functions .NET MCP Serv
188
202
::: zone pivot="programming-language-python"
189
203
The function code for the MCP Apps weather tool is defined in the `src/function_app.py` file. The `metadata` parameter on `@app.mcp_tool()` adds UI metadata to the tool, and `@app.mcp_resource_trigger()` serves the HTML widget:
The `TOOL_METADATA` constant declares a `ui.resourceUri` that tells the MCP host to fetch the interactive UI from `ui://weather/index.html` after the tool runs. The `get_weather_widget` function serves the bundled HTML file at that URI using `@app.mcp_resource_trigger()`.
198
210
@@ -201,9 +213,15 @@ You can view the complete project template in the [Azure Functions Python MCP Se
201
213
::: zone pivot="programming-language-typescript"
202
214
The function code for the MCP Apps weather tool is defined in the `src/functions/weatherMcpApp.ts` file. The `metadata` property on `app.mcpTool()` adds UI metadata to the tool, and `app.mcpResource()` serves the HTML widget:
The `TOOL_METADATA` constant declares a `ui.resourceUri` that tells the MCP host to fetch the interactive UI from `ui://weather/index.html` after the tool runs. The `getWeatherWidget` handler serves the bundled HTML file at that URI when registered with `app.mcpResource()`.
0 commit comments