-
-
Notifications
You must be signed in to change notification settings - Fork 639
Expand file tree
/
Copy pathBotSharpMCPExtensions.cs
More file actions
35 lines (29 loc) · 1.05 KB
/
BotSharpMCPExtensions.cs
File metadata and controls
35 lines (29 loc) · 1.05 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
using BotSharp.Core.MCP.Hooks;
using BotSharp.Core.MCP.Managers;
using BotSharp.Core.MCP.Services;
using BotSharp.Core.MCP.Settings;
using Microsoft.Extensions.Configuration;
namespace BotSharp.Core.MCP;
public static class BotSharpMcpExtensions
{
/// <summary>
/// Add mcp
/// </summary>
/// <param name="services"></param>
/// <param name="config"></param>
/// <returns></returns>
public static IServiceCollection AddBotSharpMCP(this IServiceCollection services, IConfiguration config)
{
var settings = config.GetSection("MCP").Get<McpSettings>();
services.AddScoped(provider => settings);
if (settings != null && settings.Enabled && !settings.McpServerConfigs.IsNullOrEmpty())
{
services.AddScoped<IMcpService, McpService>();
var clientManager = new McpClientManager(settings);
services.AddScoped(provider => clientManager);
// Register hooks
services.AddScoped<IAgentHook, McpToolAgentHook>();
}
return services;
}
}