feat: Add logging for Tool to MCP to AI Agent response pipeline

This commit is contained in:
jade
2026-07-04 01:43:41 +09:00
parent ca2b74fed1
commit 05cf3a191b
2 changed files with 14 additions and 2 deletions

View File

@@ -124,7 +124,13 @@ public class McpRouterController {
}
try {
return ResponseEntity.ok(executeService.execute(payload, tenantId));
Object result = executeService.execute(payload, tenantId);
try {
log.info("\n [MCP Gateway -> AI Agent] 최종 응답 반환: {}", objectMapper.writeValueAsString(result));
} catch (Exception e) {
log.info("\n [MCP Gateway -> AI Agent] 최종 응답 반환: {}", result);
}
return ResponseEntity.ok(result);
} catch (SecurityException se) {
log.warn(" [보안 차단] 권한 오류: {}", se.getMessage());
return ResponseEntity.status(403).body(Map.of("error", se.getMessage()));

View File

@@ -180,10 +180,16 @@ public class BusinessToolController {
}
resultPayload.put("ai_insight", "다이렉트 메서드(" + targetMethod.getName() + ") 통신이 성공적으로 수행되었습니다.");
Map<String, Object> rpcResponse = new HashMap<>();
Map<String, Object> rpcResponse = new java.util.LinkedHashMap<>(); // 순서 보장을 위해 LinkedHashMap 사용
rpcResponse.put("jsonrpc", "2.0");
rpcResponse.put("result", resultPayload);
rpcResponse.put("id", payload != null ? payload.get("id") : null);
try {
log.info("\n [Tool -> MCP Gateway] 동적 툴 실행 결과 반환: {}", objectMapper.writeValueAsString(rpcResponse));
} catch (Exception e) {
log.info("\n [Tool -> MCP Gateway] 동적 툴 실행 결과 반환: {}", rpcResponse);
}
return rpcResponse;
} catch (Exception e) {