Skip to content

Commit 50e29c5

Browse files
Add examples of icons on tools, resources, prompts, and server implementation to EverythingServer (#1096)
Co-authored-by: Stephen Halter <[email protected]>
1 parent 14f9735 commit 50e29c5

File tree

4 files changed

+66
-5
lines changed

4 files changed

+66
-5
lines changed

samples/EverythingServer/Program.cs

Lines changed: 63 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,33 @@
2121
ConcurrentDictionary<string, ConcurrentDictionary<string, byte>> subscriptions = new();
2222

2323
builder.Services
24-
.AddMcpServer()
24+
.AddMcpServer(options =>
25+
{
26+
// Configure server implementation details with icons and website
27+
options.ServerInfo = new Implementation
28+
{
29+
Name = "Everything Server",
30+
Version = "1.0.0",
31+
Title = "MCP Everything Server",
32+
Description = "A comprehensive MCP server demonstrating tools, prompts, resources, sampling, and all MCP features",
33+
WebsiteUrl = "https://github.com/modelcontextprotocol/csharp-sdk",
34+
Icons = [
35+
new Icon
36+
{
37+
Source = "https://raw.githubusercontent.com/microsoft/fluentui-emoji/62ecdc0d7ca5c6df32148c169556bc8d3782fca4/assets/Gear/Flat/gear_flat.svg",
38+
MimeType = "image/svg+xml",
39+
Sizes = ["any"],
40+
Theme = "light"
41+
},
42+
new Icon
43+
{
44+
Source = "https://raw.githubusercontent.com/microsoft/fluentui-emoji/62ecdc0d7ca5c6df32148c169556bc8d3782fca4/assets/Gear/3D/gear_3d.png",
45+
MimeType = "image/png",
46+
Sizes = ["256x256"]
47+
}
48+
]
49+
};
50+
})
2551
.WithHttpTransport(options =>
2652
{
2753
// Add a RunSessionHandler to remove all subscriptions for the session when it ends
@@ -53,7 +79,42 @@
5379
})
5480
.WithTools<AddTool>()
5581
.WithTools<AnnotatedMessageTool>()
56-
.WithTools<EchoTool>()
82+
.WithTools([
83+
// EchoTool with complex icon configuration demonstrating multiple icons,
84+
// MIME types, size specifications, and theme preferences
85+
McpServerTool.Create(
86+
typeof(EchoTool).GetMethod(nameof(EchoTool.Echo))!,
87+
options: new McpServerToolCreateOptions
88+
{
89+
Icons = [
90+
// High-resolution PNG icon for light theme
91+
new Icon
92+
{
93+
Source = "https://raw.githubusercontent.com/microsoft/fluentui-emoji/62ecdc0d7ca5c6df32148c169556bc8d3782fca4/assets/Loudspeaker/Flat/loudspeaker_flat.svg",
94+
MimeType = "image/svg+xml",
95+
Sizes = ["any"],
96+
Theme = "light"
97+
},
98+
// 3D icon for dark theme
99+
new Icon
100+
{
101+
Source = "https://raw.githubusercontent.com/microsoft/fluentui-emoji/62ecdc0d7ca5c6df32148c169556bc8d3782fca4/assets/Loudspeaker/3D/loudspeaker_3d.png",
102+
MimeType = "image/png",
103+
Sizes = ["256x256"],
104+
Theme = "dark"
105+
},
106+
// WebP format for modern browsers
107+
// Demonstrates Data URI representation with the smallest possible valid WebP image (1x1 pixel).
108+
// This will appear as a white box when rendered by a browser at 32x32
109+
new Icon
110+
{
111+
Source = "data:image/webp;base64,UklGRiQAAABXRUJQVlA4IBgAAAAwAQCdASoBAAEAAwA0JaQAA3AA/vuUAAA=",
112+
MimeType = "image/webp",
113+
Sizes = ["32x32"]
114+
}
115+
]
116+
})
117+
])
57118
.WithTools<LongRunningTool>()
58119
.WithTools<PrintEnvTool>()
59120
.WithTools<SampleLlmTool>()

samples/EverythingServer/Prompts/SimplePromptType.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ namespace EverythingServer.Prompts;
66
[McpServerPromptType]
77
public class SimplePromptType
88
{
9-
[McpServerPrompt(Name = "simple_prompt"), Description("A prompt without arguments")]
9+
[McpServerPrompt(Name = "simple_prompt", IconSource = "https://raw.githubusercontent.com/microsoft/fluentui-emoji/62ecdc0d7ca5c6df32148c169556bc8d3782fca4/assets/Light%20bulb/Flat/light_bulb_flat.svg"), Description("A prompt without arguments")]
1010
public static string SimplePrompt() => "This is a simple prompt without arguments";
1111
}

samples/EverythingServer/Resources/SimpleResourceType.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace EverythingServer.Resources;
77
[McpServerResourceType]
88
public class SimpleResourceType
99
{
10-
[McpServerResource(UriTemplate = "test://direct/text/resource", Name = "Direct Text Resource", MimeType = "text/plain")]
10+
[McpServerResource(UriTemplate = "test://direct/text/resource", Name = "Direct Text Resource", MimeType = "text/plain", IconSource = "https://raw.githubusercontent.com/microsoft/fluentui-emoji/62ecdc0d7ca5c6df32148c169556bc8d3782fca4/assets/Memo/Flat/memo_flat.svg")]
1111
[Description("A direct text resource")]
1212
public static string DirectTextResource() => "This is a direct resource";
1313

samples/EverythingServer/Tools/AddTool.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ namespace EverythingServer.Tools;
66
[McpServerToolType]
77
public class AddTool
88
{
9-
[McpServerTool(Name = "add"), Description("Adds two numbers.")]
9+
[McpServerTool(Name = "add", IconSource = "https://raw.githubusercontent.com/microsoft/fluentui-emoji/62ecdc0d7ca5c6df32148c169556bc8d3782fca4/assets/Plus/Flat/plus_flat.svg"), Description("Adds two numbers.")]
1010
public static string Add(int a, int b) => $"The sum of {a} and {b} is {a + b}";
1111
}

0 commit comments

Comments
 (0)