Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/ModelContextProtocol.Core/Protocol/Tool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public sealed class Tool : IBaseMetadata
{
/// <inheritdoc />
[JsonPropertyName("name")]
public string Name { get; set; } = string.Empty;
public required string Name { get; set; }

/// <inheritdoc />
[JsonPropertyName("title")]
Expand Down
5 changes: 3 additions & 2 deletions tests/ModelContextProtocol.Tests/Protocol/ToolTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public static void Tool_HasCorrectJsonPropertyNames()
[Fact]
public static void ToolInputSchema_HasValidDefaultSchema()
{
var tool = new Tool();
var tool = new Tool { Name = "test" };
JsonElement jsonElement = tool.InputSchema;

Assert.Equal(JsonValueKind.Object, jsonElement.ValueKind);
Expand All @@ -119,7 +119,7 @@ public static void ToolInputSchema_HasValidDefaultSchema()
public static void ToolInputSchema_RejectsInvalidSchemaDocuments(string invalidSchema)
{
using var document = JsonDocument.Parse(invalidSchema);
var tool = new Tool();
var tool = new Tool { Name = "test" };

Assert.Throws<ArgumentException>(() => tool.InputSchema = document.RootElement);
}
Expand All @@ -133,6 +133,7 @@ public static void ToolInputSchema_AcceptsValidSchemaDocuments(string validSchem
using var document = JsonDocument.Parse(validSchema);
Tool tool = new()
{
Name = "test",
InputSchema = document.RootElement
};

Expand Down