package dev.sonpx.loyalty.agent.config;

import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class McpConfig {

    @Bean
    public static BeanFactoryPostProcessor lazyMcpClientPostProcessor() {
        return beanFactory -> {
            for (String beanName : beanFactory.getBeanDefinitionNames()) {
                if (beanName.toLowerCase().contains("mcp") || beanName.toLowerCase().contains("toolcallbackprovider")) {
                    beanFactory.getBeanDefinition(beanName).setLazyInit(true);
                }
            }
        };
    }
}
