fix missing field

This commit is contained in:
Jicheng Lu 2025-03-31 17:02:14 -05:00
parent 74476030e1
commit acf1ed9cbc
2 changed files with 18 additions and 9 deletions

View file

@ -2,10 +2,9 @@ namespace BotSharp.Abstraction.Agents.Models;
public class MCPTool public class MCPTool
{ {
public string Name { get; set; }
public string ServerId { get; set; } public string ServerId { get; set; }
public bool Disabled { get; set; } public bool Disabled { get; set; }
public IEnumerable<MCPFunction> Functions { get; set; } = []; public IEnumerable<MCPFunction> Functions { get; set; } = [];
public MCPTool() public MCPTool()
@ -14,8 +13,14 @@ public class MCPTool
} }
public MCPTool( public MCPTool(
string name,
string serverId,
bool disabled = false,
IEnumerable<MCPFunction>? functions = null) IEnumerable<MCPFunction>? functions = null)
{ {
Name = name;
ServerId = serverId;
Disabled = disabled;
Functions = functions ?? []; Functions = functions ?? [];
} }
@ -32,6 +37,6 @@ public class MCPFunction
public MCPFunction(string name) public MCPFunction(string name)
{ {
this.Name = name; Name = name;
} }
} }

View file

@ -10,21 +10,25 @@ public class AgentMCPToolMongoElement
public bool Disabled { get; set; } public bool Disabled { get; set; }
public List<McpFunctionMongoElement> Functions { get; set; } = []; public List<McpFunctionMongoElement> Functions { get; set; } = [];
public static AgentMCPToolMongoElement ToMongoElement(MCPTool utility) public static AgentMCPToolMongoElement ToMongoElement(MCPTool tool)
{ {
return new AgentMCPToolMongoElement return new AgentMCPToolMongoElement
{ {
Disabled = utility.Disabled, Name = tool.Name,
Functions = utility.Functions?.Select(x => new McpFunctionMongoElement(x.Name))?.ToList() ?? [], ServerId = tool.ServerId,
Disabled = tool.Disabled,
Functions = tool.Functions?.Select(x => new McpFunctionMongoElement(x.Name))?.ToList() ?? [],
}; };
} }
public static MCPTool ToDomainElement(AgentMCPToolMongoElement utility) public static MCPTool ToDomainElement(AgentMCPToolMongoElement tool)
{ {
return new MCPTool return new MCPTool
{ {
Disabled = utility.Disabled, Name = tool.Name,
Functions = utility.Functions?.Select(x => new MCPFunction(x.Name))?.ToList() ?? [], ServerId = tool.ServerId,
Disabled = tool.Disabled,
Functions = tool.Functions?.Select(x => new MCPFunction(x.Name))?.ToList() ?? [],
}; };
} }
} }