When I used MCP, I simultaneously used Spring AOP, but a CGLIB proxy class was not generated for Tool. I tried many methods, but none of them worked.
there is my mcpToll codes
@Configuration
@Log4j2
@DependsOn("dataSourceAspect")
public class McpToolsConfig {
@Lazy
@Autowired
private ApplicationContext applicationContext;
@Bean
public ToolCallbackProvider functionRegistry() {
log.info("===== functionRegistry Bean 初始化开始 =====");
// 获取所有带有 @McpToolAnnotation 注解的Bean
Map<String, Object> annotatedBeans = applicationContext.getBeansWithAnnotation(McpToolAnnotation.class);
Collection<Object> tools = annotatedBeans.values();
tools.forEach(tool -> {
log.info("McpTool: {}, 代理状态: {}",
tool.getClass().getSimpleName(),
AopUtils.isAopProxy(tool));
});
return MethodToolCallbackProvider.builder()
.toolObjects(tools.toArray())
.build();
}
}