diff --git a/src/Infrastructure/BotSharp.Core.MCP/BotSharpMCPExtensions.cs b/src/Infrastructure/BotSharp.Core.MCP/BotSharpMCPExtensions.cs index 0f6c3a8f..44195f26 100644 --- a/src/Infrastructure/BotSharp.Core.MCP/BotSharpMCPExtensions.cs +++ b/src/Infrastructure/BotSharp.Core.MCP/BotSharpMCPExtensions.cs @@ -18,7 +18,7 @@ public static class BotSharpMcpExtensions /// public static IServiceCollection AddBotSharpMCP(this IServiceCollection services, IConfiguration config) { - var settings = config.GetSection("MCPSettings").Get(); + var settings = config.GetSection("MCP").Get(); services.AddScoped(provider => { return settings; }); if (settings != null && !settings.McpServerConfigs.IsNullOrEmpty()) { diff --git a/src/Infrastructure/BotSharp.Core.MCP/Managers/McpClientManager.cs b/src/Infrastructure/BotSharp.Core.MCP/Managers/McpClientManager.cs index 523e4b00..c11163b3 100644 --- a/src/Infrastructure/BotSharp.Core.MCP/Managers/McpClientManager.cs +++ b/src/Infrastructure/BotSharp.Core.MCP/Managers/McpClientManager.cs @@ -5,19 +5,18 @@ namespace BotSharp.Core.MCP.Managers; public class McpClientManager : IDisposable { + private readonly McpSettings _mcpSettings; - private readonly McpSettings mcpSettings; - - public McpClientManager(McpSettings settings) + public McpClientManager(McpSettings mcpSettings) { - mcpSettings = settings; + _mcpSettings = mcpSettings; } public async Task GetMcpClientAsync(string serverId) { return await McpClientFactory.CreateAsync( - mcpSettings.McpServerConfigs.Where(x=> x.Name == serverId).First(), - mcpSettings.McpClientOptions); + _mcpSettings.McpServerConfigs.Where(x=> x.Name == serverId).First(), + _mcpSettings.McpClientOptions); } public void Dispose() diff --git a/src/Infrastructure/BotSharp.Core.MCP/McpPlugin.cs b/src/Infrastructure/BotSharp.Core.MCP/McpPlugin.cs new file mode 100644 index 00000000..3b7dfd57 --- /dev/null +++ b/src/Infrastructure/BotSharp.Core.MCP/McpPlugin.cs @@ -0,0 +1,29 @@ +using BotSharp.Abstraction.Plugins.Models; +using BotSharp.Abstraction.Plugins; +using BotSharp.Abstraction.Settings; +using BotSharp.Core.MCP.Settings; +using Microsoft.Extensions.Configuration; + +namespace BotSharp.Core.MCP; + +public class McpPlugin : IBotSharpPlugin +{ + public string Id => "0cfb486a-229e-4470-a4c6-d2d4a5fdc727"; + public string Name => "Model context protocol"; + public string Description => "Model context protocol"; + + public SettingsMeta Settings => + new SettingsMeta("MCP"); + + public object GetNewSettingsInstance() => + new McpSettings(); + + public void RegisterDI(IServiceCollection services, IConfiguration config) + { + } + + public bool AttachMenu(List menu) + { + return true; + } +} diff --git a/src/WebStarter/appsettings.json b/src/WebStarter/appsettings.json index 60aca7d3..4338ba59 100644 --- a/src/WebStarter/appsettings.json +++ b/src/WebStarter/appsettings.json @@ -172,7 +172,7 @@ } }, - "MCPSettings": { + "MCP": { "McpClientOptions": { "ClientInfo": { "Name": "SimpleToolsBotsharp",