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