Skip to content

Commit a25abde

Browse files
Copilotjozkee
andcommitted
Change Icon.Sizes property from string to IList<string> per spec update
Co-authored-by: jozkee <16040868+jozkee@users.noreply.github.com>
1 parent 4bcbe1c commit a25abde

File tree

7 files changed

+18
-14
lines changed

7 files changed

+18
-14
lines changed

src/ModelContextProtocol.Core/Protocol/Icon.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,17 +59,17 @@ public sealed class Icon
5959
public string? MimeType { get; init; }
6060

6161
/// <summary>
62-
/// Gets or sets the optional size specification for the icon.
62+
/// Gets or sets the optional size specifications for the icon.
6363
/// </summary>
6464
/// <remarks>
6565
/// <para>
6666
/// This can specify one or more sizes at which the icon file can be used.
67-
/// Examples include "48x48", "any" for scalable formats like SVG, or "48x48 96x96" for multiple sizes.
67+
/// Examples include "48x48", "any" for scalable formats like SVG.
6868
/// </para>
6969
/// <para>
7070
/// If not provided, clients should assume that the icon can be used at any size.
7171
/// </para>
7272
/// </remarks>
7373
[JsonPropertyName("sizes")]
74-
public string? Sizes { get; init; }
74+
public IList<string>? Sizes { get; init; }
7575
}

tests/ModelContextProtocol.Tests/Protocol/IconTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public static void Icon_SerializationRoundTrip_PreservesAllProperties()
1313
{
1414
Source = "https://example.com/icon.png",
1515
MimeType = "image/png",
16-
Sizes = "48x48"
16+
Sizes = new List<string> { "48x48" }
1717
};
1818

1919
// Act - Serialize to JSON
@@ -58,7 +58,7 @@ public static void Icon_HasCorrectJsonPropertyNames()
5858
{
5959
Source = "https://example.com/icon.svg",
6060
MimeType = "image/svg+xml",
61-
Sizes = "any"
61+
Sizes = new List<string> { "any" }
6262
};
6363

6464
string json = JsonSerializer.Serialize(icon, McpJsonUtilities.DefaultOptions);

tests/ModelContextProtocol.Tests/Protocol/ImplementationTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ public static void Implementation_SerializationRoundTrip_PreservesAllProperties(
1616
Version = "1.0.0",
1717
Icons =
1818
[
19-
new() { Source = "https://example.com/icon.png", MimeType = "image/png", Sizes = "48x48" },
20-
new() { Source = "https://example.com/icon.svg", MimeType = "image/svg+xml", Sizes = "any" }
19+
new() { Source = "https://example.com/icon.png", MimeType = "image/png", Sizes = new List<string> { "48x48" } },
20+
new() { Source = "https://example.com/icon.svg", MimeType = "image/svg+xml", Sizes = new List<string> { "any" } }
2121
],
2222
WebsiteUrl = "https://example.com"
2323
};

tests/ModelContextProtocol.Tests/Protocol/PromptTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public static void Prompt_SerializationRoundTrip_PreservesAllProperties()
1616
Description = "Review the provided code",
1717
Icons =
1818
[
19-
new() { Source = "https://example.com/review-icon.svg", MimeType = "image/svg+xml", Sizes = "any" }
19+
new() { Source = "https://example.com/review-icon.svg", MimeType = "image/svg+xml", Sizes = new List<string> { "any" } }
2020
],
2121
Arguments =
2222
[

tests/ModelContextProtocol.Tests/Protocol/ResourceTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public static void Resource_SerializationRoundTrip_PreservesAllProperties()
1919
Size = 1024,
2020
Icons =
2121
[
22-
new() { Source = "https://example.com/pdf-icon.png", MimeType = "image/png", Sizes = "32x32" }
22+
new() { Source = "https://example.com/pdf-icon.png", MimeType = "image/png", Sizes = new List<string> { "32x32" } }
2323
],
2424
Annotations = new Annotations { Audience = [Role.User] }
2525
};

tests/ModelContextProtocol.Tests/Protocol/ToolTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public static void Tool_SerializationRoundTrip_PreservesAllProperties()
1616
Description = "Get current weather information",
1717
Icons =
1818
[
19-
new() { Source = "https://example.com/weather.png", MimeType = "image/png", Sizes = "48x48" }
19+
new() { Source = "https://example.com/weather.png", MimeType = "image/png", Sizes = new List<string> { "48x48" } }
2020
],
2121
Annotations = new ToolAnnotations
2222
{

tests/ModelContextProtocol.Tests/Server/McpServerToolTests.cs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -683,8 +683,8 @@ public void SupportsIconsInCreateOptions()
683683
{
684684
var icons = new List<Icon>
685685
{
686-
new() { Source = "https://example.com/icon.png", MimeType = "image/png", Sizes = "48x48" },
687-
new() { Source = "https://example.com/icon.svg", MimeType = "image/svg+xml", Sizes = "any" }
686+
new() { Source = "https://example.com/icon.png", MimeType = "image/png", Sizes = new List<string> { "48x48" } },
687+
new() { Source = "https://example.com/icon.svg", MimeType = "image/svg+xml", Sizes = new List<string> { "any" } }
688688
};
689689

690690
McpServerTool tool = McpServerTool.Create(() => "test", new McpServerToolCreateOptions
@@ -696,10 +696,14 @@ public void SupportsIconsInCreateOptions()
696696
Assert.Equal(2, tool.ProtocolTool.Icons.Count);
697697
Assert.Equal("https://example.com/icon.png", tool.ProtocolTool.Icons[0].Source);
698698
Assert.Equal("image/png", tool.ProtocolTool.Icons[0].MimeType);
699-
Assert.Equal("48x48", tool.ProtocolTool.Icons[0].Sizes);
699+
Assert.NotNull(tool.ProtocolTool.Icons[0].Sizes);
700+
Assert.Single(tool.ProtocolTool.Icons[0].Sizes);
701+
Assert.Equal("48x48", tool.ProtocolTool.Icons[0].Sizes[0]);
700702
Assert.Equal("https://example.com/icon.svg", tool.ProtocolTool.Icons[1].Source);
701703
Assert.Equal("image/svg+xml", tool.ProtocolTool.Icons[1].MimeType);
702-
Assert.Equal("any", tool.ProtocolTool.Icons[1].Sizes);
704+
Assert.NotNull(tool.ProtocolTool.Icons[1].Sizes);
705+
Assert.Single(tool.ProtocolTool.Icons[1].Sizes);
706+
Assert.Equal("any", tool.ProtocolTool.Icons[1].Sizes[0]);
703707
}
704708

705709
[Fact]

0 commit comments

Comments
 (0)