fix(core): bypass Spring Component scanning issues for McpTool proxies
This commit is contained in:
@@ -70,15 +70,15 @@ public class BusinessToolController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 1. 대상 Bean 및 Method 찾기 (ApplicationContext 활용)
|
|
||||||
Map<String, Object> arguments = params != null ? (Map<String, Object>) params.get("arguments") : null;
|
Map<String, Object> arguments = params != null ? (Map<String, Object>) params.get("arguments") : null;
|
||||||
Object targetBean = null;
|
Object targetBean = null;
|
||||||
Method targetMethod = null;
|
Method targetMethod = null;
|
||||||
McpFunction targetFunctionAnnotation = null;
|
McpFunction targetFunctionAnnotation = null;
|
||||||
|
|
||||||
Map<String, Object> toolBeans = applicationContext.getBeansWithAnnotation(McpTool.class);
|
// McpTool 어노테이션 기반 조회가 프록시 문제로 누락될 수 있으므로, 전체 빈을 순회하며 @McpFunction을 찾습니다.
|
||||||
|
Map<String, Object> allBeans = applicationContext.getBeansOfType(Object.class);
|
||||||
outerLoop:
|
outerLoop:
|
||||||
for (Object bean : toolBeans.values()) {
|
for (Object bean : allBeans.values()) {
|
||||||
Class<?> targetClass = AopUtils.getTargetClass(bean);
|
Class<?> targetClass = AopUtils.getTargetClass(bean);
|
||||||
for (Method method : targetClass.getDeclaredMethods()) {
|
for (Method method : targetClass.getDeclaredMethods()) {
|
||||||
McpFunction mcpFunc = AnnotationUtils.findAnnotation(method, McpFunction.class);
|
McpFunction mcpFunc = AnnotationUtils.findAnnotation(method, McpFunction.class);
|
||||||
@@ -100,7 +100,7 @@ public class BusinessToolController {
|
|||||||
|
|
||||||
if (targetBean == null || targetMethod == null) {
|
if (targetBean == null || targetMethod == null) {
|
||||||
List<String> availableFunctions = new ArrayList<>();
|
List<String> availableFunctions = new ArrayList<>();
|
||||||
for (Object bean : toolBeans.values()) {
|
for (Object bean : allBeans.values()) {
|
||||||
Class<?> targetCls = AopUtils.getTargetClass(bean);
|
Class<?> targetCls = AopUtils.getTargetClass(bean);
|
||||||
for (Method m : targetCls.getDeclaredMethods()) {
|
for (Method m : targetCls.getDeclaredMethods()) {
|
||||||
McpFunction func = AnnotationUtils.findAnnotation(m, McpFunction.class);
|
McpFunction func = AnnotationUtils.findAnnotation(m, McpFunction.class);
|
||||||
|
|||||||
@@ -68,8 +68,8 @@ public class ToolRegistryHeartbeatSender {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void scanAndBuildMetadata() {
|
private void scanAndBuildMetadata() {
|
||||||
Map<String, Object> toolBeans = applicationContext.getBeansWithAnnotation(McpTool.class);
|
Map<String, Object> allBeans = applicationContext.getBeansOfType(Object.class);
|
||||||
for (Object bean : toolBeans.values()) {
|
for (Object bean : allBeans.values()) {
|
||||||
Class<?> targetClass = AopUtils.getTargetClass(bean);
|
Class<?> targetClass = AopUtils.getTargetClass(bean);
|
||||||
McpTool toolAnnotation = AnnotationUtils.findAnnotation(targetClass, McpTool.class);
|
McpTool toolAnnotation = AnnotationUtils.findAnnotation(targetClass, McpTool.class);
|
||||||
|
|
||||||
|
|||||||
@@ -4,9 +4,11 @@ import io.shinhanlife.axhub.biz.mcp.tool.annotation.McpFunction;
|
|||||||
import io.shinhanlife.axhub.biz.mcp.tool.annotation.McpTool;
|
import io.shinhanlife.axhub.biz.mcp.tool.annotation.McpTool;
|
||||||
import io.shinhanlife.axhub.biz.mcp.tool.dto.TemplateDownloadReq;
|
import io.shinhanlife.axhub.biz.mcp.tool.dto.TemplateDownloadReq;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
|
@Service
|
||||||
@McpTool(
|
@McpTool(
|
||||||
routingType = "HTTP",
|
routingType = "HTTP",
|
||||||
group = "COMMON"
|
group = "COMMON"
|
||||||
|
|||||||
Reference in New Issue
Block a user