Add EverythingServer sample (#151)

This commit is contained in:
Aaron Powell 2025-04-05 05:48:53 +11:00 • committed by GitHub
commit 01410df5ad
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 620 additions and 1 deletions

View file

@ -314,7 +314,7 @@ public static partial class McpServerBuilderExtensions
}
/// <summary>
/// Sets or sets the handler for subscribe to resources messages.
/// Sets the handler for subscribe to resources messages.
/// </summary>
/// <param name="builder">The builder instance.</param>
/// <param name="handler">The handler.</param>
@ -325,6 +325,18 @@ public static partial class McpServerBuilderExtensions
builder.Services.Configure<McpServerHandlers>(s => s.UnsubscribeFromResourcesHandler = handler);
return builder;
}
/// <summary>
/// Sets the handler for setting the logging level.
/// </summary>
/// <param name="builder">The builder instance.</param>
/// <param name="handler">The handler.</param>
public static IMcpServerBuilder WithSetLoggingLevelHandler(this IMcpServerBuilder builder, Func<RequestContext<SetLevelRequestParams>, CancellationToken, Task<EmptyResult>> handler)
{
Throw.IfNull(builder);
builder.Services.Configure<McpServerHandlers>(s => s.SetLoggingLevelHandler = handler);
return builder;
}
#endregion
#region Transports

View file

@ -113,6 +113,7 @@ public sealed class McpServerHandlers
options.Capabilities.Prompts = promptsCapability;
options.Capabilities.Resources = resourcesCapability;
options.Capabilities.Tools = toolsCapability;
options.Capabilities.Logging = loggingCapability;
options.GetCompletionHandler = GetCompletionHandler ?? options.GetCompletionHandler;
}