BotSharp/src/Infrastructure/BotSharp.Core.MCP/Services/McpService.cs
geffzhang 38d1d4fcba feat:upgrade modelcontextprotocol nuget
1、upgrade ModelContextProtocol 0.1.0-preview.5
2、Add ModelContextProtocol.AspNetCore
2025-04-04 10:58:20 +08:00

33 lines
877 B
C#

using BotSharp.Core.MCP.Settings;
using Microsoft.Extensions.Logging;
namespace BotSharp.Core.MCP.Services;
public class McpService : IMcpService
{
private readonly IServiceProvider _services;
private readonly ILogger<McpService> _logger;
public McpService(
IServiceProvider services,
ILogger<McpService> logger)
{
_services = services;
_logger = logger;
}
public IEnumerable<McpServerConfigModel> GetServerConfigs()
{
var settings = _services.GetRequiredService<McpSettings>();
var configs = settings?.McpServerConfigs ?? [];
return configs.Select(x => new McpServerConfigModel
{
Id = x.Id,
Name = x.Name,
TransportType = x.TransportType,
TransportOptions = x.TransportOptions,
Location = x.Location
});
}
}