Add examples of icons on tools, resources, prompts, and server implementation to EverythingServer (#1096)

Co-authored-by: Stephen Halter <halter73@gmail.com>
This commit is contained in:
Mike Kistler 2026-01-09 08:49:37 -06:00 • committed by GitHub
commit 50e29c572d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 66 additions and 5 deletions

View file

@ -21,7 +21,33 @@ var builder = WebApplication.CreateBuilder(args);
ConcurrentDictionary<string, ConcurrentDictionary<string, byte>> subscriptions = new();
builder.Services
.AddMcpServer()
.AddMcpServer(options =>
{
// Configure server implementation details with icons and website
options.ServerInfo = new Implementation
{
Name = "Everything Server",
Version = "1.0.0",
Title = "MCP Everything Server",
Description = "A comprehensive MCP server demonstrating tools, prompts, resources, sampling, and all MCP features",
WebsiteUrl = "https://github.com/modelcontextprotocol/csharp-sdk",
Icons = [
new Icon
{
Source = "https://raw.githubusercontent.com/microsoft/fluentui-emoji/62ecdc0d7ca5c6df32148c169556bc8d3782fca4/assets/Gear/Flat/gear_flat.svg",
MimeType = "image/svg+xml",
Sizes = ["any"],
Theme = "light"
},
new Icon
{
Source = "https://raw.githubusercontent.com/microsoft/fluentui-emoji/62ecdc0d7ca5c6df32148c169556bc8d3782fca4/assets/Gear/3D/gear_3d.png",
MimeType = "image/png",
Sizes = ["256x256"]
}
]
};
})
.WithHttpTransport(options =>
{
// Add a RunSessionHandler to remove all subscriptions for the session when it ends
@ -53,7 +79,42 @@ builder.Services
})
.WithTools<AddTool>()
.WithTools<AnnotatedMessageTool>()
.WithTools<EchoTool>()
.WithTools([
// EchoTool with complex icon configuration demonstrating multiple icons,
// MIME types, size specifications, and theme preferences
McpServerTool.Create(
typeof(EchoTool).GetMethod(nameof(EchoTool.Echo))!,
options: new McpServerToolCreateOptions
{
Icons = [
// High-resolution PNG icon for light theme
new Icon
{
Source = "https://raw.githubusercontent.com/microsoft/fluentui-emoji/62ecdc0d7ca5c6df32148c169556bc8d3782fca4/assets/Loudspeaker/Flat/loudspeaker_flat.svg",
MimeType = "image/svg+xml",
Sizes = ["any"],
Theme = "light"
},
// 3D icon for dark theme
new Icon
{
Source = "https://raw.githubusercontent.com/microsoft/fluentui-emoji/62ecdc0d7ca5c6df32148c169556bc8d3782fca4/assets/Loudspeaker/3D/loudspeaker_3d.png",
MimeType = "image/png",
Sizes = ["256x256"],
Theme = "dark"
},
// WebP format for modern browsers
// Demonstrates Data URI representation with the smallest possible valid WebP image (1x1 pixel).
// This will appear as a white box when rendered by a browser at 32x32
new Icon
{
Source = "data:image/webp;base64,UklGRiQAAABXRUJQVlA4IBgAAAAwAQCdASoBAAEAAwA0JaQAA3AA/vuUAAA=",
MimeType = "image/webp",
Sizes = ["32x32"]
}
]
})
])
.WithTools<LongRunningTool>()
.WithTools<PrintEnvTool>()
.WithTools<SampleLlmTool>()

View file

@ -6,6 +6,6 @@ namespace EverythingServer.Prompts;
[McpServerPromptType]
public class SimplePromptType
{
[McpServerPrompt(Name = "simple_prompt"), Description("A prompt without arguments")]
[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")]
public static string SimplePrompt() => "This is a simple prompt without arguments";
}

View file

@ -7,7 +7,7 @@ namespace EverythingServer.Resources;
[McpServerResourceType]
public class SimpleResourceType
{
[McpServerResource(UriTemplate = "test://direct/text/resource", Name = "Direct Text Resource", MimeType = "text/plain")]
[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")]
[Description("A direct text resource")]
public static string DirectTextResource() => "This is a direct resource";

View file

@ -6,6 +6,6 @@ namespace EverythingServer.Tools;
[McpServerToolType]
public class AddTool
{
[McpServerTool(Name = "add"), Description("Adds two numbers.")]
[McpServerTool(Name = "add", IconSource = "https://raw.githubusercontent.com/microsoft/fluentui-emoji/62ecdc0d7ca5c6df32148c169556bc8d3782fca4/assets/Plus/Flat/plus_flat.svg"), Description("Adds two numbers.")]
public static string Add(int a, int b) => $"The sum of {a} and {b} is {a + b}";
}