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
{{ message }}
Repository navigation
Prompt parameters of type bool fail when the client sends "true" or "false" #2040
A prompt with a bool parameter fails when the client sends the argument as a string, which is how the spec defines prompt arguments (arguments: { [key: string]: string }). The client only gets Request failed (remote): An error occurred.
Numbers sent as strings work, because McpJsonUtilities.DefaultOptions sets JsonNumberHandling.AllowReadingFromString. System.Text.Json has no equivalent for booleans, so "true" can't be read into a bool. Resource templates don't have this problem: AIFunctionMcpServerResource converts each URI value with bool.Parse, int.Parse and so on.
awaitclient.GetPromptAsync("count_prompt",newDictionary<string,object?>{["count"]="5"});// count=5awaitclient.GetPromptAsync("bool_prompt",newDictionary<string,object?>{["formal"]="true"});// McpProtocolException: Request failed (remote): An error occurred.
Same with bool?. Tested with ModelContextProtocol 2.4.0 and with main (90476da).
Expected behavior
"true" and "false" bind to bool and bool? prompt parameters, like numeric strings already bind to numeric parameters. A value that isn't a boolean gives an error that names the parameter.
Possible fix
Add a parameter binder for bool and bool? in AIFunctionMcpServerPrompt.CreateAIFunctionFactoryOptions, next to the existing service binders, that accepts JSON true/false and the strings "true"/"false". Other types don't need it: enums, dates, Guid and TimeSpan are already read from strings by their JSON converters. I have a PR with tests ready.
Activity