private static Tool GetTool()

in src/Commands/Server/ToolOperations.cs [129:180]


    private static Tool GetTool(string fullName, IBaseCommand command)
    {
        var underlyingCommand = command.GetCommand();
        var tool = new Tool
        {
            Name = fullName,
            Description = underlyingCommand.Description,
        };

        // Get the GetCommand method info to check for McpServerToolAttribute
        var getCommandMethod = command.GetType().GetMethod(nameof(IBaseCommand.GetCommand));
        if (getCommandMethod?.GetCustomAttribute<McpServerToolAttribute>() is { } mcpServerToolAttr)
        {
            tool.Annotations = new ToolAnnotations()
            {
                DestructiveHint = mcpServerToolAttr.Destructive,
                IdempotentHint = mcpServerToolAttr.Idempotent,
                OpenWorldHint = mcpServerToolAttr.OpenWorld,
                ReadOnlyHint = mcpServerToolAttr.ReadOnly,
                Title = mcpServerToolAttr.Title,
            };
        }

        var args = command.GetArguments()?.ToList();

        var schema = new JsonObject
        {
            ["type"] = "object"
        };

        if (args != null && args.Count > 0)
        {
            var arguments = new JsonObject();
            foreach (var arg in args)
            {
                arguments.Add(arg.Name, new JsonObject()
                {
                    ["type"] = arg.Type.ToLower(),
                    ["description"] = arg.Description,
                });
            }

            schema["properties"] = arguments;
            schema["required"] = new JsonArray(args.Where(p => p.Required).Select(p => (JsonNode)p.Name).ToArray());
        }

        var newOptions = new JsonSerializerOptions(McpJsonUtilities.DefaultOptions);

        tool.InputSchema = JsonSerializer.SerializeToElement(schema, new JsonSourceGenerationContext(newOptions).JsonNode);

        return tool;
    }