Skip to content

Commit 88c9c24

Browse files
Updating MCP example code for GA surface area
1 parent ee6b411 commit 88c9c24

1 file changed

Lines changed: 22 additions & 9 deletions

File tree

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

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ private const string BlobPath = "snippets/{mcptoolargs.snippetname}.json";
3434
public string SaveSnippet(
3535
[McpToolTrigger("save_snippet", "Saves a code snippet into your snippet collection.")]
3636
ToolInvocationContext context,
37-
[McpToolProperty("snippetname", "string", "The name of the snippet.")]
37+
[McpToolProperty("snippetname", "The name of the snippet.")]
3838
string name,
39-
[McpToolProperty("snippet", "string", "The code snippet.")]
39+
[McpToolProperty("snippet", "The code snippet.")]
4040
string snippet
4141
)
4242
{
@@ -392,7 +392,7 @@ The trigger supports these binding options, which are defined in your code:
392392
| **extraOutputs** | When defined, sends function output to another binding. |
393393
| **handler** | The method that contains the actual function code. |
394394

395-
::: zone-end
395+
::: zone-end
396396

397397
::: zone pivot="programming-language-csharp,programming-language-java,programming-language-python,programming-language-javascript,programming-language-typescript"
398398

@@ -445,15 +445,16 @@ The `McpToolPropertyAttribute` type supports these properties:
445445
| Property | Description |
446446
| ---- | ----- |
447447
| **PropertyName** | Name of the tool property that gets exposed to clients. |
448-
| **PropertyType** | The data type of the tool property, such as `string`. |
449-
| **Description** | (Optional) Description of what the tool property does. |
450-
| **Required** | (Optional) If set to `true`, the tool property is required as an argument for tool calls. Defaults to `false`. |
448+
| **Description** | Description of what the tool property does. |
449+
| **IsRequired** | (Optional) If set to `true`, the tool property is required as an argument for tool calls. Defaults to `false`. |
450+
451+
The property type is inferred from the type of the parameter to which you apply the attribute. For example `[McpToolProperty("snippetname", "The name of the snippet.")] string name` defines a tool property named `snippetname` of type `string` in MCP messages.
451452

452453
You can see these attributes used in the `SaveSnippet` tool in the [Examples](#example).
453454

454455
#### [Bind to custom type](#tab/poco)
455456

456-
You can define one or more tool properties by binding to a plain-old CLR object (POCO) type that you define. Properties of that type are automatically exposed as tool properties. You can use the [Description] attribute to provide a description for each property. You can indicate that a property is required using the `required` keyword.
457+
You can define one or more tool properties by binding to a plain-old CLR object (POCO) type that you define. Properties of that type are automatically exposed as tool properties. You can use the [Description] attribute to provide a description for each property. You can indicate that a property is required using the `required` keyword. The class property type in the informs type used in MCP messages.
457458

458459
This example uses a custom type to define tool properties for the `SaveSnippet` tool:
459460

@@ -498,7 +499,7 @@ builder
498499
builder.Build().Run();
499500
```
500501

501-
You can call the `WithProperty()` method multiple times to define multiple properties for the tool.
502+
You can call the `WithProperty()` method multiple times to define multiple properties for the tool. Each call to `WithProperty()` includes a string representation of the MCP property type, which may not directly correspond to a CLR type. For example, use `"boolean"` to define a boolean property, even though the corresponding CLR type is `bool`. Valid types are: `"string"`, `"number"`, `"integer"`, `"boolean"`, `"object"`.
502503

503504
For the complete example, see the [`Program.cs` file](https://github.com/Azure-Samples/remote-mcp-functions-dotnet/blob/main/src/Program.cs).
504505

@@ -515,9 +516,21 @@ A `ToolProperty` object has this structure:
515516
"propertyName": "Name of the property",
516517
"propertyType": "Type of the property",
517518
"description": "Optional property description",
518-
"required": true|false
519+
"isRequired": true|false,
520+
"isArray": true|false
519521
}
520522
```
523+
524+
The fields of a `ToolProperty` object are:
525+
526+
| Property | Description |
527+
| ---- | ----- |
528+
| **propertyName** | Name of the tool property that gets exposed to clients. |
529+
| **propertyType** | Type of the tool property. Valid types are: `string`, `number`, `integer`, `boolean`, `object`. See `isArray` for array types. |
530+
| **description** | Description of what the tool property does. |
531+
| **isRequired** | (Optional) If set to `true`, the tool property is required as an argument for tool calls. Defaults to `false`. |
532+
| **isArray** | (Optional) If set to `true`, the tool property is an array of the specified property type. Defaults to `false`. |
533+
521534
::: zone-end
522535

523536
For more information, see [Examples](#example).

0 commit comments

Comments
 (0)