feat:Migrate MCP to the independent BotSharp.MCP package

This commit is contained in:
geffzhang 2025-02-25 22:57:22 +08:00
parent 731355d110
commit 69993bdca8
24 changed files with 209 additions and 177 deletions

View file

@ -127,6 +127,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BotSharp.Core.Rules", "src\
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BotSharp.Plugin.DeepSeekAI", "src\Plugins\BotSharp.Plugin.DeepSeekAI\BotSharp.Plugin.DeepSeekAI.csproj", "{AF329442-B48E-4B48-A18A-1C869D1BA6F5}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BotSharp.MCP", "src\Infrastructure\BotSharp.MCP\BotSharp.MCP.csproj", "{8ED8EEF4-06DD-45F5-AA91-BD2395E901B5}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -519,6 +521,14 @@ Global
{AF329442-B48E-4B48-A18A-1C869D1BA6F5}.Release|Any CPU.Build.0 = Release|Any CPU
{AF329442-B48E-4B48-A18A-1C869D1BA6F5}.Release|x64.ActiveCfg = Release|Any CPU
{AF329442-B48E-4B48-A18A-1C869D1BA6F5}.Release|x64.Build.0 = Release|Any CPU
{8ED8EEF4-06DD-45F5-AA91-BD2395E901B5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8ED8EEF4-06DD-45F5-AA91-BD2395E901B5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8ED8EEF4-06DD-45F5-AA91-BD2395E901B5}.Debug|x64.ActiveCfg = Debug|Any CPU
{8ED8EEF4-06DD-45F5-AA91-BD2395E901B5}.Debug|x64.Build.0 = Debug|Any CPU
{8ED8EEF4-06DD-45F5-AA91-BD2395E901B5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8ED8EEF4-06DD-45F5-AA91-BD2395E901B5}.Release|Any CPU.Build.0 = Release|Any CPU
{8ED8EEF4-06DD-45F5-AA91-BD2395E901B5}.Release|x64.ActiveCfg = Release|Any CPU
{8ED8EEF4-06DD-45F5-AA91-BD2395E901B5}.Release|x64.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@ -580,6 +590,7 @@ Global
{F812BAAE-5A7D-4DF7-8E71-70696B51C61F} = {E29DC6C4-5E57-48C5-BCB0-6B8F84782749}
{AFD64412-4D6A-452E-82A2-79E5D8842E29} = {E29DC6C4-5E57-48C5-BCB0-6B8F84782749}
{AF329442-B48E-4B48-A18A-1C869D1BA6F5} = {D5293208-2BEF-42FC-A64C-5954F61720BA}
{8ED8EEF4-06DD-45F5-AA91-BD2395E901B5} = {E29DC6C4-5E57-48C5-BCB0-6B8F84782749}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {A9969D89-C98B-40A5-A12B-FC87E55B3A19}

View file

@ -60,7 +60,7 @@ public abstract class AgentHookBase : IAgentHook
}
public virtual void OnAgentCPLoaded(Agent agent)
public virtual void OnAgentMCPToolLoaded(Agent agent)
{
}

View file

@ -27,7 +27,7 @@ public interface IAgentHook
void OnAgentUtilityLoaded(Agent agent);
void OnAgentCPLoaded(Agent agent);
void OnAgentMCPToolLoaded(Agent agent);
/// <summary>
/// Triggered when agent is loaded completely.

View file

@ -95,18 +95,19 @@ public class Agent
public List<string> Labels { get; set; } = new();
/// <summary>
/// Merge mcps from entry agent
/// Merge Utility from entry agent
/// </summary>
public bool MergeUtility { get; set; }
/// <summary>
/// Agent mcps
/// Agent Utility
/// </summary>
public List<AgentUtility> Utilities { get; set; } = new();
/// <summary>
/// Agent MCP
/// Agent MCP Tools
/// </summary>
public List<AgentCP> Acps { get; set; } = new();
public List<MCPTool> McpTools { get; set; } = new();
/// <summary>
/// Agent rules
@ -161,7 +162,7 @@ public class Agent
Responses = agent.Responses,
Samples = agent.Samples,
Utilities = agent.Utilities,
Acps = agent.Acps,
McpTools = agent.McpTools,
Knowledges = agent.Knowledges,
IsPublic = agent.IsPublic,
Disabled = agent.Disabled,
@ -304,9 +305,9 @@ public class Agent
return this;
}
public Agent SetMcps(List<AgentCP> mcps)
public Agent SetMcps(List<MCPTool> mcps)
{
Acps = mcps ?? [];
McpTools = mcps ?? [];
return this;
}
}

View file

@ -1,65 +0,0 @@
namespace BotSharp.Abstraction.Agents.Models;
public class AgentCP
{
public string Name { get; set; }
public string ServerId { get; set; }
public bool Disabled { get; set; }
public IEnumerable<ACPFunction> Functions { get; set; } = [];
public IEnumerable<ACPTemplate> Templates { get; set; } = [];
public AgentCP()
{
}
public AgentCP(
string name,
IEnumerable<ACPFunction>? functions = null,
IEnumerable<ACPTemplate>? templates = null)
{
Name = name;
Functions = functions ?? [];
Templates = templates ?? [];
}
public override string ToString()
{
return Name;
}
}
public class ACPFunction : MCPBase
{
public ACPFunction()
{
}
public ACPFunction(string name)
{
Name = name;
}
}
public class ACPTemplate : MCPBase
{
public ACPTemplate()
{
}
public ACPTemplate(string name)
{
Name = name;
}
}
public class MCPBase
{
public string Name { get; set; }
}

View file

@ -0,0 +1,41 @@
namespace BotSharp.Abstraction.Agents.Models;
public class MCPTool
{
public string Name { get; set; }
public string ServerId { get; set; }
public bool Disabled { get; set; }
public IEnumerable<MCPFunction> Functions { get; set; } = [];
public MCPTool()
{
}
public MCPTool(
string name,
IEnumerable<MCPFunction>? functions = null)
{
Name = name;
Functions = functions ?? [];
}
public override string ToString()
{
return Name;
}
}
public class MCPFunction
{
public string Name { get; set; }
public MCPFunction()
{
}
}

View file

@ -1,6 +1,3 @@
using BotSharp.Core.Mcp;
using BotSharp.Core.MCP;
namespace BotSharp.Core.Agents.Hooks;
public class BasicAgentHook : AgentHookBase
@ -41,36 +38,7 @@ public class BasicAgentHook : AgentHookBase
agent.SecondaryInstructions.Add(prompt);
}
}
public override void OnAgentCPLoaded(Agent agent)
{
if (agent.Type == AgentType.Routing)
return;
var conv = _services.GetRequiredService<IConversationService>();
var isConvMode = conv.IsConversationMode();
if (!isConvMode) return;
agent.SecondaryFunctions ??= [];
agent.SecondaryInstructions ??= [];
agent.Acps ??= [];
var (functions, templates) = GetACPContent(agent);
foreach (var fn in functions)
{
if (!agent.SecondaryFunctions.Any(x => x.Name.Equals(fn.Name, StringComparison.OrdinalIgnoreCase)))
{
agent.SecondaryFunctions.Add(fn);
}
}
foreach (var prompt in templates)
{
agent.SecondaryInstructions.Add(prompt);
}
}
private (IEnumerable<FunctionDef>, IEnumerable<string>) GetUtilityContent(Agent agent)
{
@ -114,30 +82,5 @@ public class BasicAgentHook : AgentHookBase
.Distinct().ToList();
return (functionNames, templateNames);
}
private (IEnumerable<FunctionDef>, IEnumerable<string>) GetACPContent(Agent agent)
{
List<FunctionDef> functionDefs = new List<FunctionDef>();
IEnumerable<string> templates = new List<string>();
var mcpClientManager = _services.GetRequiredService<MCPClientManager>();
var mcps = agent.Acps;
foreach (var item in mcps)
{
var ua = mcpClientManager.Factory.GetClientAsync(item.ServerId).Result;
if (ua != null)
{
var tools = ua.ListToolsAsync().Result;
var funcnames = item.Functions.Select(x => x.Name).ToList();
foreach (var tool in tools.Tools.Where(x=> funcnames.Contains(x.Name,StringComparer.OrdinalIgnoreCase)))
{
var funDef = AIFunctionUtilities.MapToFunctionDef(tool);
functionDefs.Add(funDef);
}
}
}
return (functionDefs, templates);
}
}
}

View file

@ -72,9 +72,9 @@ public partial class AgentService
hook.OnAgentUtilityLoaded(agent);
}
if(agent.Acps != null)
if(agent.McpTools != null)
{
hook.OnAgentCPLoaded(agent);
hook.OnAgentMCPToolLoaded(agent);
}
hook.OnAgentLoaded(agent);

View file

@ -40,7 +40,7 @@ public partial class AgentService
record.Responses = agent.Responses ?? [];
record.Samples = agent.Samples ?? [];
record.Utilities = agent.Utilities ?? [];
record.Acps = agent.Acps ?? [];
record.McpTools = agent.McpTools ?? [];
record.KnowledgeBases = agent.KnowledgeBases ?? [];
record.Rules = agent.Rules ?? [];
if (agent.LlmConfig != null && !agent.LlmConfig.IsInherit)
@ -107,7 +107,7 @@ public partial class AgentService
.SetResponses(foundAgent.Responses)
.SetSamples(foundAgent.Samples)
.SetUtilities(foundAgent.Utilities)
.SetMcps(foundAgent.Acps)
.SetMcps(foundAgent.McpTools)
.SetKnowledgeBases(foundAgent.KnowledgeBases)
.SetRules(foundAgent.Rules)
.SetLlmConfig(foundAgent.LlmConfig);

View file

@ -195,7 +195,6 @@
<PackageReference Include="Microsoft.Extensions.Http" Version="8.0.1" />
<PackageReference Include="Nanoid" Version="3.1.0" />
<PackageReference Include="Rougamo.Fody" Version="4.0.4" />
<PackageReference Include="mcpdotnet" Version="1.0.1.1" />
</ItemGroup>
<ItemGroup>

View file

@ -61,7 +61,7 @@ namespace BotSharp.Core.Repository
UpdateAgentUtilities(agent.Id, agent.MergeUtility, agent.Utilities);
break;
case AgentField.Acp:
UpdateAgentCP(agent.Id, agent.Acps);
UpdateAgentMcpTools(agent.Id, agent.McpTools);
break;
case AgentField.KnowledgeBase:
UpdateAgentKnowledgeBases(agent.Id, agent.KnowledgeBases);
@ -194,15 +194,15 @@ namespace BotSharp.Core.Repository
File.WriteAllText(agentFile, json);
}
private void UpdateAgentCP(string agentId, List<AgentCP> mcps)
private void UpdateAgentMcpTools(string agentId, List<MCPTool> mcptools)
{
if (mcps == null) return;
if (mcptools == null) return;
var (agent, agentFile) = GetAgentFromFile(agentId);
if (agent == null) return;
agent.Acps = mcps;
agent.McpTools = mcptools;
agent.UpdatedDateTime = DateTime.UtcNow;
var json = JsonSerializer.Serialize(agent, _options);
File.WriteAllText(agentFile, json);
@ -377,7 +377,7 @@ namespace BotSharp.Core.Repository
agent.Profiles = inputAgent.Profiles;
agent.Labels = inputAgent.Labels;
agent.Utilities = inputAgent.Utilities;
agent.Acps = inputAgent.Acps;
agent.McpTools = inputAgent.McpTools;
agent.KnowledgeBases = inputAgent.KnowledgeBases;
agent.RoutingRules = inputAgent.RoutingRules;
agent.Rules = inputAgent.Rules;

View file

@ -1,3 +1,4 @@
using BotSharp.Abstraction.Functions.Models;
using McpDotNet.Protocol.Types;
using System;
using System.Collections.Generic;

View file

@ -0,0 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>$(TargetFramework)</TargetFramework>
<LangVersion>$(LangVersion)</LangVersion>
<VersionPrefix>$(BotSharpVersion)</VersionPrefix>
<GeneratePackageOnBuild>$(GeneratePackageOnBuild)</GeneratePackageOnBuild>
<OutputPath>$(SolutionDir)packages</OutputPath>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="mcpdotnet" Version="1.0.1.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\BotSharp.Abstraction\BotSharp.Abstraction.csproj" />
</ItemGroup>
</Project>

View file

@ -1,15 +1,21 @@
using BotSharp.Abstraction.Conversations.Models;
using BotSharp.Abstraction.Functions;
using McpDotNet.Client;
using McpDotNet.Protocol.Types;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.Json;
using System.Threading.Tasks;
namespace BotSharp.Core.Mcp.Functions;
public class McpAIFunction : IFunctionCallback
public class McpToolFunction : IFunctionCallback
{
private readonly Tool _tool;
private readonly IMcpClient _client;
public McpAIFunction(Tool tool, IMcpClient client)
public McpToolFunction(Tool tool, IMcpClient client)
{
_tool = tool ?? throw new ArgumentNullException(nameof(tool));
_client = client ?? throw new ArgumentNullException(nameof(client));

View file

@ -0,0 +1,71 @@
using BotSharp.Abstraction.Agents;
using BotSharp.Abstraction.Agents.Enums;
using BotSharp.Abstraction.Agents.Models;
using BotSharp.Abstraction.Agents.Settings;
using BotSharp.Abstraction.Conversations;
using BotSharp.Abstraction.Functions.Models;
using BotSharp.Core.Mcp;
using BotSharp.Core.MCP;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
using System.Linq;
namespace BotSharp.MCP.Hooks;
public class MCPToolAgentHook : AgentHookBase
{
public override string SelfId => string.Empty;
public MCPToolAgentHook(IServiceProvider services, AgentSettings settings)
: base(services, settings)
{
}
public override void OnAgentMCPToolLoaded(Agent agent)
{
if (agent.Type == AgentType.Routing)
return;
var conv = _services.GetRequiredService<IConversationService>();
var isConvMode = conv.IsConversationMode();
if (!isConvMode) return;
agent.SecondaryFunctions ??= [];
agent.SecondaryInstructions ??= [];
agent.McpTools ??= [];
var functions = GetMCPContent(agent);
foreach (var fn in functions)
{
if (!agent.SecondaryFunctions.Any(x => x.Name.Equals(fn.Name, StringComparison.OrdinalIgnoreCase)))
{
agent.SecondaryFunctions.Add(fn);
}
}
}
private IEnumerable<FunctionDef> GetMCPContent(Agent agent)
{
List<FunctionDef> functionDefs = new List<FunctionDef>();
var mcpClientManager = _services.GetRequiredService<MCPClientManager>();
var mcps = agent.McpTools;
foreach (var item in mcps)
{
var ua = mcpClientManager.Factory.GetClientAsync(item.ServerId).Result;
if (ua != null)
{
var tools = ua.ListToolsAsync().Result;
var funcnames = item.Functions.Select(x => x.Name).ToList();
foreach (var tool in tools.Tools.Where(x => funcnames.Contains(x.Name, StringComparer.OrdinalIgnoreCase)))
{
var funDef = AIFunctionUtilities.MapToFunctionDef(tool);
functionDefs.Add(funDef);
}
}
}
return functionDefs;
}
}

View file

@ -1,5 +1,7 @@
using BotSharp.Core.Mcp.Settings;
using McpDotNet.Client;
using Microsoft.Extensions.Logging;
using System;
namespace BotSharp.Core.Mcp;

View file

@ -1,7 +1,10 @@
using BotSharp.Abstraction.Functions;
using BotSharp.Abstraction.Plugins;
using BotSharp.Core.Mcp.Functions;
using BotSharp.Core.Mcp.Settings;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;
namespace BotSharp.Core.Mcp;
@ -33,7 +36,7 @@ public class McpPlugin : IBotSharpPlugin
{
services.AddScoped<IFunctionCallback>(provider =>
{
var func = new McpAIFunction(tool, client);
var func = new McpToolFunction(tool, client);
return func;
});
}

View file

@ -1,5 +1,6 @@
using McpDotNet.Client;
using McpDotNet.Configuration;
using System.Collections.Generic;
namespace BotSharp.Core.Mcp.Settings;

View file

@ -55,7 +55,7 @@ public class AgentCreationModel
public int? MaxMessageCount { get; set; }
public List<AgentUtility> Utilities { get; set; } = new();
public List<AgentCP> Acps { get; set; } = new();
public List<MCPTool> McpTools { get; set; } = new();
public List<RoutingRuleUpdateModel> RoutingRules { get; set; } = new();
public List<AgentKnowledgeBase> KnowledgeBases { get; set; } = new();
public List<AgentRule> Rules { get; set; } = new();
@ -74,7 +74,7 @@ public class AgentCreationModel
Responses = Responses,
Samples = Samples,
Utilities = Utilities,
Acps = Acps,
McpTools = McpTools,
IsPublic = IsPublic,
Type = Type,
Disabled = Disabled,

View file

@ -40,9 +40,9 @@ public class AgentUpdateModel
public List<AgentUtility>? Utilities { get; set; }
/// <summary>
/// Acps
/// McpTools
/// </summary>
public List<AgentCP>? Acps { get; set; }
public List<MCPTool>? McpTools { get; set; }
/// <summary>
/// knowledge bases
@ -108,7 +108,7 @@ public class AgentUpdateModel
Functions = Functions ?? [],
Responses = Responses ?? [],
Utilities = Utilities ?? [],
Acps = Acps ?? [],
McpTools = McpTools ?? [],
KnowledgeBases = KnowledgeBases ?? [],
Rules = Rules ?? [],
LlmConfig = LlmConfig ?? new()

View file

@ -24,7 +24,7 @@ public class AgentViewModel
[JsonPropertyName("merge_utility")]
public bool MergeUtility { get; set; }
public List<AgentUtility> Utilities { get; set; }
public List<AgentCP> Acps { get; set; }
public List<MCPTool> Acps { get; set; }
[JsonPropertyName("knowledge_bases")]
public List<AgentKnowledgeBase> KnowledgeBases { get; set; }
@ -87,7 +87,7 @@ public class AgentViewModel
Responses = agent.Responses ?? [],
Samples = agent.Samples ?? [],
Utilities = agent.Utilities ?? [],
Acps = agent.Acps ?? [],
Acps = agent.McpTools ?? [],
KnowledgeBases = agent.KnowledgeBases ?? [],
IsPublic= agent.IsPublic,
Disabled = agent.Disabled,

View file

@ -18,7 +18,7 @@ public class AgentDocument : MongoBase
public List<AgentResponseMongoElement> Responses { get; set; }
public List<string> Samples { get; set; }
public List<AgentUtilityMongoElement> Utilities { get; set; }
public List<AgentCPMongoElement> Mcps { get; set; }
public List<AgentMCPToolMongoElement> McpTools { get; set; }
public List<AgentKnowledgeBaseMongoElement> KnowledgeBases { get; set; }
public List<string> Profiles { get; set; }
public List<string> Labels { get; set; }

View file

@ -8,64 +8,64 @@ using System.Threading.Tasks;
namespace BotSharp.Plugin.MongoStorage.Models;
[BsonIgnoreExtraElements(Inherited = true)]
public class AgentCPMongoElement
public class AgentMCPToolMongoElement
{
public string Name { get; set; }
public string ServerId { get; set; }
public bool Disabled { get; set; }
public List<AcpFunctionMongoElement> Functions { get; set; } = [];
public List<AcpTemplateMongoElement> Templates { get; set; } = [];
public List<McpFunctionMongoElement> Functions { get; set; } = [];
public List<McpTemplateMongoElement> Templates { get; set; } = [];
public static AgentCPMongoElement ToMongoElement(AgentCP utility)
public static AgentMCPToolMongoElement ToMongoElement(MCPTool utility)
{
return new AgentCPMongoElement
return new AgentMCPToolMongoElement
{
Name = utility.Name,
Disabled = utility.Disabled,
Functions = utility.Functions?.Select(x => new AcpFunctionMongoElement(x.Name))?.ToList() ?? [],
Templates = utility.Templates?.Select(x => new AcpTemplateMongoElement(x.Name))?.ToList() ?? []
Functions = utility.Functions?.Select(x => new McpFunctionMongoElement(x.Name))?.ToList() ?? [],
Templates = utility.Templates?.Select(x => new McpTemplateMongoElement(x.Name))?.ToList() ?? []
};
}
public static AgentCP ToDomainElement(AgentCPMongoElement utility)
public static MCPTool ToDomainElement(AgentMCPToolMongoElement utility)
{
return new AgentCP
return new MCPTool
{
Name = utility.Name,
Disabled = utility.Disabled,
Functions = utility.Functions?.Select(x => new ACPFunction(x.Name))?.ToList() ?? [],
Functions = utility.Functions?.Select(x => new MCPFunction(x.Name))?.ToList() ?? [],
Templates = utility.Templates?.Select(x => new ACPTemplate(x.Name))?.ToList() ?? []
};
}
}
public class AcpFunctionMongoElement
public class McpFunctionMongoElement
{
public string Name { get; set; }
public AcpFunctionMongoElement()
public McpFunctionMongoElement()
{
}
public AcpFunctionMongoElement(string name)
public McpFunctionMongoElement(string name)
{
Name = name;
}
}
public class AcpTemplateMongoElement
public class McpTemplateMongoElement
{
public string Name { get; set; }
public AcpTemplateMongoElement()
public McpTemplateMongoElement()
{
}
public AcpTemplateMongoElement(string name)
public McpTemplateMongoElement(string name)
{
Name = name;
}

View file

@ -62,7 +62,7 @@ public partial class MongoRepository
UpdateAgentUtilities(agent.Id, agent.MergeUtility, agent.Utilities);
break;
case AgentField.Acp:
UpdateAgentMcps(agent.Id, agent.Acps);
UpdateAgentMcps(agent.Id, agent.McpTools);
break;
case AgentField.KnowledgeBase:
UpdateAgentKnowledgeBases(agent.Id, agent.KnowledgeBases);
@ -264,15 +264,15 @@ public partial class MongoRepository
_dc.Agents.UpdateOne(filter, update);
}
private void UpdateAgentMcps(string agentId, List<AgentCP> mcps)
private void UpdateAgentMcps(string agentId, List<MCPTool> mcps)
{
if (mcps == null) return;
var elements = mcps?.Select(x => AgentCPMongoElement.ToMongoElement(x))?.ToList() ?? [];
var elements = mcps?.Select(x => AgentMCPToolMongoElement.ToMongoElement(x))?.ToList() ?? [];
var filter = Builders<AgentDocument>.Filter.Eq(x => x.Id, agentId);
var update = Builders<AgentDocument>.Update
.Set(x => x.Mcps, elements)
.Set(x => x.McpTools, elements)
.Set(x => x.UpdatedTime, DateTime.UtcNow);
_dc.Agents.UpdateOne(filter, update);
@ -346,7 +346,7 @@ public partial class MongoRepository
.Set(x => x.Responses, agent.Responses.Select(r => AgentResponseMongoElement.ToMongoElement(r)).ToList())
.Set(x => x.Samples, agent.Samples)
.Set(x => x.Utilities, agent.Utilities.Select(u => AgentUtilityMongoElement.ToMongoElement(u)).ToList())
.Set(x => x.Mcps, agent.Acps.Select(u => AgentCPMongoElement.ToMongoElement(u)).ToList())
.Set(x => x.McpTools, agent.McpTools.Select(u => AgentMCPToolMongoElement.ToMongoElement(u)).ToList())
.Set(x => x.KnowledgeBases, agent.KnowledgeBases.Select(u => AgentKnowledgeBaseMongoElement.ToMongoElement(u)).ToList())
.Set(x => x.Rules, agent.Rules.Select(e => AgentRuleMongoElement.ToMongoElement(e)).ToList())
.Set(x => x.LlmConfig, AgentLlmConfigMongoElement.ToMongoElement(agent.LlmConfig))
@ -527,7 +527,7 @@ public partial class MongoRepository
Responses = x.Responses?.Select(r => AgentResponseMongoElement.ToMongoElement(r))?.ToList() ?? [],
RoutingRules = x.RoutingRules?.Select(r => RoutingRuleMongoElement.ToMongoElement(r))?.ToList() ?? [],
Utilities = x.Utilities?.Select(u => AgentUtilityMongoElement.ToMongoElement(u))?.ToList() ?? [],
Mcps = x.Acps?.Select(u => AgentCPMongoElement.ToMongoElement(u))?.ToList() ?? [],
McpTools = x.McpTools?.Select(u => AgentMCPToolMongoElement.ToMongoElement(u))?.ToList() ?? [],
KnowledgeBases = x.KnowledgeBases?.Select(k => AgentKnowledgeBaseMongoElement.ToMongoElement(k))?.ToList() ?? [],
Rules = x.Rules?.Select(e => AgentRuleMongoElement.ToMongoElement(e))?.ToList() ?? [],
CreatedTime = x.CreatedDateTime,
@ -622,7 +622,7 @@ public partial class MongoRepository
Responses = agentDoc.Responses?.Select(r => AgentResponseMongoElement.ToDomainElement(r))?.ToList() ?? [],
RoutingRules = agentDoc.RoutingRules?.Select(r => RoutingRuleMongoElement.ToDomainElement(agentDoc.Id, agentDoc.Name, r))?.ToList() ?? [],
Utilities = agentDoc.Utilities?.Select(u => AgentUtilityMongoElement.ToDomainElement(u))?.ToList() ?? [],
Acps = agentDoc.Mcps?.Select(u => AgentCPMongoElement.ToDomainElement(u))?.ToList() ?? [],
McpTools = agentDoc.McpTools?.Select(u => AgentMCPToolMongoElement.ToDomainElement(u))?.ToList() ?? [],
KnowledgeBases = agentDoc.KnowledgeBases?.Select(x => AgentKnowledgeBaseMongoElement.ToDomainElement(x))?.ToList() ?? [],
Rules = agentDoc.Rules?.Select(e => AgentRuleMongoElement.ToDomainElement(e))?.ToList() ?? []
};