using Anthropic.SDK.Common; using System.Text.Json; using System.Text.Json.Nodes; public static class McpToolExtensions { public static IList ToAnthropicTools(this IEnumerable tools) { List result = new(); foreach (var tool in tools) { var function = tool.InputSchema == null ? new Function(tool.Name, tool.Description) : new Function(tool.Name, tool.Description, JsonSerializer.Serialize(tool.InputSchema)); result.Add(function); } return result; } public static Dictionary? ToMCPArguments(this JsonNode jsonNode) { if (jsonNode == null) return null; // Convert JsonNode to Dictionary return jsonNode.AsObject() .ToDictionary( prop => prop.Key, prop => JsonSerializer.Deserialize(prop.Value)! ); } }