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:
parent
14f9735c19
commit
50e29c572d
4 changed files with 66 additions and 5 deletions
|
|
@ -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>()
|
||||
|
|
|
|||
|
|
@ -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";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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";
|
||||
|
||||
|
|
|
|||
|
|
@ -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}";
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue