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
// Log the snippet name and the fetched snippet content from the blob
150
157
context.getLogger().info("Retrieving snippet with name: "+ snippetName);
151
158
context.getLogger().info("Snippet content:");
152
159
context.getLogger().info(inputBlob);
160
+
161
+
// Return the snippet content or a not found message
162
+
if (inputBlob !=null&&!inputBlob.trim().isEmpty()) {
163
+
return inputBlob;
164
+
} else {
165
+
return"Snippet '"+ snippetName +"' not found.";
166
+
}
153
167
}
154
168
```
155
169
@@ -272,17 +286,16 @@ For the complete code example, see [snippetsMcpTool.ts](https://github.com/Azure
272
286
::: zone-end
273
287
::: zone pivot="programming-language-python"
274
288
275
-
This code uses the `generic_trigger` decorator to create an endpoint to expose a tool named `save_snippet` that tries to persist a named code snippet to blob storage.
289
+
This code uses the `mcp_tool_trigger` decorator to create an endpoint to expose a tool named `save_snippet` that tries to persist a named code snippet to blob storage.
This code uses the `generic_trigger` decorator to create an endpoint to expose a tool named `get_snippet` that tries to retrieve a code snippet by name from blob storage.
315
+
This code uses the `mcp_tool_trigger` decorator to create an endpoint to expose a tool named `get_snippet` that tries to retrieve a code snippet by name from blob storage.
Retrieves a snippet by name from Azure Blob Storage.
@@ -348,34 +360,40 @@ See [Usage](#usage) to learn how to define properties of the endpoint as input p
348
360
349
361
## Annotations
350
362
351
-
The `McpTrigger` annotation creates a function that exposes a tool endpoint in your remote MCP server.
363
+
The `@McpToolTrigger` annotation creates a function that exposes a tool endpoint in your remote MCP server.
352
364
353
365
The annotation supports the following configuration options:
354
366
355
367
|Parameter | Description|
356
368
|---------|----------------------|
357
-
|**toolName**| (Required) name of the tool that's being exposed by the MCP trigger endpoint. |
369
+
|**name**| (Required) name of the tool that's being exposed by the MCP trigger endpoint. |
358
370
|**description**| (Optional) friendly description of the tool endpoint for clients. |
359
-
|**toolProperties**| The JSON string representation of one or more property objects that expose properties of the tool to clients. |
371
+
372
+
The `@McpToolProperty` annotation defines individual properties for your tools. Each property parameter in your function should be annotated with this annotation.
373
+
374
+
The `@McpToolProperty` annotation supports the following configuration options:
375
+
376
+
|Parameter | Description|
377
+
|---------|----------------------|
378
+
|**name**| (Required) name of the tool property that gets exposed to clients. |
379
+
|**propertyType**| (Required) type of the tool property. Valid types are: `string`, `number`, `integer`, `boolean`, `object`. |
380
+
|**description**| (Optional) description of what the tool property does. |
381
+
|**required**| (Optional) if set to `true`, the tool property is required as an argument for tool calls. Defaults to `false`. |
360
382
361
383
::: zone-end
362
384
::: zone pivot="programming-language-python"
363
385
## Decorators
364
386
365
387
_Applies only to the Python v2 programming model._
366
388
367
-
>[!NOTE]
368
-
>At this time, you must use a generic decorator to define an MCP trigger.
369
-
370
-
The following MCP trigger properties are supported on `generic_trigger`:
389
+
The `mcp_tool_trigger` decorator requires version 1.24.0 or later of the [`azure-functions` package](https://pypi.org/project/azure-functions/). The following MCP trigger properties are supported on `mcp_tool_trigger`:
371
390
372
391
| Property | Description |
373
392
|-------------|-----------------------------|
374
-
|**type**| (Required) Must be set to `mcpToolTrigger` in the `generic_trigger` decorator. |
375
393
|**arg_name**| The variable name (usually `context`) used in function code to access the execution context. |
376
-
|**toolName**| (Required) The name of the MCP server tool exposed by the function endpoint. |
394
+
|**tool_name**| (Required) The name of the MCP server tool exposed by the function endpoint. |
377
395
|**description**| A description of the MCP server tool exposed by the function endpoint. |
378
-
|**toolProperties**| The JSON string representation of one or more property objects that expose properties of the tool to clients. |
396
+
|**tool_properties**| The JSON string representation of one or more property objects that expose properties of the tool to clients. |
379
397
380
398
::: zone-end
381
399
::: zone pivot="programming-language-javascript,programming-language-typescript"
@@ -506,7 +524,12 @@ For the complete example, see the [`Program.cs` file](https://github.com/Azure-S
506
524
---
507
525
508
526
::: zone-end
509
-
::: zone pivot="programming-language-java,programming-language-python,programming-language-javascript,programming-language-typescript"
527
+
::: zone pivot="programming-language-java"
528
+
In Java, you define tool properties by using the `@McpToolProperty` annotation on individual function parameters. Each parameter that represents a tool property should be annotated with this annotation, specifying the property name, type, description, and whether it's required.
529
+
530
+
You can see these annotations used in the [Examples](#example).
531
+
::: zone-end
532
+
::: zone pivot="programming-language-python,programming-language-javascript,programming-language-typescript"
510
533
You can configure tool properties in the trigger definition's `toolProperties` field, which is a string representation of an array of `ToolProperty` objects.
Copy file name to clipboardExpand all lines: articles/azure-functions/functions-bindings-mcp.md
+26-7Lines changed: 26 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -40,14 +40,33 @@ The Azure Functions MCP extension allows you to use Azure Functions to create re
40
40
Add the extension to your project by installing this [NuGet package](https://www.nuget.org/packages/Microsoft.Azure.Functions.Worker.Extensions.Mcp) in your preferred way:
41
41
42
42
`Microsoft.Azure.Functions.Worker.Extensions.Mcp`
43
-
::: zone-end
44
-
::: zone pivot="programming-language-javascript,programming-language-typescript,programming-language-python,programming-language-java"
45
-
<!---At GA, replace with:
43
+
::: zone-end
44
+
::: zone pivot="programming-language-java"
45
+
+ Requires version 3.2.1 or later of the [`azure-functions-java-library` dependency](https://central.sonatype.com/artifact/com.microsoft.azure.functions/azure-functions-java-library).
46
+
+ Requires version **TBD** or later of the [`azure-functions-maven-plugin` dependency](https://central.sonatype.com/artifact/com.microsoft.azure.functions/azure-functions-maven-plugin).
47
+
::: zone-end
48
+
::: zone pivot="programming-language-javascript,programming-language-typescript"
49
+
+ Requires version 4.8.0 or later of the [`@azure/functions` dependency](https://www.npmjs.com/package/@azure/functions)
50
+
::: zone-end
51
+
::: zone pivot="programming-language-python"
52
+
+ Requires version 1.24.0 or later of the [`azure-functions` package](https://pypi.org/project/azure-functions/).
53
+
::: zone-end
54
+
::: zone pivot="programming-language-javascript,programming-language-typescript,programming-language-python,programming-language-java"
> A generally available version of the extension is now available. However, it isn’t yet included in the default extension bundle. The instructions show how to use the preview extension bundle, which includes an earlier preview version of the MCP extension, along with other preview dependencies. For now, to use the generally available version of the extension, you must [manually install the extension](./functions-bindings-register.md#explicitly-install-extensions).
The MCP extension specifically requires bundle version 4.28.0 or later. You can ensure you get this version by specifying it as the minimum version in your `host.json` file:
0 commit comments