Require Tool inputSchema during deserialization (#1600)

This commit is contained in:
DragonFSKY 2026-06-05 16:54:07 -07:00 • committed by GitHub
commit df0c102d75
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 9 additions and 0 deletions

View file

@ -64,6 +64,7 @@ public sealed class Tool : IBaseMetadata
/// </para>
/// </remarks>
[JsonPropertyName("inputSchema")]
[JsonRequired]
public JsonElement InputSchema
{
get => field;

View file

@ -105,6 +105,14 @@ public static class ToolTests
Assert.Equal("object", typeElement.GetString());
}
[Fact]
public static void ToolInputSchema_DeserializationRejectsMissingInputSchema()
{
const string json = """{"name":"test"}""";
Assert.Throws<JsonException>(() => JsonSerializer.Deserialize<Tool>(json, McpJsonUtilities.DefaultOptions));
}
[Theory]
[InlineData("null")]
[InlineData("false")]