@@ -563,6 +563,27 @@ public async Task StructuredOutput_Disabled_ReturnsExpectedSchema<T>(T value)
563
563
Assert . Null ( result . StructuredContent ) ;
564
564
}
565
565
566
+ [ Theory ]
567
+ [ InlineData ( JsonNumberHandling . Strict ) ]
568
+ [ InlineData ( JsonNumberHandling . AllowReadingFromString ) ]
569
+ public async Task ToolWithNullableParameters_ReturnsExpectedSchema ( JsonNumberHandling nunmberHandling )
570
+ {
571
+ JsonSerializerOptions options = new ( JsonContext2 . Default . Options ) { NumberHandling = nunmberHandling } ;
572
+ McpServerTool tool = McpServerTool . Create ( ( int ? x = 42 , DateTimeOffset ? y = null ) => { } , new ( ) { SerializerOptions = options } ) ;
573
+
574
+ JsonElement expectedSchema = JsonDocument . Parse ( """
575
+ {
576
+ "type": "object",
577
+ "properties": {
578
+ "x": { "type": ["integer", "null"], "default": 42 },
579
+ "y": { "type": ["string", "null"], "format": "date-time", "default": null }
580
+ }
581
+ }
582
+ """ ) . RootElement ;
583
+
584
+ Assert . True ( JsonElement . DeepEquals ( expectedSchema , tool . ProtocolTool . InputSchema ) ) ;
585
+ }
586
+
566
587
public static IEnumerable < object [ ] > StructuredOutput_ReturnsExpectedSchema_Inputs ( )
567
588
{
568
589
yield return new object [ ] { "string" } ;
@@ -695,5 +716,7 @@ record Person(string Name, int Age);
695
716
[ JsonSerializable ( typeof ( JsonSchema ) ) ]
696
717
[ JsonSerializable ( typeof ( List < AIContent > ) ) ]
697
718
[ JsonSerializable ( typeof ( List < string > ) ) ]
719
+ [ JsonSerializable ( typeof ( int ? ) ) ]
720
+ [ JsonSerializable ( typeof ( DateTimeOffset ? ) ) ]
698
721
partial class JsonContext2 : JsonSerializerContext ;
699
722
}
0 commit comments