add mcp plugin and rename setting
This commit is contained in:
parent
e89413092d
commit
832472feab
|
|
@ -18,7 +18,7 @@ public static class BotSharpMcpExtensions
|
|||
/// <returns></returns>
|
||||
public static IServiceCollection AddBotSharpMCP(this IServiceCollection services, IConfiguration config)
|
||||
{
|
||||
var settings = config.GetSection("MCPSettings").Get<McpSettings>();
|
||||
var settings = config.GetSection("MCP").Get<McpSettings>();
|
||||
services.AddScoped<McpSettings>(provider => { return settings; });
|
||||
if (settings != null && !settings.McpServerConfigs.IsNullOrEmpty())
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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<IMcpClient> 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()
|
||||
|
|
|
|||
29
src/Infrastructure/BotSharp.Core.MCP/McpPlugin.cs
Normal file
29
src/Infrastructure/BotSharp.Core.MCP/McpPlugin.cs
Normal file
|
|
@ -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<PluginMenuDef> menu)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -172,7 +172,7 @@
|
|||
}
|
||||
},
|
||||
|
||||
"MCPSettings": {
|
||||
"MCP": {
|
||||
"McpClientOptions": {
|
||||
"ClientInfo": {
|
||||
"Name": "SimpleToolsBotsharp",
|
||||
|
|
|
|||
Loading…
Reference in a new issue