Skip to content

Commit 3156818

Browse files
Update MEAI version and add regression test for #601. (#628)
1 parent a88ef0d commit 3156818

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

Directory.Packages.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
44
<System9Version>9.0.5</System9Version>
55
<System10Version>10.0.0-preview.4.25258.110</System10Version>
6-
<MicrosoftExtensionsAIVersion>9.7.0</MicrosoftExtensionsAIVersion>
6+
<MicrosoftExtensionsAIVersion>9.7.1</MicrosoftExtensionsAIVersion>
77
</PropertyGroup>
88

99
<!-- Product dependencies netstandard -->

tests/ModelContextProtocol.Tests/Server/McpServerToolTests.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -563,6 +563,27 @@ public async Task StructuredOutput_Disabled_ReturnsExpectedSchema<T>(T value)
563563
Assert.Null(result.StructuredContent);
564564
}
565565

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+
566587
public static IEnumerable<object[]> StructuredOutput_ReturnsExpectedSchema_Inputs()
567588
{
568589
yield return new object[] { "string" };
@@ -695,5 +716,7 @@ record Person(string Name, int Age);
695716
[JsonSerializable(typeof(JsonSchema))]
696717
[JsonSerializable(typeof(List<AIContent>))]
697718
[JsonSerializable(typeof(List<string>))]
719+
[JsonSerializable(typeof(int?))]
720+
[JsonSerializable(typeof(DateTimeOffset?))]
698721
partial class JsonContext2 : JsonSerializerContext;
699722
}

0 commit comments

Comments
 (0)