/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */


package org.apache.hertzbeat.ai.service.impl;

import org.apache.hertzbeat.ai.service.McpServerService;
import org.apache.hertzbeat.ai.tools.AlertDefineTools;
import org.apache.hertzbeat.ai.tools.AlertTools;
import org.apache.hertzbeat.ai.tools.MetricsTools;
import org.apache.hertzbeat.ai.tools.MonitorTools;
import org.apache.hertzbeat.ai.tools.ScheduleTools;
import org.apache.hertzbeat.ai.tools.SkillTools;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.ai.tool.ToolCallbackProvider;
import org.springframework.ai.tool.method.MethodToolCallbackProvider;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * Implementation of the McpServerService interface.
 * This service provides functionality for handling MCP server operations.
 */
@Service
@Configuration
public class McpServerServiceImpl implements McpServerService {
    @Autowired
    private MonitorTools monitorTools;
    @Autowired
    private AlertTools alertTools;
    @Autowired
    private MetricsTools metricsTools;
    @Autowired
    private AlertDefineTools alertDefineTools;
    @Autowired
    private SkillTools skillTools;
    @Autowired
    private ScheduleTools scheduleTools;

    @Bean
    public ToolCallbackProvider hertzbeatTools() {
        // Note: DatabaseTools is NOT exposed to AI directly.
        // AI should use Skills (via skillTools) to perform database diagnostics.
        return MethodToolCallbackProvider.builder()
                .toolObjects(monitorTools, alertTools, alertDefineTools, metricsTools, 
                             skillTools, scheduleTools)
                .build();
    }
}


