feat: add get_exchange_rate and get_daily_quote tools and set categoryKey to sample
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
package io.shinhanlife.dap.mcc.service;
|
||||
|
||||
import io.shinhanlife.dap.mcc.annotation.McpFunction;
|
||||
import io.shinhanlife.dap.mcc.annotation.McpTool;
|
||||
import org.springframework.stereotype.Service;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
/**
|
||||
* @package io.shinhanlife.dap.mcc.service
|
||||
* @className DailyQuoteToolService
|
||||
* @description 랜덤 명언 제공 툴
|
||||
* @author 김형식
|
||||
* @create 2026.09.01
|
||||
* <pre>
|
||||
* ---------- 개정이력 ----------
|
||||
* 수정일 수정자 수정내용
|
||||
* ---------- -------- ---------------------------
|
||||
* 2026.09.01 김형식 최초생성
|
||||
*
|
||||
* </pre>
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@McpTool(
|
||||
routingType = "DIRECT",
|
||||
categoryKey = "sample"
|
||||
)
|
||||
public class DailyQuoteToolService extends AbstractMcpToolService {
|
||||
|
||||
public record DailyQuoteReq(String category) {}
|
||||
public record DailyQuoteRes(String quote, String author) {}
|
||||
|
||||
private final List<DailyQuoteRes> quotes = List.of(
|
||||
new DailyQuoteRes("성공은 매일 반복한 작은 노력들의 합이다.", "로버트 콜리어"),
|
||||
new DailyQuoteRes("시작이 반이다.", "아리스토텔레스"),
|
||||
new DailyQuoteRes("포기하지 않는 한 실패는 없다.", "알베르트 아인슈타인"),
|
||||
new DailyQuoteRes("가장 큰 위험은 위험 없는 삶이다.", "스티븐 코비")
|
||||
);
|
||||
|
||||
@McpFunction(register = false, displayName = "랜덤 명언 툴", name = "get_daily_quote",
|
||||
description = "무작위로 영감을 주는 명언을 하나 가져옵니다.",
|
||||
prompt = "오늘의 명언 하나 알려줘, 동기부여 명언 등",
|
||||
mappingId = "QUOTE_001"
|
||||
)
|
||||
public DailyQuoteRes execute(DailyQuoteReq req) {
|
||||
int index = new Random().nextInt(quotes.size());
|
||||
DailyQuoteRes selected = quotes.get(index);
|
||||
|
||||
log.info("[DailyQuoteTool] 명언 제공 완료: {}", selected.author());
|
||||
return selected;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package io.shinhanlife.dap.mcc.service;
|
||||
|
||||
import io.shinhanlife.dap.mcc.annotation.McpFunction;
|
||||
import io.shinhanlife.dap.mcc.annotation.McpTool;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.client.RestClient;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* @package io.shinhanlife.dap.mcc.service
|
||||
* @className ExchangeRateToolService
|
||||
* @description 실시간 환율 조회 툴
|
||||
* @author 김형식
|
||||
* @create 2026.09.01
|
||||
* <pre>
|
||||
* ---------- 개정이력 ----------
|
||||
* 수정일 수정자 수정내용
|
||||
* ---------- -------- ---------------------------
|
||||
* 2026.09.01 김형식 최초생성
|
||||
*
|
||||
* </pre>
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@McpTool(
|
||||
routingType = "DIRECT",
|
||||
categoryKey = "sample"
|
||||
)
|
||||
public class ExchangeRateToolService extends AbstractMcpToolService {
|
||||
|
||||
public record ExchangeRateReq(String currencyCode) {}
|
||||
public record ExchangeRateRes(String baseCurrency, String targetCurrency, double rate) {}
|
||||
|
||||
private final RestClient restClient;
|
||||
|
||||
public ExchangeRateToolService() {
|
||||
this.restClient = RestClient.create();
|
||||
}
|
||||
|
||||
@McpFunction(register = false, displayName = "실시간 환율 조회 툴", name = "get_exchange_rate",
|
||||
description = "원하는 통화의 실시간 환율을 조회합니다. (예: USD, EUR, JPY)",
|
||||
prompt = "현재 달러 환율 알려줘, 엔화 환율은?",
|
||||
mappingId = "EXCHANGE_001"
|
||||
)
|
||||
public ExchangeRateRes execute(ExchangeRateReq req) {
|
||||
String targetCurrency = req.currencyCode() != null ? req.currencyCode().toUpperCase().trim() : "USD";
|
||||
|
||||
// 간단한 모의 데이터로 반환 (실제 구현 시 외부 연동)
|
||||
double dummyRate = 1350.50;
|
||||
if (targetCurrency.contains("JPY")) {
|
||||
dummyRate = 905.20;
|
||||
} else if (targetCurrency.contains("EUR")) {
|
||||
dummyRate = 1450.30;
|
||||
}
|
||||
|
||||
log.info("[ExchangeRateTool] 환율 조회 완료: {} -> {}", targetCurrency, dummyRate);
|
||||
return new ExchangeRateRes("KRW", targetCurrency, dummyRate);
|
||||
}
|
||||
}
|
||||
@@ -30,7 +30,7 @@ import java.time.format.DateTimeFormatter;
|
||||
@Service
|
||||
@McpTool(
|
||||
routingType = "DIRECT",
|
||||
categoryKey = "common"
|
||||
categoryKey = "sample"
|
||||
)
|
||||
public class WeatherToolService extends AbstractMcpToolService {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user