-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMcpGatewayServiceCollectionExtensions.cs
More file actions
45 lines (36 loc) · 1.47 KB
/
McpGatewayServiceCollectionExtensions.cs
File metadata and controls
45 lines (36 loc) · 1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
using ManagedCode.MCPGateway.Abstractions;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Extensions.Hosting;
namespace ManagedCode.MCPGateway;
public static class McpGatewayServiceCollectionExtensions
{
public static IServiceCollection AddMcpGateway(
this IServiceCollection services,
Action<McpGatewayOptions>? configure = null)
{
ArgumentNullException.ThrowIfNull(services);
services.AddOptions<McpGatewayOptions>();
if (configure is not null)
{
services.Configure(configure);
}
services.TryAddSingleton<IMcpGateway, McpGateway>();
services.TryAddSingleton<IMcpGatewayRegistry, McpGatewayRegistry>();
services.TryAddSingleton<McpGatewayToolSet>();
return services;
}
public static IServiceCollection AddMcpGatewayInMemoryToolEmbeddingStore(this IServiceCollection services)
{
ArgumentNullException.ThrowIfNull(services);
services.AddMemoryCache();
services.TryAddSingleton<IMcpGatewayToolEmbeddingStore, McpGatewayInMemoryToolEmbeddingStore>();
return services;
}
public static IServiceCollection AddMcpGatewayIndexWarmup(this IServiceCollection services)
{
ArgumentNullException.ThrowIfNull(services);
services.TryAddEnumerable(ServiceDescriptor.Singleton<IHostedService, McpGatewayIndexWarmupService>());
return services;
}
}