package org.dromara.ai.mcp.tools;

import org.dromara.ai.mcp.McpTool;

import java.util.HashMap;
import java.util.Map;

public class AlgorithmComputeTool implements McpTool {
    @Override
    public String name() {
        return "algorithm_compute";
    }

    @Override
    public String description() {
        return "执行简单算法计算";
    }

    @Override
    public Map<String, Object> schema() {
        Map<String, Object> s = new HashMap<>();
        s.put("type", "object");
        s.put("properties", Map.of("n", Map.of("type", "integer")));
        return s;
    }

    @Override
    public Map<String, Object> invoke(Map<String, Object> input) {
        int n = Integer.parseInt(String.valueOf(input.getOrDefault("n", 10)));
        long sum = 0;
        for (int i = 1; i <= n; i++) sum += i;
        return Map.of("sum", sum);
    }
}
