Use TryAddEnumerable for McpServerOptionsSetup (#252)
This commit is contained in:
parent
cae5dff318
commit
b3a5a82544
1 changed files with 53 additions and 1 deletions
|
|
@ -1,5 +1,6 @@
|
|||
using ModelContextProtocol.Server;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Microsoft.Extensions.DependencyInjection.Extensions;
|
||||
|
||||
namespace Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
|
|
@ -17,7 +18,7 @@ public static class McpServerServiceCollectionExtensions
|
|||
public static IMcpServerBuilder AddMcpServer(this IServiceCollection services, Action<McpServerOptions>? configureOptions = null)
|
||||
{
|
||||
services.AddOptions();
|
||||
services.AddTransient<IConfigureOptions<McpServerOptions>, McpServerOptionsSetup>();
|
||||
services.TryAddEnumerable(ServiceDescriptor.Transient<IConfigureOptions<McpServerOptions>, McpServerOptionsSetup>());
|
||||
if (configureOptions is not null)
|
||||
{
|
||||
services.Configure(configureOptions);
|
||||
|
|
|
|||
Loading…
Reference in a new issue