BotSharp/src/Infrastructure/BotSharp.MCP/MCPClientManager.cs

31 lines
673 B
C#
Raw Normal View History

2025-02-23 14:55:35 +00:00
using BotSharp.Core.Mcp.Settings;
using Microsoft.Extensions.Logging;
using ModelContextProtocol.Client;
using System;
using System.Linq;
using System.Threading.Tasks;
2025-02-23 14:55:35 +00:00
namespace BotSharp.Core.Mcp;
public class MCPClientManager : IDisposable
{
2025-03-26 05:36:29 +00:00
private readonly MCPSettings mcpSettings;
2025-03-26 05:36:29 +00:00
public MCPClientManager(MCPSettings settings)
{
mcpSettings = settings;
}
public async Task<IMcpClient> GetMcpClientAsync(string serverId)
{
return await McpClientFactory.CreateAsync(mcpSettings.McpServerConfigs
.Where(x=> x.Name == serverId).First(), mcpSettings.McpClientOptions);
}
public void Dispose()
{
2025-03-26 05:36:29 +00:00
}
}