Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 63 additions & 2 deletions samples/EverythingServer/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,33 @@
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/main/assets/Gear/Flat/gear_flat.svg",
MimeType = "image/svg+xml",
Sizes = ["any"],
Theme = "light"
},
new Icon
{
Source = "https://raw.githubusercontent.com/microsoft/fluentui-emoji/main/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
Expand Down Expand Up @@ -53,7 +79,42 @@
})
.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/main/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/main/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>()
Expand Down
2 changes: 1 addition & 1 deletion samples/EverythingServer/Prompts/SimplePromptType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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/main/assets/Light%20bulb/Flat/light_bulb_flat.svg"), Description("A prompt without arguments")]
public static string SimplePrompt() => "This is a simple prompt without arguments";
}
2 changes: 1 addition & 1 deletion samples/EverythingServer/Resources/SimpleResourceType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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/main/assets/Memo/Flat/memo_flat.svg")]
[Description("A direct text resource")]
public static string DirectTextResource() => "This is a direct resource";

Expand Down
2 changes: 1 addition & 1 deletion samples/EverythingServer/Tools/AddTool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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/main/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}";
}