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
60 changes: 59 additions & 1 deletion 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 @@ -58,6 +84,38 @@
.WithTools<PrintEnvTool>()
.WithTools<SampleLlmTool>()
.WithTools<TinyImageTool>()
.WithTools([
// A tool with multiple complex icons demonstrating different themes, sizes, and MIME types
McpServerTool.Create(
WeatherTool.GetWeather,

Check failure on line 90 in samples/EverythingServer/Program.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest, Debug)

The name 'WeatherTool' does not exist in the current context

Check failure on line 90 in samples/EverythingServer/Program.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest, Debug)

The name 'WeatherTool' does not exist in the current context

Check failure on line 90 in samples/EverythingServer/Program.cs

View workflow job for this annotation

GitHub Actions / build (macos-latest, Debug)

The name 'WeatherTool' does not exist in the current context

Check failure on line 90 in samples/EverythingServer/Program.cs

View workflow job for this annotation

GitHub Actions / build (macos-latest, Debug)

The name 'WeatherTool' does not exist in the current context

Check failure on line 90 in samples/EverythingServer/Program.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, Debug)

The name 'WeatherTool' does not exist in the current context

Check failure on line 90 in samples/EverythingServer/Program.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, Debug)

The name 'WeatherTool' does not exist in the current context

Check failure on line 90 in samples/EverythingServer/Program.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, Release)

The name 'WeatherTool' does not exist in the current context

Check failure on line 90 in samples/EverythingServer/Program.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, Release)

The name 'WeatherTool' does not exist in the current context

Check failure on line 90 in samples/EverythingServer/Program.cs

View workflow job for this annotation

GitHub Actions / build (macos-latest, Release)

The name 'WeatherTool' does not exist in the current context

Check failure on line 90 in samples/EverythingServer/Program.cs

View workflow job for this annotation

GitHub Actions / build (macos-latest, Release)

The name 'WeatherTool' does not exist in the current context

Check failure on line 90 in samples/EverythingServer/Program.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest, Release)

The name 'WeatherTool' does not exist in the current context

Check failure on line 90 in samples/EverythingServer/Program.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest, Release)

The name 'WeatherTool' does not exist in the current context
new McpServerToolCreateOptions
{
Name = "get_weather",
Title = "Get Weather Information",
Icons = [
new Icon
{
Source = "https://raw.githubusercontent.com/microsoft/fluentui-emoji/main/assets/Sun/Flat/sun_flat.svg",
MimeType = "image/svg+xml",
Sizes = ["any"],
Theme = "light"
},
new Icon
{
Source = "https://raw.githubusercontent.com/microsoft/fluentui-emoji/main/assets/Sun/Flat/sun_flat.svg",
MimeType = "image/svg+xml",
Sizes = ["any"],
Theme = "dark"
},
new Icon
{
Source = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==",
MimeType = "image/png",
Sizes = ["16x16", "32x32"]
}
]
})
])
.WithPrompts<ComplexPromptType>()
.WithPrompts<SimplePromptType>()
.WithResources<SimpleResourceType>()
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}";
}
Loading