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
-86Lines changed: 0 additions & 86 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -280,92 +280,6 @@ For the complete code example, see [function_app.py](https://github.com/Azure-Sa
280
280
281
281
::: zone-end
282
282
283
-
::: zone pivot="programming-language-java"
284
-
The following code creates an endpoint to expose a resource named `Weather Widget` that serves an interactive weather display as bundled HTML content. The resource uses the `ui://` scheme to indicate it's an MCP App UI resource.
285
-
286
-
```java
287
-
@FunctionName("GetWeatherWidget")
288
-
publicString getWeatherWidget(
289
-
@McpResourceTrigger(
290
-
name="context",
291
-
uri="ui://weather/index.html",
292
-
resourceName="Weather Widget",
293
-
title="Weather Widget",
294
-
description="Interactive weather display for MCP Apps",
The `RESOURCE_METADATA` constant is defined as a JSON string that provides additional MCP metadata surfaced via the protocol's `_meta` field:
310
-
311
-
```java
312
-
privatestaticfinalStringRESOURCE_METADATA="""
313
-
{
314
-
"ui": {
315
-
"prefersBorder": true
316
-
}
317
-
}
318
-
""";
319
-
```
320
-
321
-
A tool can reference this resource by declaring a `resourceUri` in its metadata, pointing to `ui://weather/index.html`. When the tool is invoked, the MCP host fetches the resource and renders it:
322
-
323
-
```java
324
-
325
-
privatestaticfinalStringTOOL_METADATA="""
326
-
{
327
-
"ui": {
328
-
"resourceUri": "ui://weather/index.html"
329
-
}
330
-
}
331
-
""";
332
-
333
-
@FunctionName("GetWeather")
334
-
public String getWeather(
335
-
@McpToolTrigger(
336
-
name = "GetWeather",
337
-
description = "Returns current weather for a location via Open-Meteo.")
338
-
@McpMetadata(
339
-
name = "GetWeather",
340
-
json = TOOL_METADATA)
341
-
String context,
342
-
@McpToolProperty(
343
-
name = "location",
344
-
propertyType = "string",
345
-
description = "City name to check weather for (e.g., Seattle, NewYork, Miami)")
346
-
String location,
347
-
final ExecutionContext executionContext) {
348
-
Object result = weatherService.getCurrentWeather(location);
349
-
return MAPPER.writeValueAsString(result);
350
-
}
351
-
```
352
-
353
-
354
-
For the complete code example, see [McpWeatherApp](https://github.com/Azure-Samples/remote-mcp-functions-java/tree/main/samples/McpWeatherApp/src/main/java/com/function/weather).
355
-
356
-
### Dependency
357
-
358
-
Add the following dependency to your project's `pom.xml` file. The MCP annotations are included in the Azure Functions Java library starting from version **3.2.4**:
0 commit comments