Skip to content

Commit b335b07

Browse files
committed
resolve merge conflicts
1 parent a2421d4 commit b335b07

1 file changed

Lines changed: 0 additions & 86 deletions

File tree

articles/azure-functions/functions-bindings-mcp-resource-trigger.md

Lines changed: 0 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -280,92 +280,6 @@ For the complete code example, see [function_app.py](https://github.com/Azure-Sa
280280
281281
::: zone-end
282282

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-
public String 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",
295-
mimeType = "text/html;profile=mcp-app")
296-
@McpMetadata(
297-
name = "context",
298-
json = RESOURCE_METADATA)
299-
String context,
300-
final ExecutionContext executionContext) {
301-
302-
executionContext.getLogger().info("GetWeatherWidget: serving weather widget UI");
303-
304-
java.io.File file = new java.io.File("app/dist/index.html");
305-
return java.nio.file.Files.readString(file.toPath(), StandardCharsets.UTF_8);
306-
}
307-
```
308-
309-
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-
private static final String RESOURCE_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-
private static final String TOOL_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, New York, 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**:
359-
360-
```xml name=pom.xml
361-
<dependency>
362-
<groupId>com.microsoft.azure.functions</groupId>
363-
<artifactId>azure-functions-java-library</artifactId>
364-
<version>3.2.4</version>
365-
</dependency>
366-
```
367-
::: zone-end
368-
369283
[!INCLUDE [functions-mcp-extension-powershell-note](../../includes/functions-mcp-extension-powershell-note.md)]
370284

371285
::: zone pivot="programming-language-csharp"

0 commit comments

Comments
 (0)