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
### Automatic completions with AllowedValuesAttribute
85
+
86
+
For parameters with a known set of valid values, you can use `System.ComponentModel.DataAnnotations.AllowedValuesAttribute` on `string` parameters of prompts or resource templates. The server will automatically surface those values as completions without needing a custom completion handler.
87
+
88
+
#### Prompt parameters
89
+
90
+
```csharp
91
+
[McpServerPromptType]
92
+
publicclassMyPrompts
93
+
{
94
+
[McpServerPrompt, Description("Generates a code review prompt")]
With these attributes in place, when a client sends a `completion/complete` request for the `language` or `section` argument, the server will automatically filter and return matching values based on what the user has typed so far. This approach can be combined with a custom completion handler registered via `WithCompleteHandler`; the handler's results are returned first, followed by any matching `AllowedValues`.
119
+
84
120
### Requesting completions on the client
85
121
86
122
Clients request completions using <xref:ModelContextProtocol.Client.McpClient.CompleteAsync*>. Provide a reference to the prompt or resource template, the argument name, and the current partial value:
0 commit comments