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
[McpToolTrigger("save_snippet", "Saves a code snippet into your snippet collection.")]
36
36
ToolInvocationContextcontext,
37
-
[McpToolProperty("snippetname", "string", "The name of the snippet.")]
37
+
[McpToolProperty("snippetname", "The name of the snippet.")]
38
38
stringname,
39
-
[McpToolProperty("snippet", "string", "The code snippet.")]
39
+
[McpToolProperty("snippet", "The code snippet.")]
40
40
stringsnippet
41
41
)
42
42
{
@@ -392,7 +392,7 @@ The trigger supports these binding options, which are defined in your code:
392
392
|**extraOutputs**| When defined, sends function output to another binding. |
393
393
|**handler**| The method that contains the actual function code. |
394
394
395
-
::: zone-end
395
+
::: zone-end
396
396
397
397
::: zone pivot="programming-language-csharp,programming-language-java,programming-language-python,programming-language-javascript,programming-language-typescript"
398
398
@@ -445,15 +445,16 @@ The `McpToolPropertyAttribute` type supports these properties:
445
445
| Property | Description |
446
446
| ---- | ----- |
447
447
|**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.
451
452
452
453
You can see these attributes used in the `SaveSnippet` tool in the [Examples](#example).
453
454
454
455
#### [Bind to custom type](#tab/poco)
455
456
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.
457
458
458
459
This example uses a custom type to define tool properties for the `SaveSnippet` tool:
459
460
@@ -498,7 +499,7 @@ builder
498
499
builder.Build().Run();
499
500
```
500
501
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"`.
502
503
503
504
For the complete example, see the [`Program.cs` file](https://github.com/Azure-Samples/remote-mcp-functions-dotnet/blob/main/src/Program.cs).
504
505
@@ -515,9 +516,21 @@ A `ToolProperty` object has this structure:
515
516
"propertyName": "Name of the property",
516
517
"propertyType": "Type of the property",
517
518
"description": "Optional property description",
518
-
"required": true|false
519
+
"isRequired": true|false,
520
+
"isArray": true|false
519
521
}
520
522
```
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`. |
0 commit comments