-
Notifications
You must be signed in to change notification settings - Fork 689
Expand file tree
/
Copy pathIcon.cs
More file actions
85 lines (80 loc) · 3.21 KB
/
Icon.cs
File metadata and controls
85 lines (80 loc) · 3.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
using System.Text.Json.Serialization;
namespace ModelContextProtocol.Protocol;
/// <summary>
/// Represents an icon that can be used to visually identify an implementation, resource, tool, or prompt.
/// </summary>
/// <remarks>
/// <para>
/// Icons enhance user interfaces by providing visual context and improving the discoverability of available functionality.
/// Each icon includes a source URI pointing to the icon resource, and optional MIME type and size information.
/// </para>
/// <para>
/// Clients that support rendering icons MUST support at least the following MIME types:
/// </para>
/// <list type="bullet">
/// <item><description>image/png - PNG images (safe, universal compatibility)</description></item>
/// <item><description>image/jpeg (and image/jpg) - JPEG images (safe, universal compatibility)</description></item>
/// </list>
/// <para>
/// Clients that support rendering icons SHOULD also support:
/// </para>
/// <list type="bullet">
/// <item><description>image/svg+xml - SVG images (scalable but requires security precautions)</description></item>
/// <item><description>image/webp - WebP images (modern, efficient format)</description></item>
/// </list>
/// <para>
/// See the <see href="https://github.com/modelcontextprotocol/specification/blob/main/schema/">schema</see> for details.
/// </para>
/// </remarks>
public sealed class Icon
{
/// <summary>
/// Gets or sets the URI pointing to the icon resource.
/// </summary>
/// <remarks>
/// <para>
/// This can be an HTTP/HTTPS URL pointing to an image file or a data URI with base64-encoded image data.
/// </para>
/// <para>
/// Consumers SHOULD take steps to ensure URLs serving icons are from the same domain as the client/server
/// or a trusted domain.
/// </para>
/// <para>
/// Consumers SHOULD take appropriate precautions when consuming SVGs as they can contain executable JavaScript.
/// </para>
/// </remarks>
[JsonPropertyName("src")]
public required string Source { get; init; }
/// <summary>
/// Gets or sets the optional MIME type of the icon.
/// </summary>
/// <remarks>
/// This can be used to override the server's MIME type if it's missing or generic.
/// Common values include "image/png", "image/jpeg", "image/svg+xml", and "image/webp".
/// </remarks>
[JsonPropertyName("mimeType")]
public string? MimeType { get; init; }
/// <summary>
/// Gets or sets the optional size specifications for the icon.
/// </summary>
/// <remarks>
/// <para>
/// This can specify one or more sizes at which the icon file can be used.
/// Examples include "48x48", "any" for scalable formats like SVG.
/// </para>
/// <para>
/// If not provided, clients should assume that the icon can be used at any size.
/// </para>
/// </remarks>
[JsonPropertyName("sizes")]
public IList<string>? Sizes { get; init; }
/// <summary>
/// Gets or sets the optional theme for this icon.
/// </summary>
/// <remarks>
/// Can be "light", "dark", or a custom theme identifier.
/// Used to specify which UI theme the icon is designed for.
/// </remarks>
[JsonPropertyName("theme")]
public string? Theme { get; init; }
}