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
@@ -180,11 +187,11 @@ The function code for the MCP server tools is defined in the `src` folder. The `
180
187
You can view the complete project template in the [Azure Functions .NET MCP Server](https://github.com/Azure-Samples/remote-mcp-functions-dotnet) GitHub repository.
181
188
::: zone-end
182
189
::: zone pivot="programming-language-java"
183
-
The function code for the MCP server tools is defined in the `src/main/java/com/function/` folder. The `@McpToolTrigger` annotation exposes the functions as MCP Server tools:
190
+
The function code for the MCP server tools is defined in the `samples/FunctionsMcpTool/src/main/java/com/function/` folder. The `@McpToolTrigger` annotation exposes the functions as MCP Server tools:
You can view the complete project template in the [Azure Functions Java MCP Server](https://github.com/Azure-Samples/remote-mcp-functions-java) GitHub repository.
Copy file name to clipboardExpand all lines: articles/azure-functions/scenario-mcp-apps.md
+92-28Lines changed: 92 additions & 28 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -21,9 +21,9 @@ After running the project locally and verifying your code by using GitHub Copilo
21
21
22
22
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.
23
23
24
-
::: zone pivot="programming-language-javascript,programming-language-java"
24
+
::: zone pivot="programming-language-javascript"
25
25
> [!IMPORTANT]
26
-
> While [creating MCP Apps](./functions-bindings-mcp.md) is supported for Java and JavaScript, this 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.
26
+
> While [creating MCP Apps](./functions-bindings-mcp.md) is supported for JavaScript, this quickstart currently only has examples for C#, Java, Python, and TypeScript. To complete this quickstart, select one of these supported languages at the top of the article.
+ If you use another [supported version of Java](supported-languages.md?pivots=programming-language-java#languages-by-runtime-version), update the project's `pom.xml` file.
46
+
+ Set the `JAVA_HOME` environment variable to the install location of the correct version of the Java Development Kit (JDK).
47
+
+[Apache Maven 3.8.x](https://maven.apache.org)
48
+
::: zone-end
43
49
<!-- replace when supported
44
50
::: zone pivot="programming-language-javascript,programming-language-typescript" -->
45
51
::: zone pivot="programming-language-typescript"
@@ -57,7 +63,7 @@ This article supports version 2 of the Python programming model for Azure Functi
57
63
58
64
+[Azure Developer CLI](/azure/developer/azure-developer-cli/install-azd) version 1.23.x or a later version
59
65
::: zone-end
60
-
::: zone pivot="programming-language-python,programming-language-typescript"
66
+
::: zone pivot="programming-language-java,programming-language-python,programming-language-typescript"
61
67
+[Node.js](https://nodejs.org/) (required to build the MCP Apps UI)
62
68
63
69
+[Visual Studio Code](https://code.visualstudio.com/) with these extensions:
@@ -66,7 +72,7 @@ This article supports version 2 of the Python programming model for Azure Functi
This command pulls the project files from the [template repository](https://github.com/Azure-Samples/remote-mcp-functions-dotnet) and initializes the project in the current folder. The -e flag sets a name for the current environment. In `azd`, the environment maintains a unique deployment context for your app, and you can define more than one. It's also used in names of the resources you create in Azure.
95
+
This command pulls the project files from the [template repository](https://github.com/Azure-Samples/remote-mcp-functions-dotnet) and initializes the project in the current folder. The -e flag sets a name for the current environment. In `azd`, the environment maintains a unique deployment context for your app, and you can define more than one. It's also used in names of the resources you create in Azure.
96
+
::: zone-end
97
+
::: zone pivot="programming-language-java,programming-language-python,programming-language-typescript"
98
+
2. Press <kbd>F1</kbd> to open the command palette. Search for and run `Azure Developer CLI (azd): init`.
99
+
100
+
3. When prompted, select **Select a template**.
96
101
::: zone-end
97
102
::: zone pivot="programming-language-typescript"
98
103
4. Search for and select **Remote MCP Functions with TypeScript**.
@@ -108,7 +113,14 @@ Use the Azure Developer CLI to create an Azure Functions code project from a tem
108
113
109
114
The command pulls the project files from the [template repository](https://github.com/Azure-Samples/remote-mcp-functions-python) and initializes the project in the current folder. In `azd`, the environment maintains a unique deployment context for your app, and you can define more than one. It's also used in the names of the resources you create in Azure.
110
115
::: zone-end
111
-
::: zone pivot="programming-language-csharp,programming-language-python,programming-language-typescript"
116
+
::: zone pivot="programming-language-java"
117
+
4. Search for and select **Remote MCP Functions with Java**.
118
+
119
+
5. When prompted, enter `mcpweather-java` as the environment name.
120
+
121
+
The command pulls the project files from the [template repository](https://github.com/Azure-Samples/remote-mcp-functions-java) and initializes the project in the current folder. In `azd`, the environment maintains a unique deployment context for your app, and you can define more than one. It's also used in names of the resources you create in Azure.
122
+
::: zone-end
123
+
::: zone pivot="programming-language-csharp,programming-language-java,programming-language-python,programming-language-typescript"
@@ -128,6 +140,18 @@ The MCP Apps weather tool includes a frontend application that you must build be
128
140
cd ../
129
141
```
130
142
143
+
::: zone-end
144
+
::: zone pivot="programming-language-java"
145
+
146
+
1. In the terminal, go to the UI app folder and build the application:
147
+
148
+
```console
149
+
cd samples/McpWeatherApp/app
150
+
npm install
151
+
npm run build
152
+
cd ..
153
+
```
154
+
131
155
::: zone-end
132
156
::: zone pivot="programming-language-python"
133
157
@@ -169,13 +193,16 @@ The MCP Apps weather tool includes a frontend application that you must build be
169
193
```
170
194
171
195
::: zone-end
172
-
::: zone pivot="programming-language-csharp,programming-language-python,programming-language-typescript"
196
+
::: zone pivot="programming-language-csharp,programming-language-java,programming-language-python,programming-language-typescript"
173
197
## Run your MCP server locally
174
198
::: zone-end
175
199
::: zone pivot="programming-language-csharp"
176
200
When prompted, select **src/McpWeatherApp**. You see this prompt because there are two projects in the solution, and the other project isn't used by this article.
177
201
::: zone-end
178
-
::: zone pivot="programming-language-csharp,programming-language-python,programming-language-typescript"
202
+
::: zone pivot="programming-language-java"
203
+
In a terminal window, make sure you're in the `samples/McpWeatherApp` project folder.
204
+
::: zone-end
205
+
::: zone pivot="programming-language-csharp,programming-language-java,programming-language-python,programming-language-typescript"
@@ -204,50 +231,85 @@ You can review the code that defines the MCP Apps tools. An MCP Apps tool requir
204
231
+ A **resource** that serves the bundled HTML/JavaScript at the matching `ui://` URI.
205
232
::: zone-end
206
233
::: zone pivot="programming-language-csharp"
207
-
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:
234
+
The function code for the MCP Apps weather tool is defined in the `src/McpWeatherApp` folder. In this function, the `[McpMetadata]` attribute adds UI metadata to the `GetWeather` tool.
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]`.
242
+
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]`.
214
247
215
248
You can view the complete project template in the [Azure Functions .NET MCP Server](https://github.com/Azure-Samples/remote-mcp-functions-dotnet) GitHub repository.
216
249
::: zone-end
217
250
::: zone pivot="programming-language-python"
218
-
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:
251
+
The function code for the MCP Apps weather tool is defined in the `src/function_app.py` file. In this function, the `metadata` parameter on `@app.mcp_tool()` adds UI metadata to the `get_weather` tool.
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 `@app.mcp_resource_trigger()` method serves the HTML widget. The `get_weather_widget` functionserves the bundled HTML file at that URI using `@app.mcp_resource_trigger()`:
255
+
The `@app.mcp_resource_trigger()` decorator is applied to the `get_weather_widget` function, which 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()`.
264
+
226
265
You can view the complete project template in the [Azure Functions Python MCP Server](https://github.com/Azure-Samples/remote-mcp-functions-python) GitHub repository.
227
266
::: zone-end
228
267
::: zone pivot="programming-language-typescript"
229
-
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:
268
+
The function code for the MCP Apps weather tool is defined in the `src/functions/weatherMcpApp.ts` file. In this function, the `metadata` property on `app.mcpTool()` adds UI metadata to the `getWeather` tool when it's registered.
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.
240
285
241
-
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()`.
You can view the complete project template in the [Azure Functions TypeScript MCP Server](https://github.com/Azure-Samples/remote-mcp-functions-typescript) GitHub repository.
244
289
::: zone-end
245
-
::: zone pivot="programming-language-csharp,programming-language-python,programming-language-typescript"
290
+
::: zone pivot="programming-language-java"
291
+
The function code for the MCP Apps weather tool is defined in the `samples/McpWeatherApp` folder. In this function, the `@McpMetadata` annotation adds UI metadata to the `GetWeather` tool.
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` function serves the bundled HTML file at that URI using `@McpResourceTrigger`.
304
+
305
+
You can view the complete project template in the [Azure Functions Java MCP Server](https://github.com/Azure-Samples/remote-mcp-functions-java) GitHub repository.
306
+
::: zone-end
307
+
::: zone pivot="programming-language-csharp,programming-language-java,programming-language-python,programming-language-typescript"
246
308
After verifying the MCP Apps tools locally, you can publish the project to Azure.
247
309
248
310
## Deploy to Azure
249
311
::: zone-end
250
-
::: zone pivot="programming-language-python,programming-language-typescript"
312
+
::: zone pivot="programming-language-java,programming-language-python,programming-language-typescript"
@@ -274,15 +336,17 @@ This project is configured to use `azd` to deploy this project to a new function
274
336
| _Azure subscription_ | Subscription in which your resources are created. |
275
337
| _Azure location_ | Azure region in which to create the resource group that contains the new Azure resources. Only regions that currently support the Flex Consumption plan are shown. |
276
338
| _vnetEnabled_ | `False` to skip creating virtual network resources, which simplifies the deployment. |
277
-
When prompted, pick your subscription, an Azure region for the resources, and choose `false` to skip creating virtual network resources to simplify the deployment.
339
+
340
+
When prompted, pick your subscription, an Azure region for the resources, and choose `false` to skip creating virtual network resources to simplify the deployment.
278
341
279
342
1. Run the `azd deploy` command to deploy the `weather` app to Azure:
280
343
281
344
```console
282
345
azd deploy --service weather
283
346
```
284
-
::: zone-end
285
347
348
+
::: zone-end
349
+
::: zone pivot="programming-language-csharp,programming-language-java,programming-language-python,programming-language-typescript"
0 commit comments