diff --git a/dap-gateway/src/main/java/io/shinhanlife/dap/mcg/presentation/McpRouterController.java b/dap-gateway/src/main/java/io/shinhanlife/dap/mcg/presentation/McpRouterController.java index 228c4b61..3ccfab00 100644 --- a/dap-gateway/src/main/java/io/shinhanlife/dap/mcg/presentation/McpRouterController.java +++ b/dap-gateway/src/main/java/io/shinhanlife/dap/mcg/presentation/McpRouterController.java @@ -20,6 +20,7 @@ import io.shinhanlife.dap.lib.adapter.dto.JsonRpcRequest; import io.shinhanlife.dap.lib.adapter.dto.JsonRpcResponse; import io.shinhanlife.dap.lib.adapter.dto.Params; import io.shinhanlife.dap.mcg.config.GatewayFallbackProperties; +import io.shinhanlife.dap.mcg.config.McpGatewayProperties; import io.shinhanlife.dap.mcc.dto.ToolMetadata; import io.shinhanlife.dap.mcg.registry.InMemoryRegistryService; import io.shinhanlife.dap.mcg.service.ExecuteService; @@ -60,7 +61,8 @@ public class McpRouterController { ExecuteService executeService, SecurityProperties securityProperties, ObjectMapper objectMapper, - GatewayFallbackProperties gatewayFallbackProperties) { + GatewayFallbackProperties gatewayFallbackProperties, + McpGatewayProperties mcpGatewayProperties) { this.registryService = registryService; this.executeService = executeService; this.securityProperties = securityProperties; @@ -72,7 +74,15 @@ public class McpRouterController { factory.setConnectTimeout(1000); // 연결 시도 타임아웃 1초 factory.setReadTimeout(1000); // 응답 대기 타임아웃 1초 - this.restClient = RestClient.builder().requestFactory(factory).build(); + String apiKey = mcpGatewayProperties.toolServerApiKey(); + if (apiKey == null || apiKey.isEmpty()) { + apiKey = "tool-server-key"; + } + + this.restClient = RestClient.builder() + .requestFactory(factory) + .defaultHeader("X-Tool-Server-API-Key", apiKey) + .build(); } @PostMapping("/tools/call")